Laravel-Test-Helpers
Laravel-Test-Helpers copied to clipboard
Factory::create - Fatal error: maximum function nesting level reached
Using sqlite3 with Laravel's default settings, the Factory::create method fails with the example code on page 102 of Laravel Testing Decoded.
CREATE TABLE "authors" (
"author_id" integer not null primary key autoincrement,
"name" varchar not null,
"email" varchar not null,
"created_at" datetime not null,
"updated_at" datetime not null
);
Call Stack:
0.0002 236552 1. {main}() /Users/Xlator/code/composer-packages/vendor/phpunit/phpunit/composer/bin/phpunit:0
0.0031 514272 2. PHPUnit_TextUI_Command::main() /Users/Xlator/code/composer-packages/vendor/phpunit/phpunit/composer/bin/phpunit:63
0.0031 514896 3. PHPUnit_TextUI_Command->run() /Users/Xlator/code/composer-packages/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
0.0574 3422752 4. PHPUnit_TextUI_TestRunner->doRun() /Users/Xlator/code/composer-packages/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:176
0.0600 3714200 5. PHPUnit_Framework_TestSuite->run() /Users/Xlator/code/jway-laravel-testing/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:349
0.1628 11408848 6. PHPUnit_Framework_TestSuite->run() /Users/Xlator/code/jway-laravel-testing/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:705
0.2116 15927040 7. PHPUnit_Framework_TestSuite->runTest() /Users/Xlator/code/jway-laravel-testing/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
0.2116 15927040 8. PHPUnit_Framework_TestCase->run() /Users/Xlator/code/jway-laravel-testing/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
0.2116 15927040 9. PHPUnit_Framework_TestResult->run() /Users/Xlator/code/jway-laravel-testing/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:783
0.2117 15927808 10. PHPUnit_Framework_TestCase->runBare() /Users/Xlator/code/jway-laravel-testing/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php:648
0.2183 16210400 11. PHPUnit_Framework_TestCase->runTest() /Users/Xlator/code/jway-laravel-testing/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:838
0.2184 16211176 12. ReflectionMethod->invokeArgs() /Users/Xlator/code/jway-laravel-testing/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
0.2184 16211272 13. AuthorTest->testIsInvalidWithoutUniqueEmail() /Users/Xlator/code/jway-laravel-testing/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
0.2184 16211408 14. Way\Tests\Factory::create() /Users/Xlator/code/jway-laravel-testing/app/tests/models/AuthorTest.php:23
0.2184 16211656 15. Way\Tests\Factory::make() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:82
0.2184 16211976 16. Way\Tests\Factory->fire() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:117
0.2185 16212248 17. Way\Tests\Factory->setColumns() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:148
0.2185 16213240 18. Way\Tests\Factory->createRelationship() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:246
0.2185 16213320 19. Way\Tests\Factory::create() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:346
0.2185 16213456 20. Way\Tests\Factory::make() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:82
0.2186 16213776 21. Way\Tests\Factory->fire() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:117
0.2186 16214048 22. Way\Tests\Factory->setColumns() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:148
0.2186 16214928 23. Way\Tests\Factory->createRelationship() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:246
0.2186 16215008 24. Way\Tests\Factory::create() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:346
0.2186 16215144 25. Way\Tests\Factory::make() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:82
0.2187 16215464 26. Way\Tests\Factory->fire() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:117
0.2187 16215736 27. Way\Tests\Factory->setColumns() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:148
0.2187 16216616 28. Way\Tests\Factory->createRelationship() /Users/Xlator/code/jway-laravel-testing/vendor/way/laravel-test-helpers/src/Way/Tests/Factory.php:246
etc. etc.
Created the author model with Factory::author
and then saved it with $author->save()
as a workaround.
had same problem with mysql and phpunit nesting function limit with 100!
This happens when a field has the classname followed by the id eg user_id
is used as the primary key for the users
table. I have submitted a pull request with a fix but until that is accepted you can use
composer require "grandadevans/laravel-test-helpers:dev-master"
I shall keep my version active for quite a bit of time after the pull request has been accepted in case you haven't realised.