Skip to content

Commit

Permalink
Merge pull request #21 from hiddewie/master
Browse files Browse the repository at this point in the history
Updated PHPUnit classes to be compatible with namespaces of PHPUnit 6
  • Loading branch information
fiunchinho authored Feb 5, 2017
2 parents f35935d + d345240 commit 7a5867b
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"require": {
},
"require-dev": {
"phpunit/phpunit": "^4.2 || ^5.0"
"phpunit/phpunit": "^6.0"
},
"bin": ["bin/phpunit-randomizer"],
"autoload": {
Expand Down
4 changes: 2 additions & 2 deletions example_tests/ExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class ExampleTest extends \PHPUnit_Framework_TestCase
class ExampleTest extends \PHPUnit\Framework\TestCase
{
public static $setUpBeforeClass = -1;
public $setUp;
Expand Down Expand Up @@ -51,4 +51,4 @@ public function test5()
{
echo __METHOD__ . "\n";
}
}
}
4 changes: 2 additions & 2 deletions example_tests/OtherExampleTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

class OtherExampleTest extends \PHPUnit_Framework_TestCase
class OtherExampleTest extends \PHPUnit\Framework\TestCase
{
public static $setUpBeforeClass = -1;
public $setUp;
Expand Down Expand Up @@ -51,4 +51,4 @@ public function test5()
{
echo __METHOD__ . "\n";
}
}
}
12 changes: 6 additions & 6 deletions src/PHPUnitRandomizer/Command.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
namespace PHPUnitRandomizer;

class Command extends \PHPUnit_TextUI_Command
class Command extends \PHPUnit\TextUI\Command
{
public function __construct()
{
Expand All @@ -15,7 +15,7 @@ public static function main($exit = TRUE)

/**
* Only called when 'order' argument is used.
*
*
* @param string $order_parameter The order argument passed in command line.
*/
protected function orderHandler($order_parameter)
Expand All @@ -27,7 +27,7 @@ protected function orderHandler($order_parameter)

/**
* Parses arguments to know if random order is desired, and if seed was chosen.
*
*
* @param string $order String from command line parameter.
* @return array
*/
Expand Down Expand Up @@ -69,8 +69,8 @@ public function showHelp()

private function showError($message)
{
print \PHPUnit_Runner_Version::getVersionString() . "\n\n";
print \PHPUnit\Runner\Version::getVersionString() . "\n\n";
print $message . "\n";
exit(\PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
exit(\PHPUnit\TextUI\TestRunner::FAILURE_EXIT);
}
}
}
16 changes: 8 additions & 8 deletions src/PHPUnitRandomizer/Randomizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ class Randomizer
/**
* Order the TestSuite tests in a random order.
*
* @param \PHPUnit_Framework_Test $suite The suite to randomize.
* @param \PHPUnit\Framework\Test $suite The suite to randomize.
* @param integer $seed Seed used for PHP to randomize the suite.
* @return \PHPUnit_Framework_Test
* @return \PHPUnit\Framework\Test
*/
public function randomizeTestSuite(\PHPUnit_Framework_Test $suite, $seed)
public function randomizeTestSuite(\PHPUnit\Framework\Test $suite, $seed)
{
if ($this->testSuiteContainsOtherSuites($suite))
{
Expand All @@ -30,7 +30,7 @@ public function randomizeTestSuite(\PHPUnit_Framework_Test $suite, $seed)
*
* @param [type] $suite Main Test Suite to randomize.
* @param [type] $seed Seed to use.
* @return \PHPUnit_Framework_Test
* @return \PHPUnit\Framework\Test
*/
private function randomizeSuiteThatContainsOtherSuites($suite, $seed)
{
Expand All @@ -45,23 +45,23 @@ private function randomizeSuiteThatContainsOtherSuites($suite, $seed)
/**
* Test Suites can contain other Test Suites or just Test Cases.
*
* @param \PHPUnit_Framework_Test $suite [description]
* @param \PHPUnit\Framework\Test $suite [description]
* @return Boolean
*/
private function testSuiteContainsOtherSuites($suite)
{
$tests = $suite->tests();
return isset($tests[0]) && $tests[0] instanceof \PHPUnit_Framework_TestSuite;
return isset($tests[0]) && $tests[0] instanceof \PHPUnit\Framework\TestSuite;
}

/**
* Randomize the test cases inside a TestSuite, with the given seed.
*
* @param \PHPUnit_Framework_Test $suite Test suite to randomize.
* @param \PHPUnit\Framework\Test $suite Test suite to randomize.
* @param integer $seed Seed to be used for the random funtion.
* @param integer $order Arbitrary value to "salt" the seed.
* @param bool $fix_depends [=false]
* @return \PHPUnit_Framework_Test
* @return \PHPUnit\Framework\Test
*/
private function randomizeSuite($suite, $seed, $order = 0, $fix_depends = true)
{
Expand Down
12 changes: 6 additions & 6 deletions src/PHPUnitRandomizer/ResultPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace PHPUnitRandomizer;

class ResultPrinter extends \PHPUnit_TextUI_ResultPrinter
class ResultPrinter extends \PHPUnit\TextUI\ResultPrinter
{
/**
* Seed used to randomize the order of the tests.
Expand All @@ -18,7 +18,7 @@ class ResultPrinter extends \PHPUnit_TextUI_ResultPrinter
* @param boolean $verbose
* @param boolean $colors
* @param boolean $debug
* @throws PHPUnit_Framework_Exception
* @throws PHPUnit\Framework\Exception
* @since Method available since Release 3.0.0
*/
public function __construct($out = null, $verbose = false, $colors = false, $debug = false, $seed = null)
Expand All @@ -29,15 +29,15 @@ public function __construct($out = null, $verbose = false, $colors = false, $deb

/**
* Just add to the output the seed used to randomize the test suite.
*
* @param PHPUnit_Framework_TestResult $result
*
* @param PHPUnit\Framework\TestResult $result
*/
protected function printFooter(\PHPUnit_Framework_TestResult $result)
protected function printFooter(\PHPUnit\Framework\TestResult $result)
{
parent::printFooter($result);

$this->writeNewLine();
$this->write("Randomized with seed: {$this->seed}");
$this->writeNewLine();
}
}
}
10 changes: 5 additions & 5 deletions src/PHPUnitRandomizer/TestRunner.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<?php
namespace PHPUnitRandomizer;

class TestRunner extends \PHPUnit_TextUI_TestRunner
class TestRunner extends \PHPUnit\TextUI\TestRunner
{
/**
* Uses a random test suite to randomize the given test suite, and in case that no printer
* has been selected, uses printer that shows the random seed used to randomize.
*
* @param PHPUnit_Framework_Test $suite TestSuite to execute
*
* @param PHPUnit\Framework\Test $suite TestSuite to execute
* @param array $arguments Arguments to use
*/
public function doRun(\PHPUnit_Framework_Test $suite, array $arguments = array(), $exit = true)
public function doRun(\PHPUnit\Framework\Test $suite, array $arguments = array(), $exit = true)
{
$localArguments = $arguments;

Expand Down Expand Up @@ -40,7 +40,7 @@ private function addPrinter($arguments)
);

if (isset($arguments['printer']) &&
$arguments['printer'] instanceof \PHPUnit_Util_Printer) {
$arguments['printer'] instanceof \PHPUnit\Util\Printer) {
$this->printer = $arguments['printer'];
}
}
Expand Down

0 comments on commit 7a5867b

Please sign in to comment.