| @@ 9-54 (lines=46) @@ | ||
| 6 | use LaravelZero\Framework\Contracts\Providers\Composer; |
|
| 7 | use LaravelZero\Framework\Commands\Component\Illuminate\Database\Installer; |
|
| 8 | ||
| 9 | class DatabaseInstallTest extends TestCase |
|
| 10 | { |
|
| 11 | public function tearDown() |
|
| 12 | { |
|
| 13 | File::delete(config_path('database.php')); |
|
| 14 | File::delete(database_path('database.sqlite')); |
|
| 15 | File::delete(database_path('migrations')); |
|
| 16 | File::delete(database_path('seeds'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php')); |
|
| 17 | } |
|
| 18 | ||
| 19 | /** @test */ |
|
| 20 | public function it_requires_packages(): void |
|
| 21 | { |
|
| 22 | $composerMock = $this->createMock(Composer::class); |
|
| 23 | ||
| 24 | $composerMock->expects($this->once())->method('require')->with('illuminate/database "5.5.*"'); |
|
| 25 | ||
| 26 | app()->instance(Composer::class, $composerMock); |
|
| 27 | ||
| 28 | $this->app->add(app(Installer::class)); |
|
| 29 | ||
| 30 | $this->app->call('install:database'); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** @test */ |
|
| 34 | public function it_copy_stubs(): void |
|
| 35 | { |
|
| 36 | $this->addDatabaseCommand(); |
|
| 37 | ||
| 38 | $this->app->call('install:database'); |
|
| 39 | ||
| 40 | $this->assertTrue(File::exists(config_path('database.php'))); |
|
| 41 | $this->assertTrue(File::exists(database_path('database.sqlite'))); |
|
| 42 | $this->assertTrue(File::exists(database_path('migrations'))); |
|
| 43 | $this->assertTrue(File::exists(database_path('seeds'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php'))); |
|
| 44 | } |
|
| 45 | ||
| 46 | private function addDatabaseCommand(): void |
|
| 47 | { |
|
| 48 | $composerMock = $this->createMock(Composer::class); |
|
| 49 | $composerMock->method('require'); |
|
| 50 | app()->instance(Composer::class, $composerMock); |
|
| 51 | ||
| 52 | $this->app->add(app(Installer::class)); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| @@ 9-54 (lines=46) @@ | ||
| 6 | use LaravelZero\Framework\Contracts\Providers\Composer; |
|
| 7 | use LaravelZero\Framework\Commands\Component\Illuminate\Database\Installer; |
|
| 8 | ||
| 9 | class InstallDatabaseTest extends TestCase |
|
| 10 | { |
|
| 11 | public function tearDown() |
|
| 12 | { |
|
| 13 | File::delete(config_path('database.php')); |
|
| 14 | File::delete(database_path('database.sqlite')); |
|
| 15 | File::delete(database_path('migrations')); |
|
| 16 | File::delete(database_path('seeds'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php')); |
|
| 17 | } |
|
| 18 | ||
| 19 | /** @test */ |
|
| 20 | public function it_requires_packages(): void |
|
| 21 | { |
|
| 22 | $composerMock = $this->createMock(Composer::class); |
|
| 23 | ||
| 24 | $composerMock->expects($this->once())->method('require')->with('illuminate/database "5.5.*"'); |
|
| 25 | ||
| 26 | app()->instance(Composer::class, $composerMock); |
|
| 27 | ||
| 28 | $this->app->add(app(Installer::class)); |
|
| 29 | ||
| 30 | $this->app->call('install:database'); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** @test */ |
|
| 34 | public function it_copy_stubs(): void |
|
| 35 | { |
|
| 36 | $this->addDatabaseCommand(); |
|
| 37 | ||
| 38 | $this->app->call('install:database'); |
|
| 39 | ||
| 40 | $this->assertTrue(File::exists(config_path('database.php'))); |
|
| 41 | $this->assertTrue(File::exists(database_path('database.sqlite'))); |
|
| 42 | $this->assertTrue(File::exists(database_path('migrations'))); |
|
| 43 | $this->assertTrue(File::exists(database_path('seeds'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php'))); |
|
| 44 | } |
|
| 45 | ||
| 46 | private function addDatabaseCommand(): void |
|
| 47 | { |
|
| 48 | $composerMock = $this->createMock(Composer::class); |
|
| 49 | $composerMock->method('require'); |
|
| 50 | app()->instance(Composer::class, $composerMock); |
|
| 51 | ||
| 52 | $this->app->add(app(Installer::class)); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||