Closed ericadamski closed 7 years ago
Which tests are failing?
All of our own tests are failing. The error messages says that it cannot find the most recent migration file.
Can you give me an example of a failing test?
Every error is similar to this.
// // PHPUnit 5.6.1 by Sebastian Bergmann and contributors.
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 65 / 97 ( 67%)
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 97 / 97 (100%)
Time: 15.79 seconds, Memory: 60.00MB
There were 97 errors:
1) Tests\Integration\ApplicantsTest::itListsApplicants
Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such table: people (SQL: insert into "people" ("name", "email", "password", "remember_token", "updated_at", "created_at") values (Willow Hintz Sr., nitzsche.lucinda@example.net, $2y$10$YA9Bku1X81JpNuJPqyE76.82.M2se64cbA91BK6b6JQ08A8JYvvNm, UBEG8mAwm5, 2016-12-07 13:36:06, 2016-12-07 13:36:06))
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:761
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:717
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:481
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:435
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2142
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1433
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1607
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1576
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:1472
/Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:87
/Users/Sgt-Wikkidoo/MB3/marvel/tests/TestCase.php:23
Hmmm...a possible quick fix could be to run the following command before your tests run...
Artisan::call('migrate:disorganise');
Then, when your tests complete, run...
Artisan::call('migrate:organise');
Let me know if that works
I have already tried that, I even went as far as removing the package keeping my migrations all inside one directory and just added the provider and it still fails the same way.
Here is what I have the my base test file. There is some code that I didn't include in the setup
like creating a user.
protected function setup()
{
parent::setup();
\Artisan::call('migrate:disorganise');
}
public static function tearDownAfterClass()
{
\Artisan::call('migrate:organise', [ '--force' => true ]);
}
It crashes with an error like
// // PHPUnit 5.6.1 by Sebastian Bergmann and contributors.
EEEEEEEEPHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php:762
Stack trace:
#0 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php(643): Illuminate\Container\Container->build('Illuminate\\Cont...', Array)
#1 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(709): Illuminate\Container\Container->make('Illuminate\\Cont...', Array)
#2 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(154): Illuminate\Foundation\Application->make('Illuminate\\Cont...')
#3 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(79): Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler()
#4 [internal function]: Illuminate\Foundati in /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 762
Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php:762
Stack trace:
#0 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php(643): Illuminate\Container\Container->build('Illuminate\\Cont...', Array)
#1 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(709): Illuminate\Container\Container->make('Illuminate\\Cont...', Array)
#2 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(154): Illuminate\Foundation\Application->make('Illuminate\\Cont...')
#3 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(79): Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler()
#4 [internal function]: Illuminate\Foundati in /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 762
PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php:762
Stack trace:
#0 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php(643): Illuminate\Container\Container->build('Illuminate\\Cont...', Array)
#1 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(709): Illuminate\Container\Container->make('Illuminate\\Cont...', Array)
#2 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(154): Illuminate\Foundation\Application->make('Illuminate\\Cont...')
#3 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(79): Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler()
#4 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/la in /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 762
Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php:762
Stack trace:
#0 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php(643): Illuminate\Container\Container->build('Illuminate\\Cont...', Array)
#1 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(709): Illuminate\Container\Container->make('Illuminate\\Cont...', Array)
#2 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(154): Illuminate\Foundation\Application->make('Illuminate\\Cont...')
#3 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(79): Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler()
#4 /Users/Sgt-Wikkidoo/MB3/marvel/vendor/la in /Users/Sgt-Wikkidoo/MB3/marvel/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 762
I also cannot seem to run php artisan migrate
I get
vagrant@homestead:~/MB3/marvel$ php artisan migrate
Migration table created successfully.
Nothing to migrate.
I also cannot seem to run php artisan migrate I get
And your migrations are organised?
Yes.
What version of Laravel?
I'm running 5.3.10
Same issue when updating to latest (5.3.26)
Ive just tested it on a clean install of Laravel with no issues.
The fact it says you have nothing to migrate
when running the command in the CLI has alarm bells ringing, but pretty hard for me to debug without a proper scenario to look at.
If you could make a test app on a repo that i can pull and test with, i will definitely look into this further
Hey @JayBizzle, I'm on a team with @ericadamski.
Thanks for taking the time to go back and forth with us.
It appears to be an issue on rollback. We didn't realize it was on rollback because it was happening in our tests where we were using the DatabaseMigrations
trait. This initiates a migrate and a rollback on every test and the error was happening in the rollback.
I've been able to create the issue using a fresh install of Laravel. I've created a repo for the issue.
composer install
in the terminaltouch database/database.sqlite
in the terminalphp artisan migrate:organise
in the terminalphp artisan migrate
in the terminalphp artisan migrate:rollback
in the terminal
Laravel's rollback
method in it's Migrator.php
calls your getMigrationFiles
method, but its expecting a different format then it receives.
getMigrationFiles
in Laravel-Migrations-Organiserarray:2 [
0 => "2014_10_12_000000_create_users_table"
1 => "2014_10_12_100000_create_password_resets_table"
]
getMigrationFiles
in Built-in Laravel Migrator.phparray:2 [
"2014_10_12_000000_create_users_table" => "/Users/kory/Sites/TestMigrationOrganise/database/migrations/2014_10_12_000000_create_users_table.php"
"2014_10_12_100000_create_password_resets_table" => "/Users/kory/Sites/TestMigrationOrganise/database/migrations/2014_10_12_100000_create_password_resets_table.php"
]
I'm taking a look at this to see if I can resolve this with a PR. Let me know if you've run across this before.
Submitted PR #14 to solve this issue.
Hey @korygorsky
Thanks for that example repo, these kind of things really help when debugging this kind of stuff. I ran through the steps you mentioned and could indeed replicate the issue.
Great work on the PR, i have now merged that and released v4.0.2
Thanks again!
Glad to help out @JayBizzle. Thanks for all your work on this.
When we run the tests without the line in the
config/app.php
file they all pass. As soon as I add inJaybizzle\MigrationsOrganiser\MigrationsOrganiserServiceProvider::class,
phpunit fails not being able to find our migrations.