-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Errors when unit testing #162
Comments
On Travis and locally on my machine the test seem to run just fine. Please not that the test use a |
Ok well that is good then. Maybe its something with my setup? If this continues and I can track it down I will try and provide more information. Thank you for the quick response. |
I'm having the same problem. Did you find a way to work around this? |
I posted a workaround to a related issue the other day. Perhaps these comments may help: #457 (comment) |
I'm attempting to unit test one of my classes. Problem seems that the PermissionRegistar is being asked for before the migrations get run. I'm not really sure how to fix this as it might be more a problem for Laravel then with your code. If the tables already exist (which they would live) but have not been created yet because you are migrating them inside a unit test, then this error happens. I've adjusted the error output to return the trace so you can see what is happening.
[2017-01-09 10:47:50] testing.ALERT: Could not register permissionsSQLSTATE[42S02]: Base table or view not found: 1146 Table 'testing.permissions' doesn't exist (SQL: select * from
permissions)#0 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Database/Connection.php(726): Illuminate\Database\Connection->runQueryCallback('select * from
...', Array, Object(Closure))#1 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Database/Connection.php(351): Illuminate\Database\Connection->run('select * from
...', Array, Object(Closure)) #2 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1648): Illuminate\Database\Connection->select('select * from
...', Array, true)#3 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1634): Illuminate\Database\Query\Builder->runSelect()
#4 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(636): Illuminate\Database\Query\Builder->get(Array)
#5 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(327): Illuminate\Database\Eloquent\Builder->getModels(Array)
#6 /home/vagrant/pesq/vendor/spatie/laravel-permission/src/PermissionRegistrar.php(76): Illuminate\Database\Eloquent\Builder->get()
#7 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(349): Spatie\Permission\PermissionRegistrar->Spatie\Permission{closure}()
#8 /home/vagrant/pesq/vendor/spatie/laravel-permission/src/PermissionRegistrar.php(77): Illuminate\Cache\Repository->rememberForever('spatie.permissi...', Object(Closure))
#9 /home/vagrant/pesq/vendor/spatie/laravel-permission/src/PermissionRegistrar.php(46): Spatie\Permission\PermissionRegistrar->getPermissions()
#10 /home/vagrant/pesq/vendor/spatie/laravel-permission/src/PermissionServiceProvider.php(37): Spatie\Permission\PermissionRegistrar->registerPermissions()
#11 [internal function]: Spatie\Permission\PermissionServiceProvider->boot(Object(Spatie\Permission\PermissionRegistrar))
#12 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Container/Container.php(508): call_user_func_array(Array, Array)
#13 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(769): Illuminate\Container\Container->call(Array)
#14 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(752): Illuminate\Foundation\Application->bootProvider(Object(Spatie\Permission\PermissionServiceProvider))
#15 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation{closure}(Object(Spatie\Permission\PermissionServiceProvider), 25)
#16 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(753): array_walk(Array, Object(Closure))
#17 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application->boot()
#18 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#19 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(267): Illuminate\Foundation\Application->bootstrapWith(Array)
#20 /home/vagrant/pesq/tests/TestCase.php(21): Illuminate\Foundation\Console\Kernel->bootstrap()
#21 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php(91): TestCase->createApplication()
#22 /home/vagrant/pesq/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php(66): Illuminate\Foundation\Testing\TestCase->refreshApplication()
#23 /home/vagrant/pesq/vendor/phpunit/phpunit/src/Framework/TestCase.php(950): Illuminate\Foundation\Testing\TestCase->setUp()
#24 /home/vagrant/pesq/vendor/phpunit/phpunit/src/Framework/TestResult.php(701): PHPUnit_Framework_TestCase->runBare()
#25 /home/vagrant/pesq/vendor/phpunit/phpunit/src/Framework/TestCase.php(909): PHPUnit_Framework_TestResult->run(Object(ReceiveMailTest))
#26 /home/vagrant/pesq/vendor/phpunit/phpunit/src/Framework/TestSuite.php(753): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
#27 /home/vagrant/pesq/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(465): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult))
#28 /home/vagrant/pesq/vendor/phpunit/phpunit/src/TextUI/Command.php(185): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array, true)
#29 /home/vagrant/pesq/vendor/phpunit/phpunit/src/TextUI/Command.php(115): PHPUnit_TextUI_Command->run(Array, true)
#30 /home/vagrant/pesq/vendor/phpunit/phpunit/phpunit(47): PHPUnit_TextUI_Command::main()
#31 {main}`
The text was updated successfully, but these errors were encountered: