forked from CouscousPHP/Couscous
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for OverrideConfigFromCLI step
Contains 3 test cases (well-formed array, empty array, missing option)
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
tests/UnitTest/Module/Config/Step/OverrideConfigFromCLITest.php
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,63 @@ | ||
<?php | ||
|
||
namespace Couscous\Tests\UnitTest\Module\Config\Step; | ||
|
||
use Couscous\Module\Config\Step\OverrideConfigFromCLI; | ||
use Couscous\Tests\UnitTest\Mock\MockProject; | ||
use Psr\Log\LoggerInterface; | ||
|
||
/** | ||
* @covers \Couscous\Module\Config\Step\OverrideConfigFromCLI | ||
*/ | ||
class OverrideConfigFromCLITest extends \PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function should_override_title_if_specified() | ||
{ | ||
$project = new MockProject(); | ||
$project->metadata['title'] = 'foo'; | ||
$project->metadata['cliConfig'] = ['title=bar']; | ||
|
||
$logger = $this->getMock("Psr\Log\LoggerInterface"); | ||
|
||
$step = new OverrideConfigFromCLI($logger); | ||
$step->__invoke($project); | ||
|
||
$this->assertEquals('bar', $project->metadata['title']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function should_not_override_title_if_not_specified() | ||
{ | ||
$project = new MockProject(); | ||
$project->metadata['title'] = 'foo'; | ||
$project->metadata['cliConfig'] = []; | ||
|
||
$logger = $this->getMock("Psr\Log\LoggerInterface"); | ||
|
||
$step = new OverrideConfigFromCLI($logger); | ||
$step->__invoke($project); | ||
|
||
$this->assertEquals('foo', $project->metadata['title']); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function should_not_override_title_if_no_cliConfig() | ||
{ | ||
$project = new MockProject(); | ||
$project->metadata['title'] = 'foo'; | ||
|
||
$logger = $this->getMock("Psr\Log\LoggerInterface"); | ||
|
||
$step = new OverrideConfigFromCLI($logger); | ||
$step->__invoke($project); | ||
|
||
$this->assertEquals('foo', $project->metadata['title']); | ||
} | ||
} |