Skip to content

Commit

Permalink
Fix CS-Issues
Browse files Browse the repository at this point in the history
  • Loading branch information
be-heiglandreas committed Apr 23, 2019
1 parent 436419f commit a05edfd
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 74 deletions.
7 changes: 2 additions & 5 deletions src/Command/CompareCommand.php
Expand Up @@ -50,10 +50,10 @@ protected function configure()
{
$this->setName('compare')
->setDescription('Compares two JUnit log files')
->setDefinition(array(
->setDefinition([
new InputArgument('base', InputArgument::REQUIRED, 'Base file for the comparison'),
new InputArgument('current', InputArgument::REQUIRED, 'Current file to compare against the base file')
))
])
->setHelp('');
}

Expand All @@ -71,8 +71,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$parser->parseFile($input->getArgument('base')),
$parser->parseFile($input->getArgument('current'))
);


} catch (\Exception $e) {
$style->error($e->getMessage());
return;
Expand Down Expand Up @@ -110,6 +108,5 @@ protected function execute(InputInterface $input, OutputInterface $output)
);
$writer->write($mergeResult);
}

}
}
10 changes: 5 additions & 5 deletions src/Command/DiffCommand.php
Expand Up @@ -42,10 +42,10 @@ protected function configure()
{
$this->setName('diff')
->setDescription('Shows a diff between two JUnit log files')
->setDefinition(array(
->setDefinition([
new InputOption('input1', '1', InputOption::VALUE_REQUIRED, 'First input file'),
new InputOption('input2', '2', InputOption::VALUE_REQUIRED, 'Second input file')
))
])
->setHelp('');
}

Expand All @@ -62,7 +62,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
try {
$file1 = $input->getOption('input1');
$array1 = $parser->parseFile($file1);
} catch(\Exception $e) {
} catch (\Exception $e) {
$output->writeln('<bg=red;fg=white> ' . $e->getMessage() . ' </>');
return;
}
Expand Down Expand Up @@ -97,7 +97,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
continue;
}
}

$output->writeln('');
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
$output->writeln([
Expand Down Expand Up @@ -134,7 +134,7 @@ protected function merge(array $array1, array $array2)
$merged[$key]['base'] = $value;
}

foreach($array2 as $key => $value) {
foreach ($array2 as $key => $value) {
$merged[$key]['current'] = $value;
}

Expand Down
2 changes: 1 addition & 1 deletion src/JUnitMerger.php
Expand Up @@ -52,7 +52,7 @@ public function merge(array $array1, array $array2)
$this->mergeResult->addBase($key, $value);
}

foreach($array2 as $key => $value) {
foreach ($array2 as $key => $value) {
$this->mergeResult->addCurrent($key, $value);
}

Expand Down
2 changes: 0 additions & 2 deletions src/JUnitParser.php
Expand Up @@ -76,7 +76,6 @@ public function parseFile($filename)

$items = $xpath->query('//testcase');
foreach ($items as $item) {

$class = $item->getAttribute('class');
if (! $class) {
$class = explode('::', $item->parentNode->getAttribute('name'))[0];
Expand Down Expand Up @@ -120,7 +119,6 @@ public function parseFile($filename)
'type' => $ftype,
'info' => $addInfo,
];

}

return $result;
Expand Down
1 change: 0 additions & 1 deletion src/Writer/FileSummary.php
Expand Up @@ -58,6 +58,5 @@ public function write(MergeResult $mergeResult)
$mergeResult->countCurrent(),
basename($this->file2)
));

}
}
1 change: 0 additions & 1 deletion src/Writer/Legend.php
Expand Up @@ -68,6 +68,5 @@ public function write(MergeResult $mergeResult)
),
''
]);

}
}
1 change: 0 additions & 1 deletion src/Writer/Standard.php
Expand Up @@ -107,7 +107,6 @@ private function writeChangedTest($base, $current, $key)
$this->addVerboseInformationToChangedTest($current);
$this->addVeryVerboseInformationToChangedTest($current);
}

}

private function addVerboseInformationToChangedTest($current)
Expand Down
46 changes: 18 additions & 28 deletions tests/Command/CompareCommandTest.php
Expand Up @@ -46,12 +46,10 @@ public function testExecute()

$command = $application->find('compare');
$commandTester = new CommandTester($command);
$commandTester->execute(
array(
'base' => __DIR__ . '/../_assets/log1.xml',
'current' => __DIR__ . '/../_assets/log.xml',
)
);
$commandTester->execute([
'base' => __DIR__ . '/../_assets/log1.xml',
'current' => __DIR__ . '/../_assets/log.xml',
]);

$this->assertEquals('
Console Tool
Expand All @@ -65,7 +63,6 @@ public function testExecute()
Analyzed 615 tests in total, 613 tests in file log1.xml and 613 tests in file log.xml
Added: 2 , Removed: 2 , Changed: 1
', $commandTester->getDisplay());

}

public function testExecuteQuietly()
Expand All @@ -76,15 +73,12 @@ public function testExecuteQuietly()

$command = $application->find('compare');
$commandTester = new CommandTester($command);
$commandTester->execute(
array(
'base' => __DIR__ . '/../_assets/log1.xml',
'current' => __DIR__ . '/../_assets/log.xml',
),
array(
'verbosity' => OutputInterface::VERBOSITY_QUIET
)
);
$commandTester->execute([
'base' => __DIR__ . '/../_assets/log1.xml',
'current' => __DIR__ . '/../_assets/log.xml',
], [
'verbosity' => OutputInterface::VERBOSITY_QUIET
]);

$this->assertEquals('
Added: 2 , Removed: 2 , Changed: 1
Expand All @@ -98,12 +92,10 @@ public function testThatNonExistingFilesRaiseError()

$command = $application->find('compare');
$commandTester = new CommandTester($command);
$commandTester->execute(
array(
'base' => __DIR__ . '/../_assets/log1.xml',
'current' => __DIR__ . '/../_assets/log.xm',
)
);
$commandTester->execute([
'base' => __DIR__ . '/../_assets/log1.xml',
'current' => __DIR__ . '/../_assets/log.xm',
]);

$this->assertContains('[ERROR] File log.xm is not readable', $commandTester->getDisplay());
}
Expand All @@ -115,12 +107,10 @@ public function testThatInvalidFileRaisesError()

$command = $application->find('compare');
$commandTester = new CommandTester($command);
$commandTester->execute(
array(
'base' => __DIR__ . '/../_assets/log1.xml',
'current' => __DIR__ . '/../_assets/log.empty',
)
);
$commandTester->execute([
'base' => __DIR__ . '/../_assets/log1.xml',
'current' => __DIR__ . '/../_assets/log.empty',
]);

$this->assertContains('[ERROR] File log.empty seems not to be a JUnit-File', $commandTester->getDisplay());
}
Expand Down
33 changes: 13 additions & 20 deletions tests/Command/DiffCommandTest.php
Expand Up @@ -45,12 +45,10 @@ public function testExecute()

$command = $application->find('diff');
$commandTester = new CommandTester($command);
$commandTester->execute(
array(
'--input1' => __DIR__ . '/../_assets/log1.xml',
'--input2' => __DIR__ . '/../_assets/log.xml',
)
);
$commandTester->execute([
'--input1' => __DIR__ . '/../_assets/log1.xml',
'--input2' => __DIR__ . '/../_assets/log.xml',
]);

$this->assertEquals('Console Tool
Expand All @@ -62,7 +60,6 @@ public function testExecute()
Analyzed 615 tests in total, 613 tests in file log1.xml and 613 tests in file log.xml
', $commandTester->getDisplay());

}

public function testThatNonExistingFilesRaiseError()
Expand All @@ -72,12 +69,10 @@ public function testThatNonExistingFilesRaiseError()

$command = $application->find('diff');
$commandTester = new CommandTester($command);
$commandTester->execute(
array(
'--input1' => __DIR__ . '/../_assets/log1.xml',
'--input2' => __DIR__ . '/../_assets/log.xm',
)
);
$commandTester->execute([
'--input1' => __DIR__ . '/../_assets/log1.xml',
'--input2' => __DIR__ . '/../_assets/log.xm',
]);

$this->assertEquals('Console Tool
Expand All @@ -92,12 +87,10 @@ public function testThatInvalidFileRaisesError()

$command = $application->find('diff');
$commandTester = new CommandTester($command);
$commandTester->execute(
array(
'--input1' => __DIR__ . '/../_assets/log1.xml',
'--input2' => __DIR__ . '/../_assets/log.empty',
)
);
$commandTester->execute([
'--input1' => __DIR__ . '/../_assets/log1.xml',
'--input2' => __DIR__ . '/../_assets/log.empty',
]);

$this->assertEquals('Console Tool
Expand All @@ -120,4 +113,4 @@ public function testThatNoFileRaisesError()
File is not readable
', $commandTester->getDisplay());
}
}
}
4 changes: 1 addition & 3 deletions tests/JUnitParserTest.php
Expand Up @@ -157,9 +157,7 @@ public function testThatParsingAJunitFileResultsInAnArray()
'info' => ''
],
];

$this->assertEquals($expectedResult, $result);

$this->assertEquals($expectedResult, $result);
}

}
2 changes: 0 additions & 2 deletions tests/MergeResultTest.php
Expand Up @@ -53,7 +53,6 @@ public function testThatAddingABaseWorks()
$this->assertAttributeEquals([], 'content', $mergeResult);
$mergeResult->addBase('a', 'b');
$this->assertAttributeEquals(['a' => ['base' => 'b']], 'content', $mergeResult);

}

public function testThatAddingACurrentWorks()
Expand All @@ -64,7 +63,6 @@ public function testThatAddingACurrentWorks()
$this->assertAttributeEquals([], 'content', $mergeResult);
$mergeResult->addCurrent('a', 'b');
$this->assertAttributeEquals(['a' => ['current' => 'b']], 'content', $mergeResult);

}

public function testThatSortingWorks()
Expand Down
2 changes: 1 addition & 1 deletion tests/Writer/LegendTest.php
Expand Up @@ -52,7 +52,7 @@ public function testThatSummaryWorks()
'<bg=red;fg=yellow>-</>: This test was removed in file b',
'<bg=blue;fg=yellow>o</>: The test-result changed between file a and b',
''
]);
]);
$mergeresult = M::mock('\Org_Heigl\JUnitDiff\MergeResult');

$fileSummary = new Legend($styleInterface, 'a', 'b');
Expand Down
18 changes: 15 additions & 3 deletions tests/Writer/StandardTest.php
Expand Up @@ -62,10 +62,22 @@ public function testThatSummaryWorks()
$mergeresult->shouldReceive('key')->andReturnValues(['a', 'b', 'c', 'd', 'e']);
$mergeresult->shouldReceive('current')->andReturnValues([
['base'=>['result'=>'Success', 'message' => '', 'info' => '']],
['base' => ['result'=>'success', 'message' => '', 'info' => ''], 'current' => ['result' => 'success', 'message' => '', 'info' => '']],
['base' => ['result'=>'success', 'message' => '', 'info' => ''], 'current' => [
'result' => 'success',
'message' => '',
'info' => ''
]],
['current' => ['result' => 'success', 'message' => '', 'info' => '']],
['base' => ['result' => 'success', 'message' => '', 'info' => ''], 'current' => ['result' => 'failure', 'message' => '', 'info' => '']],
['base' => ['result' => 'failure', 'message' => '', 'info' => ''], 'current' => ['result' => 'success', 'message' => '', 'info' => '']],
['base' => ['result' => 'success', 'message' => '', 'info' => ''], 'current' => [
'result' => 'failure',
'message' => '',
'info' => ''
]],
['base' => ['result' => 'failure', 'message' => '', 'info' => ''], 'current' => [
'result' => 'success',
'message' => '',
'info' => ''
]],
]);

$fileSummary = new Standard($styleInterface, 'a', 'b');
Expand Down
4 changes: 3 additions & 1 deletion tests/Writer/SummaryTest.php
Expand Up @@ -45,7 +45,9 @@ public function testThatQuietSummaryWorks()
{
$styleInterface = M::mock('\Symfony\Component\Console\Style\StyleInterface');
$styleInterface->shouldReceive('writeQuiet')
->with('Added:<bg=green;fg=black> 3 </>, Removed:<bg=red;fg=yellow> 5 </>, Changed:<bg=blue;fg=yellow> 7 </>');
->with(
'Added:<bg=green;fg=black> 3 </>, Removed:<bg=red;fg=yellow> 5 </>, Changed:<bg=blue;fg=yellow> 7 </>'
);
$mergeresult = M::mock('\Org_Heigl\JUnitDiff\MergeResult');
$mergeresult->shouldReceive('countNew')->andReturn(3);
$mergeresult->shouldReceive('countRemoved')->andReturn(5);
Expand Down

0 comments on commit a05edfd

Please sign in to comment.