/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Database/DatabaseMigrationMakeCommandTest.php
119 строк
5 KB
Jason McCreary
[13.x] Mockery cleanup (#61117)
10 авг 2026, 20:23
Не верифицирован
10 авг 2026, 20:23
2ee40ee
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Database; use Illuminate\Database\Console\Migrations\MigrateMakeCommand; use Illuminate\Database\Migrations\MigrationCreator; use Illuminate\Foundation\Application; use Illuminate\Support\Composer; use Mockery; use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Input\ArrayInput; use Symfony\Component\Console\Output\NullOutput; class DatabaseMigrationMakeCommandTest extends TestCase { public function testBasicCreateDumpsAutoload() { $creator = Mockery::mock(MigrationCreator::class); $composer = Mockery::mock(Composer::class); $command = new MigrateMakeCommand($creator, $composer); $app = new Application; $app->useDatabasePath(__DIR__); $command->setLaravel($app); $creator->expects('create') ->with('create_foo', __DIR__.DIRECTORY_SEPARATOR.'migrations', 'foo', true) ->andReturn(__DIR__.'/migrations/2021_04_23_110457_create_foo.php'); $this->runCommand($command, ['name' => 'create_foo']); } public function testBasicCreateGivesCreatorProperArguments() { $creator = Mockery::mock(MigrationCreator::class); $command = new MigrateMakeCommand( $creator, Mockery::mock(Composer::class)->shouldIgnoreMissing() ); $app = new Application; $app->useDatabasePath(__DIR__); $command->setLaravel($app); $creator->expects('create') ->with('create_foo', __DIR__.DIRECTORY_SEPARATOR.'migrations', 'foo', true) ->andReturn(__DIR__.'/migrations/2021_04_23_110457_create_foo.php'); $this->runCommand($command, ['name' => 'create_foo']); } public function testBasicCreateGivesCreatorProperArgumentsWhenNameIsStudlyCase() { $creator = Mockery::mock(MigrationCreator::class); $command = new MigrateMakeCommand( $creator, Mockery::mock(Composer::class)->shouldIgnoreMissing() ); $app = new Application; $app->useDatabasePath(__DIR__); $command->setLaravel($app); $creator->expects('create') ->with('create_foo', __DIR__.DIRECTORY_SEPARATOR.'migrations', 'foo', true) ->andReturn(__DIR__.'/migrations/2021_04_23_110457_create_foo.php'); $this->runCommand($command, ['name' => 'CreateFoo']); } public function testBasicCreateGivesCreatorProperArgumentsWhenTableIsSet() { $creator = Mockery::mock(MigrationCreator::class); $command = new MigrateMakeCommand( $creator, Mockery::mock(Composer::class)->shouldIgnoreMissing() ); $app = new Application; $app->useDatabasePath(__DIR__); $command->setLaravel($app); $creator->expects('create') ->with('create_foo', __DIR__.DIRECTORY_SEPARATOR.'migrations', 'users', true) ->andReturn(__DIR__.'/migrations/2021_04_23_110457_create_foo.php'); $this->runCommand($command, ['name' => 'create_foo', '--create' => 'users']); } public function testBasicCreateGivesCreatorProperArgumentsWhenCreateTablePatternIsFound() { $creator = Mockery::mock(MigrationCreator::class); $command = new MigrateMakeCommand( $creator, Mockery::mock(Composer::class)->shouldIgnoreMissing() ); $app = new Application; $app->useDatabasePath(__DIR__); $command->setLaravel($app); $creator->expects('create') ->with('create_users_table', __DIR__.DIRECTORY_SEPARATOR.'migrations', 'users', true) ->andReturn(__DIR__.'/migrations/2021_04_23_110457_create_users_table.php'); $this->runCommand($command, ['name' => 'create_users_table']); } public function testCanSpecifyPathToCreateMigrationsIn() { $creator = Mockery::mock(MigrationCreator::class); $command = new MigrateMakeCommand( $creator, Mockery::mock(Composer::class)->shouldIgnoreMissing() ); $app = new Application; $command->setLaravel($app); $app->setBasePath('/home/laravel'); $creator->expects('create') ->with('create_foo', '/home/laravel/vendor/laravel-package/migrations', 'users', true) ->andReturn('/home/laravel/vendor/laravel-package/migrations/2021_04_23_110457_create_foo.php'); $this->runCommand($command, ['name' => 'create_foo', '--path' => 'vendor/laravel-package/migrations', '--create' => 'users']); } protected function runCommand($command, $input = []) { return $command->run(new ArrayInput($input), new NullOutput); } }