Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions bin/paratest
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ if (false === in_array(PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) {
exit(1);
}

#use ParaTest\UI\Text\PHPUnitTextUI;
use ParaTest\Console\Commands\ParaTestCommand;
use ParaTest\Console\Testers\PHPUnit;

#PHPUnitTextUI::main();

use ParaTest\Console\ParaTestApplication;

$app = new ParaTestApplication();
$app->run();
ParaTestCommand::applicationFactory(new PHPUnit())->run();
18 changes: 12 additions & 6 deletions src/Console/Commands/ParaTestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace ParaTest\Console\Commands;

use ParaTest\Console\Testers\Tester;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand All @@ -24,6 +25,17 @@ public function __construct(Tester $tester)
$this->tester->configure($this);
}

public static function applicationFactory(Tester $tester): Application
{
$application = new Application('ParaTest');
$command = new ParaTestCommand($tester);

$application->add($command);
$application->setDefaultCommand($command->getName(), true);

return $application;
}

/**
* Ubiquitous configuration options for ParaTest.
*/
Expand Down Expand Up @@ -100,12 +112,6 @@ protected function configure()
'Pass the given arguments verbatim to the underlying php process. Example: --passthru-php="\'-d\' ' .
'\'zend_extension=xdebug.so\'"'
)
->addOption(
'verbose',
'v',
InputOption::VALUE_REQUIRED,
'If given, debug output is printed. Example: --verbose=1'
)
->addOption('whitelist', null, InputOption::VALUE_REQUIRED, 'Directory to add to the coverage whitelist.');
}

Expand Down
60 changes: 0 additions & 60 deletions src/Console/ParaTestApplication.php

This file was deleted.

109 changes: 0 additions & 109 deletions src/Console/VersionProvider.php

This file was deleted.

48 changes: 35 additions & 13 deletions test/Unit/Console/Commands/ParaTestCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,44 @@ public function testConstructor()
$this->assertSame($this->tester, $this->getObjectValue($this->command, 'tester'));
}

public function testApplicationFactory(): void
{
$application = ParaTestCommand::applicationFactory($this->tester);
$commands = $application->all();

$this->assertArrayHasKey($this->command->getName(), $commands);
$this->assertInstanceOf(ParaTestCommand::class, $commands[$this->command->getName()]);
}

/**
* Should be configured from the ParaTest command
* as well as the Tester it is composed of.
*/
public function testConfiguredDefinitionWithPHPUnitTester()
{
$options = [
// Arguments
new InputArgument(
'path',
InputArgument::OPTIONAL,
'The path to a directory or file containing tests. <comment>(default: current directory)</comment>'
),

// Default Symfony options
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message'),
new InputOption(
'--verbose',
'-v|vv|vvv',
InputOption::VALUE_NONE,
'Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug'
),
new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version'),
new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),

// Custom options
new InputOption(
'processes',
'p',
Expand All @@ -50,7 +81,6 @@ public function testConfiguredDefinitionWithPHPUnitTester()
InputOption::VALUE_NONE,
'Run test methods instead of classes in separate processes.'
),
new InputOption('help', 'h', InputOption::VALUE_NONE, 'Display this help message.'),
new InputOption(
'phpunit',
null,
Expand Down Expand Up @@ -95,11 +125,6 @@ public function testConfiguredDefinitionWithPHPUnitTester()
'Log test execution in JUnit XML format to file.'
),
new InputOption('colors', null, InputOption::VALUE_NONE, 'Displays a colored bar as a test result.'),
new InputArgument(
'path',
InputArgument::OPTIONAL,
'The path to a directory or file containing tests. <comment>(default: current directory)</comment>'
),
new InputOption(
'no-test-tokens',
null,
Expand Down Expand Up @@ -179,12 +204,6 @@ public function testConfiguredDefinitionWithPHPUnitTester()
'Pass the given arguments verbatim to the underlying php process. ' .
'Example: --passthru-php="\'-d\' \'zend_extension=xdebug.so\'"'
),
new InputOption(
'verbose',
'v',
InputOption::VALUE_REQUIRED,
'If given, debug output is printed. Example: --verbose=1'
),
new InputOption(
'whitelist',
null,
Expand All @@ -193,7 +212,10 @@ public function testConfiguredDefinitionWithPHPUnitTester()
),
];
$expected = new InputDefinition($options);
$definition = $this->command->getDefinition();
$application = ParaTestCommand::applicationFactory($this->tester);
$command = $application->get($this->command->getName());
$command->mergeApplicationDefinition();
$definition = $command->getDefinition();
$this->assertEquals($expected, $definition);
}

Expand Down
49 changes: 0 additions & 49 deletions test/Unit/Console/VersionProviderTest.php

This file was deleted.