Skip to content

Can't mock "exit" #11

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
jmauerhan opened this issue Jun 12, 2016 · 3 comments
Closed

Can't mock "exit" #11

jmauerhan opened this issue Jun 12, 2016 · 3 comments

Comments

@jmauerhan
Copy link

When I try to mock exit I get an error:

In my test: $this->getFunctionMock('Silva', 'exit');

When I run the test:

1) Test\Unit\ApplicationTest::testRunDefaultsToHelpMenu                                            
ParseError: syntax error, unexpected 'exit' (T_EXIT), expecting identifier (T_STRING) or '('       

***\vendor\php-mock\php-mock\classes\Mock.php:180                   
***\vendor\php-mock\php-mock\classes\Mock.php:87                    
***\vendor\php-mock\php-mock-phpunit\classes\PHPMock.php:89         
***\tests\ApplicationTest.php:19                                    

ERRORS!                                                                                            
Tests: 1, Assertions: 0, Errors: 1.                                                                                                                                                              

Versions:

phpunit/phpunit                    5.4.4
php-mock/php-mock                  1.0.1 
php-mock/php-mock-integration      1.0.0 
php-mock/php-mock-phpunit          1.1.1 
@jmauerhan
Copy link
Author

Other functions can be mocked without this error.

@malkusch
Copy link
Member

malkusch commented Jun 13, 2016

You can't mock exit:

exit is a language construct

PHPMock can only mock functions.

@jmauerhan
Copy link
Author

Heh, that makes sense - I was sure I had done it before... hmm... 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