-
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.
bump dependencies, remove fool/echolog dependency
- Loading branch information
1 parent
db951a8
commit ca85b29
Showing
9 changed files
with
208 additions
and
141 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace SugaredRim\PHPUnit\TextUI; | ||
|
||
use Schnittstabil\Get\Get; | ||
|
||
class Command extends BaseCommand | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
public function handleArguments(array $argv) | ||
{ | ||
parent::handleArguments($argv); | ||
|
||
if (Get::value('sugaredDebug', $this->arguments, false)) { | ||
$this->logDebug('Parsed arguments', $this->arguments); | ||
} | ||
|
||
$this->addListeners(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag) | ||
*/ | ||
public function run(array $argv, $exit = true) | ||
{ | ||
$argv = $this->preprocessArgv($argv); | ||
|
||
if (in_array('--sugared-debug', $argv)) { | ||
$this->logDebug('Arguments', $argv); | ||
} | ||
|
||
return parent::run($argv, $exit); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace SugaredRim\PHPUnit\TextUI; | ||
|
||
use Schnittstabil\Get\Get; | ||
|
||
class Command extends BaseCommand | ||
{ | ||
/** | ||
* {@inheritdoc} | ||
* | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
public function handleArguments(array $argv): void | ||
{ | ||
parent::handleArguments($argv); | ||
|
||
if (Get::value('sugaredDebug', $this->arguments, false)) { | ||
$this->logDebug('Parsed arguments', $this->arguments); | ||
} | ||
|
||
$this->addListeners(); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @SuppressWarnings(PHPMD.BooleanArgumentFlag) | ||
*/ | ||
public function run(array $argv, $exit = true): int | ||
{ | ||
$argv = $this->preprocessArgv($argv); | ||
|
||
if (in_array('--sugared-debug', $argv)) { | ||
$this->logDebug('Arguments', $argv); | ||
} | ||
|
||
return parent::run($argv, $exit); | ||
} | ||
} |
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,98 @@ | ||
<?php | ||
|
||
namespace SugaredRim\PHPUnit\TextUI; | ||
|
||
use Psr\Log\LoggerInterface; | ||
use Schnittstabil\ComposerExtra\ComposerExtra; | ||
use Schnittstabil\Get\Get; | ||
|
||
class BaseCommand extends \PHPUnit\TextUI\Command | ||
{ | ||
protected $argvRendererClass = Argv::class; | ||
protected $namespace = 'sugared-rim/phpunit'; | ||
protected $defaultConfig; | ||
protected $logger; | ||
protected $config; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function __construct(LoggerInterface $logger = null) | ||
{ | ||
$this->defaultConfig = new \stdClass(); | ||
$this->defaultConfig->presets = ['SugaredRim\\PHPUnit\\DefaultPreset::get']; | ||
|
||
$this->logger = $logger; | ||
|
||
$this->longOptions['sugared-coverage-text-show-uncovered-files'] | ||
= 'sugaredCoverageTextShowUncoveredFilesHandler'; | ||
$this->longOptions['sugared-debug'] = 'sugaredDebugHandler'; | ||
$this->longOptions['sugared-namespace='] = 'sugaredNamespaceHandler'; | ||
} | ||
|
||
protected function logDebug($title, $value) | ||
{ | ||
if ($this->logger !== null) { | ||
$this->logger->debug($title.': '.json_encode($value, JSON_PRETTY_PRINT)); | ||
} | ||
} | ||
|
||
protected function sugaredCoverageTextShowUncoveredFilesHandler() | ||
{ | ||
$this->arguments['coverageTextShowUncoveredFiles'] = true; | ||
} | ||
|
||
protected function sugaredDebugHandler() | ||
{ | ||
$this->arguments['sugaredDebug'] = true; | ||
} | ||
|
||
protected function sugaredNamespaceHandler($namespace) | ||
{ | ||
$this->namespace = $namespace; | ||
} | ||
|
||
/** | ||
* @SuppressWarnings(PHPMD.StaticAccess) | ||
*/ | ||
protected function addListeners() | ||
{ | ||
foreach ((array) $this->getConfig('sugared.listeners', []) as $listener) { | ||
$class = Get::value('class', $listener); | ||
$listenerClass = new \ReflectionClass($class); | ||
$arguments = json_decode(json_encode(Get::value('arguments', $listener, [])), true); | ||
|
||
$this->arguments['listeners'][] = $listenerClass->newInstanceArgs($arguments); | ||
} | ||
} | ||
|
||
protected function getConfig($path = null, $default = null) | ||
{ | ||
if ($this->config === null) { | ||
$this->config = new ComposerExtra( | ||
$this->namespace, | ||
$this->defaultConfig, | ||
'presets' | ||
); | ||
} | ||
|
||
if ($path === null) { | ||
$path = array(); | ||
} | ||
|
||
return $this->config->get($path, $default); | ||
} | ||
|
||
protected function preprocessArgv(array $argv) | ||
{ | ||
$config = $this->getConfig(); | ||
|
||
if (in_array('--sugared-debug', $argv)) { | ||
$this->logDebug('Config', $config); | ||
} | ||
|
||
$argvRenderer = new $this->argvRendererClass($config); | ||
|
||
return $argvRenderer($argv); | ||
} | ||
} |
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
Oops, something went wrong.