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 #224 from elliotchance/1.4/193-set-color-scheme
1.4/193 set color scheme
- Loading branch information
Showing
9 changed files
with
289 additions
and
57 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,89 @@ | ||
<?php | ||
|
||
namespace Concise\Console\Theme; | ||
|
||
use PHPUnit_Runner_BaseTestRunner; | ||
|
||
abstract class AbstractTheme implements ThemeInterface | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function getTheme() | ||
{ | ||
return array( | ||
PHPUnit_Runner_BaseTestRunner::STATUS_PASSED => $this->getStatusPassedColor(), | ||
PHPUnit_Runner_BaseTestRunner::STATUS_FAILURE => $this->getStatusFailureColor(), | ||
PHPUnit_Runner_BaseTestRunner::STATUS_ERROR => $this->getStatusErrorColor(), | ||
PHPUnit_Runner_BaseTestRunner::STATUS_SKIPPED => $this->getStatusSkippedColor(), | ||
PHPUnit_Runner_BaseTestRunner::STATUS_INCOMPLETE => $this->getStatusIncompleteColor(), | ||
PHPUnit_Runner_BaseTestRunner::STATUS_RISKY => $this->getStatusRiskyColor(), | ||
'value.integer' => $this->getValueIntegerColor(), | ||
'value.float' => $this->getValueFloatColor(), | ||
'value.string' => $this->getValueStringColor(), | ||
'value.closure' => $this->getValueClosureColor(), | ||
'value.null' => $this->getValueNullColor(), | ||
'value.boolean' => $this->getValueBooleanColor(), | ||
); | ||
} | ||
|
||
public function getValueIntegerColor() | ||
{ | ||
return 'red'; | ||
} | ||
|
||
public function getValueFloatColor() | ||
{ | ||
return 'magenta'; | ||
} | ||
|
||
public function getValueStringColor() | ||
{ | ||
return 'yellow'; | ||
} | ||
|
||
public function getValueClosureColor() | ||
{ | ||
return 'cyan'; | ||
} | ||
|
||
public function getValueNullColor() | ||
{ | ||
return 'blue'; | ||
} | ||
|
||
public function getValueBooleanColor() | ||
{ | ||
return 'green'; | ||
} | ||
|
||
public function getStatusPassedColor() | ||
{ | ||
return 'green'; | ||
} | ||
|
||
public function getStatusFailureColor() | ||
{ | ||
return 'red'; | ||
} | ||
|
||
public function getStatusErrorColor() | ||
{ | ||
return 'red'; | ||
} | ||
|
||
public function getStatusSkippedColor() | ||
{ | ||
return 'blue'; | ||
} | ||
|
||
public function getStatusIncompleteColor() | ||
{ | ||
return 'yellow'; | ||
} | ||
|
||
public function getStatusRiskyColor() | ||
{ | ||
return 'yellow'; | ||
} | ||
} |
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,35 @@ | ||
<?php | ||
|
||
namespace Concise\Console\Theme; | ||
|
||
interface ThemeInterface | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function getTheme(); | ||
|
||
public function getValueIntegerColor(); | ||
|
||
public function getValueFloatColor(); | ||
|
||
public function getValueStringColor(); | ||
|
||
public function getValueClosureColor(); | ||
|
||
public function getValueNullColor(); | ||
|
||
public function getValueBooleanColor(); | ||
|
||
public function getStatusPassedColor(); | ||
|
||
public function getStatusFailureColor(); | ||
|
||
public function getStatusErrorColor(); | ||
|
||
public function getStatusSkippedColor(); | ||
|
||
public function getStatusIncompleteColor(); | ||
|
||
public function getStatusRiskyColor(); | ||
} |
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,50 @@ | ||
<?php | ||
|
||
namespace Concise\Console; | ||
|
||
use \Concise\TestCase; | ||
|
||
class CommandColorSchemeTest extends TestCase | ||
{ | ||
protected $command; | ||
|
||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
$this->command = new Command(); | ||
} | ||
|
||
public function testDefaultColorSchemeIsSet() | ||
{ | ||
$this->assert($this->command->getColorScheme(), instance_of, 'Concise\Console\Theme\DefaultTheme'); | ||
} | ||
|
||
public function testColorSchemeCanBeAClassName() | ||
{ | ||
$theme = $this->mock('Concise\Console\Theme\DefaultTheme')->get(); | ||
$this->setProperty($this->command, 'colorScheme', get_class($theme)); | ||
$this->assert(get_class($this->command->getColorScheme()), equals, get_class($theme)); | ||
} | ||
|
||
/** | ||
* @expectedException \Exception | ||
* @expectedExceptionMessage No such color scheme 'Foo\Bar'. | ||
*/ | ||
public function testColorSchemeWillThrowExceptionIfColorSchemeClassDoesNotExist() | ||
{ | ||
$this->setProperty($this->command, 'colorScheme', 'Foo\Bar'); | ||
$this->command->getColorScheme(); | ||
} | ||
|
||
public function testColorSchemeCanBeAClassNameFoundInTheDefaultNamespace() | ||
{ | ||
$this->setProperty($this->command, 'colorScheme', 'Default'); | ||
$this->assert($this->command->getColorScheme(), instance_of, 'Concise\Console\Theme\DefaultTheme'); | ||
} | ||
|
||
public function testColorSchemeWithLowerCase() | ||
{ | ||
$this->setProperty($this->command, 'colorScheme', 'default'); | ||
$this->assert($this->command->getColorScheme(), instance_of, 'Concise\Console\Theme\DefaultTheme'); | ||
} | ||
} |
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
Oops, something went wrong.