ixudra
320
3
Testing

Mockery: cannot redeclare method

Posted 3 months ago by ixudra

Updated my composer file and suddenly all my tests fail:

- AccountControllerTest: Index
PHP Fatal error:  Cannot redeclare Mockery_0_Illuminate_Auth_Access_Gate::allows() in /var/www/project/htdocs/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php(34) : eval()'d code on line 1003
PHP Stack trace:
PHP   1. {main}() /var/www/project/htdocs/vendor/codeception/codeception/codecept:0
PHP   2. Codeception\Application->run() /var/www/project/htdocs/vendor/codeception/codeception/codecept:43
PHP   3. Codeception\Application->run() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/Application.php:108
PHP   4. Codeception\Application->doRun() /var/www/project/htdocs/vendor/symfony/console/Application.php:145
PHP   5. Codeception\Application->doRunCommand() /var/www/project/htdocs/vendor/symfony/console/Application.php:269
PHP   6. Codeception\Command\Run->run() /var/www/project/htdocs/vendor/symfony/console/Application.php:908
PHP   7. Codeception\Command\Run->execute() /var/www/project/htdocs/vendor/symfony/console/Command/Command.php:255
PHP   8. Codeception\Command\Run->runSuites() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/Command/Run.php:390
PHP   9. Codeception\Codecept->run() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/Command/Run.php:495
PHP  10. Codeception\Codecept->runSuite() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/Codecept.php:159
PHP  11. Codeception\SuiteManager->run() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/Codecept.php:192
PHP  12. Codeception\PHPUnit\Runner->doEnhancedRun() /var/www/project/htdocs/vendor/codeception/codeception/src/Codeception/SuiteManager.php:158
PHP  13. Codeception\Suite->run() /var/www/project/htdocs/vendor/codeception/phpunit-wrapper/src/Runner.php:118
PHP  14. AccountControllerTest->run() /var/www/project/htdocs/vendor/phpunit/phpunit/src/Framework/TestSuite.php:746
PHP  15. PHPUnit\Framework\TestResult->run() /var/www/project/htdocs/vendor/phpunit/phpunit/src/Framework/TestCase.php:796
PHP  16. AccountControllerTest->runBare() /var/www/project/htdocs/vendor/phpunit/phpunit/src/Framework/TestResult.php:687
PHP  17. AccountControllerTest->setUp() /var/www/project/htdocs/vendor/phpunit/phpunit/src/Framework/TestCase.php:838
PHP  18. Illuminate\Support\Facades\Facade::shouldReceive() /var/www/project/htdocs/tests/unit/base/BaseUnitTestCase.php:16
PHP  19. Illuminate\Support\Facades\Facade::createFreshMockInstance() /var/www/project/htdocs/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:66
PHP  20. Illuminate\Support\Facades\Facade::createMock() /var/www/project/htdocs/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:78
PHP  21. Mockery::mock() /var/www/project/htdocs/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:94
PHP  22. Mockery\Container->mock() /var/www/project/htdocs/vendor/mockery/mockery/library/Mockery.php:117
PHP  23. Mockery\Loader\EvalLoader->load() /var/www/project/htdocs/vendor/mockery/mockery/library/Mockery/Container.php:224

In EvalLoader.php(34) : eval()'d code line 1003:

Cannot redeclare Mockery_0_Illuminate_Auth_Access_Gate::allows()

Anyone got any ideas?

  • Laravel: 5.7.28
  • Mockery: 1.2.2
  • Codeception: 2.2.5

Please sign in or create an account to participate in this conversation.