Skip to content

sample test doesn't work #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bartonhammond opened this issue Oct 17, 2017 · 2 comments
Closed

sample test doesn't work #17

bartonhammond opened this issue Oct 17, 2017 · 2 comments

Comments

@bartonhammond
Copy link

here is test:

<?php
class UtilTest extends \PHPUnit\Framework\TestCase {
    use \phpmock\phpunit\PHPMock;
    public function testTime()
    {
        $time = $this->getFunctionMock(__NAMESPACE__, "time");
        $time->expects($this->once())->willReturn(3);
        $this->assertEquals(3, time());
    }
}

and console output:

$ vendor/bin/phpunit 
PHPUnit 5.7.23 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 48 ms, Memory: 5.25MB

There was 1 failure:

1) UtilTest::testTime
Failed asserting that 1508265379 matches expected 3.

/Users/barton/projects/wisnet/wisnetds/Tests/utilities/UtilTest.php:13

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

And php version:

~/projects/wisnet/wisnetds (unittest)$ php -v
PHP 5.6.31 (cli) (built: Aug  7 2017 20:28:16) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Xdebug v2.5.5, Copyright (c) 2002-2017, by Derick Rethans
~/projects/wisnet/wisnetds (unittest)$ 

@malkusch
Copy link
Member

Put UtilTest into a namespace.

@bartonhammond
Copy link
Author

That did it. Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants