generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from salahhusa9/Tests-Pipelines
Tests pipelines
- Loading branch information
Showing
10 changed files
with
311 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Salahhusa9\Updater\Tests\Pipelines; | ||
|
||
use Illuminate\Support\Facades\Process; | ||
use Salahhusa9\Updater\Pipelines\ArtisanCallCacheClearPipe; | ||
use Salahhusa9\Updater\Tests\TestCase; | ||
|
||
class ArtisanCallCacheClearPipeTest extends TestCase | ||
{ | ||
public function test_run_handle() | ||
{ | ||
Process::fake([ | ||
'*' => Process::result('cache:clear'), | ||
]); | ||
|
||
$messages = [ | ||
'Clearing cache...', | ||
'Cache cleared!', | ||
]; | ||
|
||
$content = [ | ||
'output' => function ($message) use ($messages) { | ||
$this->assertTrue(in_array($message, $messages)); | ||
}, | ||
]; | ||
|
||
$next = function ($result) use ($content) { | ||
$this->assertEquals($result, $content); | ||
}; | ||
|
||
app()->make(ArtisanCallCacheClearPipe::class)->handle($content, $next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Salahhusa9\Updater\Tests\Pipelines; | ||
|
||
use Illuminate\Support\Facades\Process; | ||
use Salahhusa9\Updater\Pipelines\ArtisanCallConfigClearPipe; | ||
use Salahhusa9\Updater\Tests\TestCase; | ||
|
||
class ArtisanCallConfigClearPipeTest extends TestCase | ||
{ | ||
public function test_run_handle() | ||
{ | ||
Process::fake([ | ||
'*' => Process::result('config:clear'), | ||
]); | ||
|
||
$messages = [ | ||
'Clearing config cache...', | ||
'Config cache cleared!', | ||
]; | ||
|
||
$content = [ | ||
'output' => function ($message) use ($messages) { | ||
$this->assertTrue(in_array($message, $messages)); | ||
}, | ||
]; | ||
|
||
$next = function ($result) use ($content) { | ||
$this->assertEquals($result, $content); | ||
}; | ||
|
||
app()->make(ArtisanCallConfigClearPipe::class)->handle($content, $next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Salahhusa9\Updater\Tests\Pipelines; | ||
|
||
use Illuminate\Support\Facades\Process; | ||
use Salahhusa9\Updater\Pipelines\ArtisanCallMigratePipe; | ||
use Salahhusa9\Updater\Tests\TestCase; | ||
|
||
class ArtisanCallMigratePipeTest extends TestCase | ||
{ | ||
public function test_run_handle() | ||
{ | ||
Process::fake([ | ||
'*' => Process::result('migrate'), | ||
]); | ||
|
||
$messages = [ | ||
'Migrating...', | ||
'Migrated!', | ||
]; | ||
|
||
$content = [ | ||
'output' => function ($message) use ($messages) { | ||
$this->assertTrue(in_array($message, $messages)); | ||
}, | ||
]; | ||
|
||
$next = function ($result) use ($content) { | ||
$this->assertEquals($result, $content); | ||
}; | ||
|
||
app()->make(ArtisanCallMigratePipe::class)->handle($content, $next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Salahhusa9\Updater\Tests\Pipelines; | ||
|
||
use Illuminate\Support\Facades\Process; | ||
use Salahhusa9\Updater\Pipelines\ArtisanCallOptimizePipe; | ||
use Salahhusa9\Updater\Tests\TestCase; | ||
|
||
class ArtisanCallOptimizePipeTest extends TestCase | ||
{ | ||
public function test_run_handle() | ||
{ | ||
Process::fake([ | ||
'*' => Process::result('optimize'), | ||
]); | ||
|
||
$messages = [ | ||
'Optimizing...', | ||
'Optimized!', | ||
]; | ||
|
||
$content = [ | ||
'output' => function ($message) use ($messages) { | ||
$this->assertTrue(in_array($message, $messages)); | ||
}, | ||
]; | ||
|
||
$next = function ($result) use ($content) { | ||
$this->assertEquals($result, $content); | ||
}; | ||
|
||
app()->make(ArtisanCallOptimizePipe::class)->handle($content, $next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Salahhusa9\Updater\Tests\Pipelines; | ||
|
||
use Illuminate\Support\Facades\Process; | ||
use Salahhusa9\Updater\Pipelines\ArtisanCallRouteClearPipe; | ||
use Salahhusa9\Updater\Tests\TestCase; | ||
|
||
class ArtisanCallRouteClearPipeTest extends TestCase | ||
{ | ||
public function test_run_handle() | ||
{ | ||
Process::fake([ | ||
'*' => Process::result('route:clear'), | ||
]); | ||
|
||
$messages = [ | ||
'Clearing route cache...', | ||
'Route cache cleared!', | ||
]; | ||
|
||
$content = [ | ||
'output' => function ($message) use ($messages) { | ||
$this->assertTrue(in_array($message, $messages)); | ||
}, | ||
]; | ||
|
||
$next = function ($result) use ($content) { | ||
$this->assertEquals($result, $content); | ||
}; | ||
|
||
app()->make(ArtisanCallRouteClearPipe::class)->handle($content, $next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Salahhusa9\Updater\Tests\Pipelines; | ||
|
||
use Illuminate\Support\Facades\Process; | ||
use Salahhusa9\Updater\Pipelines\ArtisanCallViewClearPipe; | ||
use Salahhusa9\Updater\Tests\TestCase; | ||
|
||
class ArtisanCallViewClearPipeTest extends TestCase | ||
{ | ||
public function test_run_handle() | ||
{ | ||
Process::fake([ | ||
'*' => Process::result('view:clear'), | ||
]); | ||
|
||
$messages = [ | ||
'Clearing view cache...', | ||
'View cache cleared!', | ||
]; | ||
|
||
$content = [ | ||
'output' => function ($message) use ($messages) { | ||
$this->assertTrue(in_array($message, $messages)); | ||
}, | ||
]; | ||
|
||
$next = function ($result) use ($content) { | ||
$this->assertEquals($result, $content); | ||
}; | ||
|
||
app()->make(ArtisanCallViewClearPipe::class)->handle($content, $next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
namespace Salahhusa9\Updater\Tests\Pipelines; | ||
|
||
use Illuminate\Support\Facades\Process; | ||
use Salahhusa9\Updater\Pipelines\GitPipe; | ||
use Salahhusa9\Updater\Tests\TestCase; | ||
|
||
class GitPipeTest extends TestCase | ||
{ | ||
public function test_run_handle() | ||
{ | ||
Process::fake([ | ||
'*' => Process::result('1.0.0'), // this for return $version in getCurrentVersion() | ||
]); | ||
|
||
$messages = [ | ||
'Downloading version 1.0.0 ...', | ||
'Checkout success', | ||
]; | ||
|
||
$content = [ | ||
'output' => function ($message) use ($messages) { | ||
$this->assertTrue(in_array($message, $messages)); | ||
}, | ||
'new_version' => '1.0.0', | ||
]; | ||
|
||
$next = function ($result) use ($content) { | ||
$this->assertEquals($result, $content); | ||
}; | ||
|
||
app()->make(GitPipe::class)->handle($content, $next); | ||
} | ||
|
||
public function test_run_handle_with_error() | ||
{ | ||
$this->expectException(\Exception::class); | ||
|
||
Process::fake([ | ||
'*' => Process::result('error'), // this for throw new \Exception('git checkout failed: '.$checkout); becouse $checkout = Git::checkout($version); return error | ||
]); | ||
|
||
$messages = [ | ||
'Downloading version 1.0.0 ...', | ||
'git checkout failed: error', | ||
]; | ||
|
||
$content = [ | ||
'output' => function ($message) use ($messages) { | ||
$this->assertTrue(in_array($message, $messages)); | ||
}, | ||
'new_version' => '1.0.0', | ||
]; | ||
|
||
$next = function ($result) use ($content) { | ||
$this->assertEquals($result, $content); | ||
}; | ||
|
||
app()->make(GitPipe::class)->handle($content, $next); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
namespace Salahhusa9\Updater\Tests\Pipelines; | ||
|
||
use Salahhusa9\Updater\Pipelines\SeedersPipe; | ||
use Salahhusa9\Updater\Tests\TestCase; | ||
|
||
class SeedersPipeTest extends TestCase | ||
{ | ||
public function test_run_handle() | ||
{ | ||
$messages = [ | ||
'Seeding...', | ||
'Seeded!', | ||
]; | ||
|
||
$content = [ | ||
'output' => function ($message) use ($messages) { | ||
$this->assertTrue(in_array($message, $messages)); | ||
}, | ||
]; | ||
|
||
$next = function ($result) use ($content) { | ||
$this->assertEquals($result, $content); | ||
}; | ||
|
||
config()->set('updater.seeders', [ | ||
|
||
]); | ||
|
||
app()->make(SeedersPipe::class)->handle($content, $next); | ||
} | ||
} |