-
Notifications
You must be signed in to change notification settings - Fork 2
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 #1 from caneco/release-1.1.0
[1.1.0] added a couple of features and tests
- Loading branch information
Showing
17 changed files
with
254 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ build | |
composer.lock | ||
vendor | ||
tests/temp | ||
.idea | ||
.idea | ||
.phpintel |
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
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
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 |
---|---|---|
|
@@ -58,4 +58,4 @@ private function process(string $command) | |
$this->error($e->getMessage()); | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -7,4 +7,4 @@ | |
class AliasException extends RuntimeException | ||
{ | ||
// | ||
} | ||
} |
File renamed without changes.
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,89 @@ | ||
<?php | ||
|
||
namespace Caneco\ArtisanAliases\Tests\Feature; | ||
|
||
use Caneco\ArtisanAliases\AliasManager; | ||
use Caneco\ArtisanAliases\AliasModel; | ||
use Caneco\ArtisanAliases\Exceptions\AliasException; | ||
use Illuminate\Support\Facades\Artisan; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AliasManagerTest extends TestCase | ||
{ | ||
protected $path = __DIR__.'/../tmp/laravel_aliases'; | ||
|
||
public function setUp() | ||
{ | ||
copy(__DIR__.'/../../stubs/laravel_aliases', $this->path); | ||
|
||
Artisan::shouldReceive('all') | ||
->andReturn(['laravel' => 'inspire']); | ||
} | ||
|
||
public function tearDown() | ||
{ | ||
array_map('unlink', glob(__DIR__.'/tmp/*')); | ||
} | ||
|
||
/** @test */ | ||
public function an_exception_is_not_thrown_if_the_file_does_not_exist() | ||
{ | ||
$manager = new AliasManager('MISSING_' . $this->path); | ||
|
||
$this->assertEmpty($manager->safeLoadFile()); | ||
} | ||
|
||
/** @test */ | ||
public function stub_file_contains_the_initial_aliases() | ||
{ | ||
$manager = new AliasManager($this->path); | ||
|
||
$this->assertEquals( | ||
'laravel=inspire,# cc=clear-compiled', | ||
implode(',', $manager->loadFile()) | ||
); | ||
} | ||
|
||
/** @test */ | ||
public function initial_aliases_from_stub_are_imported_on_load() | ||
{ | ||
$manager = new AliasManager($this->path); | ||
|
||
$this->assertEquals( | ||
'{"laravel":"inspire"}', | ||
json_encode($manager->load()) | ||
); | ||
} | ||
|
||
/** @test */ | ||
public function an_alias_can_be_saved() | ||
{ | ||
$manager = new AliasManager($this->path); | ||
$manager->save(AliasModel::parse('example=alias')); | ||
$alias = $manager->load(); | ||
|
||
$this->assertArrayHasKey('example', $alias); | ||
$this->assertContains('alias', array_values($alias)); | ||
} | ||
|
||
/** @test */ | ||
public function an_exception_is_thrown_storing_an_alias_that_already_exists() | ||
{ | ||
$this->expectException(AliasException::class); | ||
$this->expectExceptionMessage("Artisan command/alias already exists!"); | ||
|
||
$manager = new AliasManager($this->path); | ||
$manager->save(AliasModel::parse('laravel=expires')); | ||
} | ||
|
||
/** @test */ | ||
public function force_storing_an_alias_that_already_exists() | ||
{ | ||
$manager = new AliasManager($this->path); | ||
$manager->save(AliasModel::parse('laravel=expires'), $force = true); | ||
$alias = $manager->load(); | ||
|
||
$this->assertArrayHasKey('laravel', $alias); | ||
$this->assertContains('expires', array_values($alias)); | ||
} | ||
} |
Oops, something went wrong.