Skip to content

Error while mocking built-in functions like curl_init #8

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
dlevel opened this issue May 10, 2016 · 3 comments
Closed

Error while mocking built-in functions like curl_init #8

dlevel opened this issue May 10, 2016 · 3 comments

Comments

@dlevel
Copy link

dlevel commented May 10, 2016

Hi,

It is certainly a miss use of the library but I always get an error that said that the function registerMockObject does not exist.

I deeped into the library to find it and I didn't see any information in the README to fix this.

Thank you.

@malkusch
Copy link
Member

malkusch commented May 10, 2016

Could you please give a full stack trace and a minimal code example to
produce that situation?

@dlevel
Copy link
Author

dlevel commented May 10, 2016

Here is the sample of code:

public function testAuthenticationFailureWrongAuthorizationCode() { $this->getFunctionMock(__NAMESPACE__, "curl_init"); }

And the stack trace :

PHPUnit_Framework_Exception: PHP Fatal error: Call to undefined method JsonRpc\Authentication\AuthTest::registerMockObject() in /var/www/api-gateway/vendor/phpunit/phpunit-mock-objects/src/Framework/MockObject/MockBuilder.php on line 136 PHP Stack trace: PHP 1. {main}() -:0 PHP 2. __phpunit_run_isolated_test() -:92 PHP 3. PHPUnit_Framework_TestCase->run() -:53 PHP 4. PHPUnit_Framework_TestResult->run() /var/www/api-gateway/vendor/phpunit/phpunit/src/Framework/TestCase.php:801 PHP 5. PHPUnit_Framework_TestCase->runBare() /var/www/api-gateway/vendor/phpunit/phpunit/src/Framework/TestResult.php:685 PHP 6. PHPUnit_Framework_TestCase->runTest() /var/www/api-gateway/vendor/phpunit/phpunit/src/Framework/TestCase.php:845 PHP 7. ReflectionMethod->invokeArgs() /var/www/api-gateway/vendor/phpunit/phpunit/src/Framework/TestCase.php:985 PHP 8. JsonRpc\Authentication\AuthTest->testAuthenticationFailureWrongAuthorizationCode() /var/www/api-gateway/vendor/phpunit/phpunit/src/Framework/TestCase.php:985 PHP 9. JsonRpc\Authentication\AuthTest->getFunctionMock() /var/www/api-gateway/module/JsonRpc/tests/Authentication/AuthTest.php:145 PHP 10. PHPUnit_Framework_MockObject_MockBuilder->getMockForAbstractClass() /var/www/api-gateway/vendor/php-mock/php-mock-phpunit/classes/PHPMock.php:79

@dlevel
Copy link
Author

dlevel commented May 10, 2016

It seems that the bug only occurs in my ide but not when I run it through the console. Maybe it is due to an autoloading issue on my side.

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