Skip to content

Commit

Permalink
Merge pull request #111 from keradus/CS
Browse files Browse the repository at this point in the history
CS: Better PSR2 following
  • Loading branch information
DonCallisto authored Nov 11, 2017
2 parents 11f65cf + 341ac48 commit 63babaf
Show file tree
Hide file tree
Showing 15 changed files with 53 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,16 @@ public function __construct(SpecificationLocator $locator, SuiteRepository $regi
*/
public function configure(Command $command)
{
$command->addOption('list-features', null, InputOption::VALUE_NONE,
$command->addOption(
'list-features',
null,
InputOption::VALUE_NONE,
'Output a list of feature files to be executed by Behat'
);
$command->addOption('list-scenarios', null, InputOption::VALUE_NONE,
$command->addOption(
'list-scenarios',
null,
InputOption::VALUE_NONE,
'Output a list of individual scenarios to be executed by Behat'
);
}
Expand Down
6 changes: 4 additions & 2 deletions adapters/Behat/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ public function iRunBehat($argumentsString = '')
$argumentsString .= ' 2>&1';
}

exec($command = sprintf('%s %s',
BEHAT_BIN_PATH, $argumentsString
exec($command = sprintf(
'%s %s',
BEHAT_BIN_PATH,
$argumentsString
), $output, $return);

$this->lastBehatStdOut = trim(implode("\n", $output));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,16 @@ public function __construct(ContainerInterface $container)
*/
public function configure(Command $command)
{
$command->addOption('list-features', null, InputOption::VALUE_NONE,
$command->addOption(
'list-features',
null,
InputOption::VALUE_NONE,
'Output a list of feature files to be executed by Behat'
);
$command->addOption('list-scenarios', null, InputOption::VALUE_NONE,
$command->addOption(
'list-scenarios',
null,
InputOption::VALUE_NONE,
'Output a list of individual scenarios to be executed by Behat'
);
}
Expand Down
7 changes: 5 additions & 2 deletions adapters/Behat2/features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ public function iRunBehat($argumentsString = '')
$argumentsString .= ' 2>&1';
}

exec($command = sprintf('%s %s %s --no-time',
BEHAT_PHP_BIN_PATH, escapeshellarg(BEHAT_BIN_PATH), $argumentsString
exec($command = sprintf(
'%s %s %s --no-time',
BEHAT_PHP_BIN_PATH,
escapeshellarg(BEHAT_BIN_PATH),
$argumentsString
), $output, $return);

$this->lastBehatStdOut = trim(implode("\n", $output));
Expand Down
15 changes: 8 additions & 7 deletions src/Command/ParallelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,18 @@ private function getMaxNumberOfProcess($maxNumberOfParallelProc)
* @param ProcessesManager $processManager
* @return array
*/
private function doExecute(InputInterface $input,
OutputInterface $output,
QueueInterface $queue,
ProcessesManager $processManager)
{
private function doExecute(
InputInterface $input,
OutputInterface $output,
QueueInterface $queue,
ProcessesManager $processManager
) {
$processes = null;

if ($this->isVerbose($output)) {
$progressBar = new VerboseRenderer($queue->count(), $this->hasErrorSummary($input), $output);
} else {
$progressBar = new ProgressBarRenderer($queue->count(),$this->hasErrorSummary($input), $output, new ProgressBar($output));
$progressBar = new ProgressBarRenderer($queue->count(), $this->hasErrorSummary($input), $output, new ProgressBar($output));
}

$progressBar->renderHeader($queue);
Expand All @@ -145,7 +146,7 @@ private function doExecute(InputInterface $input,
* @var Processes $processes
*/
$processes->cleanUP(); //it is not getting called with -p1 after the last process otherwise
$processes->wait(function() use ($progressBar, $queue, $processes) {
$processes->wait(function () use ($progressBar, $queue, $processes) {
$progressBar->renderBody($queue, $processes);
});
$progressBar->renderFooter($queue, $processes);
Expand Down
2 changes: 1 addition & 1 deletion src/Process/ProcessesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function createProcessesForTheBeforeCommand($range, Processes &$processe
$process = $this->processFactory->createAProcessForACustomCommand($this->beforeCommand, $currentChannel, $currentProcessNumber, $this->isFirstForThisChannel($currentChannel));
$processes->add($currentChannel, $process);
$processes->start($currentChannel);
$processes->wait(function() use ($processes){
$processes->wait(function () use ($processes) {
if ($processes->getExitCode()) {
$errorOutput = $processes->getErrorOutput();
$output = current($errorOutput);
Expand Down
15 changes: 8 additions & 7 deletions src/Process/Report.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ class Report
* @param string|null $errorBuffer
* @param boolean $isFirstOnThread
*/
public function __construct($suite,
$isSuccess,
$time,
$processorNumber,
$errorBuffer,
$isFirstOnThread)
{
public function __construct(
$suite,
$isSuccess,
$time,
$processorNumber,
$errorBuffer,
$isFirstOnThread
) {
$this->isSuccess = $isSuccess;
$this->processorNumber = $processorNumber;
$this->suite = $suite;
Expand Down
6 changes: 3 additions & 3 deletions src/Queue/CreateTestsQueueFromPhpUnitXML.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public static function execute($xmlFile)

private static function processTestSuite(TestsQueue $testSuites, \PHPUnit\Framework\TestSuiteIterator $testSuiteIterator)
{
foreach ($testSuiteIterator as $testSuite) {
foreach ($testSuiteIterator as $testSuite) {
self::addTestFile($testSuites, $testSuite);

if ($testSuite instanceof \PHPUnit\Framework\TestSuite) {
self::processTestSuite($testSuites, $testSuite->getIterator());
self::processTestSuite($testSuites, $testSuite->getIterator());
}
}
}
Expand All @@ -46,4 +46,4 @@ private static function addTestFile(TestsQueue $testSuites, $testSuite)
$testSuites->add($class->getFileName());
}
}
}
}
2 changes: 0 additions & 2 deletions tests/Environment/FastestEnvironmentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

namespace Liuggio\Fastest\Environment;


use Liuggio\Fastest\Process\EnvCommandCreator;

/**
*
*/
class FastestEnvironmentTest extends \PHPUnit\Framework\TestCase
{

public function setup()
{
$envName = EnvCommandCreator::ENV_TEST_CHANNEL_READABLE;
Expand Down
2 changes: 0 additions & 2 deletions tests/Process/ProcessFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Liuggio\Fastest\Process;


class ProcessFactoryTest extends \PHPUnit\Framework\TestCase
{

Expand Down Expand Up @@ -75,4 +74,3 @@ public function shouldReplaceThePlaceholder()
);
}
}

7 changes: 3 additions & 4 deletions tests/Process/ProcessesManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Liuggio\Fastest\Process;


use Liuggio\Fastest\Queue\TestSuite;
use Symfony\Component\Process\Process;

Expand Down Expand Up @@ -57,7 +56,7 @@ public function shouldCreateProcessesWithoutBeforeProcessExecutingFactoryWithThe
$factory->expects($this->exactly(1))
->method('createAProcess')
->with($this->anything(), $this->equalTo(1), $this->equalTo(1), $this->equalTo(true))
->willReturn(new Process('echo ',rand()));
->willReturn(new Process('echo ', rand()));


$manager = new ProcessesManager($factory, 1);
Expand All @@ -84,7 +83,7 @@ public function shouldCreate6ProcessesGivingThemTheCorrectEnvParameters()
->getMock();
$processes->expects($this->any())
->method('getIndexesOfCompletedChannel')
->willReturn(range(1,3));
->willReturn(range(1, 3));
$processes->expects($this->any())
->method('add')
->willReturn(true);
Expand All @@ -109,7 +108,7 @@ public function shouldCreate6ProcessesGivingThemTheCorrectEnvParameters()
$factory->expects($this->at($at))
->method('createAProcess')
->with($this->anything(), $this->equalTo($expectation[0]), $this->equalTo($expectation[1]), $this->equalTo($expectation[2]))
->willReturn(new Process('echo ',rand()));
->willReturn(new Process('echo ', rand()));
}

$manager = new ProcessesManager($factory, 1);
Expand Down
2 changes: 1 addition & 1 deletion tests/Queue/CreateTestsQueueFromSTDINTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private function executeCommandWithDelayedStdin($command, $stdinLines, $delayMic
// 1 => readable handle connected to child stdout
// 2 => readable handle connected to child stderr

foreach($stdinLines as $stdinLine) {
foreach ($stdinLines as $stdinLine) {
usleep($delayMicroseconds);
fwrite($pipes[0], $stdinLine);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Queue/Infrastructure/InMemoryQueueFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ public function shouldCreateAQueue()

$this->assertInstanceOf('\Liuggio\Fastest\Queue\Infrastructure\InMemoryQueue', $queue);
}
}
}
2 changes: 1 addition & 1 deletion tests/Queue/Infrastructure/InMemoryQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public function shouldPopAndPushASuite()
$this->assertEquals('a', $queue->pop());
$this->assertTrue($queue->isEmpty());
}
}
}
4 changes: 2 additions & 2 deletions tests/Queue/ReadFromInputAndPushIntoTheQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Liuggio\Fastest\Queue;


class ReadFromInputAndPushIntoTheQueueTest extends \PHPUnit\Framework\TestCase {
class ReadFromInputAndPushIntoTheQueueTest extends \PHPUnit\Framework\TestCase
{

/**
* @test
Expand Down

0 comments on commit 63babaf

Please sign in to comment.