Skip to content

Commit

Permalink
#10: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prymas007 committed Aug 2, 2016
1 parent 4b7a92a commit 3651818
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/PHPUnitRandomizer/Randomizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function randomizeTestSuite(\PHPUnit_Framework_Test $suite, $seed)
}
else
{
$this->randomizeSuite($suite, $seed, 0, true);
$this->randomizeSuite($suite, $seed, 0);
}

return $suite;
Expand All @@ -36,10 +36,10 @@ private function randomizeSuiteThatContainsOtherSuites($suite, $seed)
{
$order = 0;
foreach ($suite->tests() as $test) {
$this->randomizeSuite($test, $seed, $order, true);
$this->randomizeSuite($test, $seed, $order);
$order++;
}
return $this->randomizeSuite($suite, $seed, $order);
return $this->randomizeSuite($suite, $seed, $order, false);
}

/**
Expand All @@ -63,7 +63,7 @@ private function testSuiteContainsOtherSuites($suite)
* @param bool $fix_depends [=false]
* @return \PHPUnit_Framework_Test
*/
private function randomizeSuite($suite, $seed, $order = 0, $fix_depends = false)
private function randomizeSuite($suite, $seed, $order = 0, $fix_depends = true)
{
$reflected = new \ReflectionObject($suite);
$property = $reflected->getProperty('tests');
Expand Down Expand Up @@ -152,7 +152,8 @@ private function fixDependencies(array $tests)
* @param array $tests_methods tests (shuffled) array
* @return array array
*/
private function setOrder($tests_dependencies, $tests_methods) {
private function setOrder($tests_dependencies, $tests_methods)
{
$new_order = [];
foreach ($tests_methods as $method_name => $order) {
if (isset($tests_dependencies[$method_name]) && !in_array($tests_dependencies[$method_name], $new_order)) {
Expand All @@ -176,7 +177,8 @@ private function setOrder($tests_dependencies, $tests_methods) {
* @param array $tests_methods tests (shuffled) array
* @return void
*/
private function isDependant(&$new_order, $tests_dependencies, $tests_methods, $method) {
private function isDependant(&$new_order, $tests_dependencies, $tests_methods, $method)
{
foreach ($tests_dependencies as $dependant => $depends) {
if ($method == $dependant && !in_array($depends, $new_order)) {
array_splice($new_order, array_search($method, $new_order), 0, [$depends]);
Expand Down

0 comments on commit 3651818

Please sign in to comment.