Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
rappasoft authored and actions-user committed Mar 8, 2021
1 parent 8f7fdd5 commit 1adde70
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 26 deletions.
2 changes: 1 addition & 1 deletion tests/Commands/PatchMakeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Rappasoft\LaravelPatches\Tests\Commands;

use InvalidArgumentException;
use Illuminate\Support\Facades\File;
use InvalidArgumentException;
use Rappasoft\LaravelPatches\Tests\TestCase;

class PatchMakeTest extends TestCase
Expand Down
44 changes: 29 additions & 15 deletions tests/Commands/PatchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class PatchTest extends TestCase
/** @test */
public function it_runs_pending_patches()
{
file_put_contents(database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php'));
file_put_contents(
database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php')
);

$this->assertDatabaseCount('patches', 0);

Expand All @@ -28,8 +30,10 @@ public function it_runs_pending_patches()
/** @test */
public function it_increments_the_batch_number_normally()
{
file_put_contents(database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php'));
file_put_contents(
database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php')
);

$this->artisan('patch')->run();

Expand All @@ -38,8 +42,10 @@ public function it_increments_the_batch_number_normally()
'batch' => 1,
]);

file_put_contents(database_path('patches/2021_01_02_000000_my_second_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_02_000000_my_second_patch.php'));
file_put_contents(
database_path('patches/2021_01_02_000000_my_second_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_02_000000_my_second_patch.php')
);

$this->artisan('patch')->run();

Expand All @@ -52,11 +58,15 @@ public function it_increments_the_batch_number_normally()
/** @test */
public function multiple_patches_have_the_same_batch_if_run_at_the_same_time()
{
file_put_contents(database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php'));
file_put_contents(
database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php')
);

file_put_contents(database_path('patches/2021_01_02_000000_my_second_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_02_000000_my_second_patch.php'));
file_put_contents(
database_path('patches/2021_01_02_000000_my_second_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_02_000000_my_second_patch.php')
);

$this->artisan('patch')->run();

Expand All @@ -76,11 +86,15 @@ public function multiple_patches_have_the_same_batch_if_run_at_the_same_time()
/** @test */
public function it_increments_the_batch_number_by_one_if_step_is_enabled()
{
file_put_contents(database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php'));

file_put_contents(database_path('patches/2021_01_02_000000_my_second_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_02_000000_my_second_patch.php'));
file_put_contents(
database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php')
);

file_put_contents(
database_path('patches/2021_01_02_000000_my_second_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_02_000000_my_second_patch.php')
);

$this->artisan('patch', ['--step' => true])->run();

Expand Down
30 changes: 20 additions & 10 deletions tests/Commands/RollbackTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public function it_rollsback_a_patch()
{
Log::shouldReceive('info')->with('Goodbye First');

file_put_contents(database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php'));
file_put_contents(
database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php')
);

$this->assertDatabaseCount('patches', 0);

Expand Down Expand Up @@ -42,11 +44,15 @@ public function it_rollsback_all_patches_of_the_previous_batch()
Log::shouldReceive('info')->with('Goodbye First');
Log::shouldReceive('info')->with('Goodbye Second');

file_put_contents(database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php'));
file_put_contents(
database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php')
);

file_put_contents(database_path('patches/2021_01_02_000000_my_second_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_02_000000_my_second_patch.php'));
file_put_contents(
database_path('patches/2021_01_02_000000_my_second_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_02_000000_my_second_patch.php')
);

$this->artisan('patch')->run();

Expand All @@ -62,11 +68,15 @@ public function it_rollsback_the_correct_patches_with_step()
{
Log::shouldReceive('info')->once();

file_put_contents(database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php'));
file_put_contents(
database_path('patches/2021_01_01_000000_my_first_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_01_000000_my_first_patch.php')
);

file_put_contents(database_path('patches/2021_01_02_000000_my_second_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_02_000000_my_second_patch.php'));
file_put_contents(
database_path('patches/2021_01_02_000000_my_second_patch.php'),
file_get_contents(__DIR__.'/patches/2021_01_02_000000_my_second_patch.php')
);

$this->artisan('patch')->run();

Expand Down

0 comments on commit 1adde70

Please sign in to comment.