php-mock/php-mock-phpunit

Can't mock "exit"

jmauerhan opened this issue · 3 comments

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 

Other functions can be mocked without this error.

You can't mock exit:

exit is a language construct

PHPMock can only mock functions.

Heh, that makes sense - I was sure I had done it before... hmm... Thanks :)