Skip to content

Commit 7a5867b

Browse files
authored
Merge pull request #21 from hiddewie/master
Updated PHPUnit classes to be compatible with namespaces of PHPUnit 6
2 parents f35935d + d345240 commit 7a5867b

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require": {
1313
},
1414
"require-dev": {
15-
"phpunit/phpunit": "^4.2 || ^5.0"
15+
"phpunit/phpunit": "^6.0"
1616
},
1717
"bin": ["bin/phpunit-randomizer"],
1818
"autoload": {

example_tests/ExampleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class ExampleTest extends \PHPUnit_Framework_TestCase
3+
class ExampleTest extends \PHPUnit\Framework\TestCase
44
{
55
public static $setUpBeforeClass = -1;
66
public $setUp;
@@ -51,4 +51,4 @@ public function test5()
5151
{
5252
echo __METHOD__ . "\n";
5353
}
54-
}
54+
}

example_tests/OtherExampleTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
class OtherExampleTest extends \PHPUnit_Framework_TestCase
3+
class OtherExampleTest extends \PHPUnit\Framework\TestCase
44
{
55
public static $setUpBeforeClass = -1;
66
public $setUp;
@@ -51,4 +51,4 @@ public function test5()
5151
{
5252
echo __METHOD__ . "\n";
5353
}
54-
}
54+
}

src/PHPUnitRandomizer/Command.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
namespace PHPUnitRandomizer;
33

4-
class Command extends \PHPUnit_TextUI_Command
4+
class Command extends \PHPUnit\TextUI\Command
55
{
66
public function __construct()
77
{
@@ -15,7 +15,7 @@ public static function main($exit = TRUE)
1515

1616
/**
1717
* Only called when 'order' argument is used.
18-
*
18+
*
1919
* @param string $order_parameter The order argument passed in command line.
2020
*/
2121
protected function orderHandler($order_parameter)
@@ -27,7 +27,7 @@ protected function orderHandler($order_parameter)
2727

2828
/**
2929
* Parses arguments to know if random order is desired, and if seed was chosen.
30-
*
30+
*
3131
* @param string $order String from command line parameter.
3232
* @return array
3333
*/
@@ -69,8 +69,8 @@ public function showHelp()
6969

7070
private function showError($message)
7171
{
72-
print \PHPUnit_Runner_Version::getVersionString() . "\n\n";
72+
print \PHPUnit\Runner\Version::getVersionString() . "\n\n";
7373
print $message . "\n";
74-
exit(\PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
74+
exit(\PHPUnit\TextUI\TestRunner::FAILURE_EXIT);
7575
}
76-
}
76+
}

src/PHPUnitRandomizer/Randomizer.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ class Randomizer
77
/**
88
* Order the TestSuite tests in a random order.
99
*
10-
* @param \PHPUnit_Framework_Test $suite The suite to randomize.
10+
* @param \PHPUnit\Framework\Test $suite The suite to randomize.
1111
* @param integer $seed Seed used for PHP to randomize the suite.
12-
* @return \PHPUnit_Framework_Test
12+
* @return \PHPUnit\Framework\Test
1313
*/
14-
public function randomizeTestSuite(\PHPUnit_Framework_Test $suite, $seed)
14+
public function randomizeTestSuite(\PHPUnit\Framework\Test $suite, $seed)
1515
{
1616
if ($this->testSuiteContainsOtherSuites($suite))
1717
{
@@ -30,7 +30,7 @@ public function randomizeTestSuite(\PHPUnit_Framework_Test $suite, $seed)
3030
*
3131
* @param [type] $suite Main Test Suite to randomize.
3232
* @param [type] $seed Seed to use.
33-
* @return \PHPUnit_Framework_Test
33+
* @return \PHPUnit\Framework\Test
3434
*/
3535
private function randomizeSuiteThatContainsOtherSuites($suite, $seed)
3636
{
@@ -45,23 +45,23 @@ private function randomizeSuiteThatContainsOtherSuites($suite, $seed)
4545
/**
4646
* Test Suites can contain other Test Suites or just Test Cases.
4747
*
48-
* @param \PHPUnit_Framework_Test $suite [description]
48+
* @param \PHPUnit\Framework\Test $suite [description]
4949
* @return Boolean
5050
*/
5151
private function testSuiteContainsOtherSuites($suite)
5252
{
5353
$tests = $suite->tests();
54-
return isset($tests[0]) && $tests[0] instanceof \PHPUnit_Framework_TestSuite;
54+
return isset($tests[0]) && $tests[0] instanceof \PHPUnit\Framework\TestSuite;
5555
}
5656

5757
/**
5858
* Randomize the test cases inside a TestSuite, with the given seed.
5959
*
60-
* @param \PHPUnit_Framework_Test $suite Test suite to randomize.
60+
* @param \PHPUnit\Framework\Test $suite Test suite to randomize.
6161
* @param integer $seed Seed to be used for the random funtion.
6262
* @param integer $order Arbitrary value to "salt" the seed.
6363
* @param bool $fix_depends [=false]
64-
* @return \PHPUnit_Framework_Test
64+
* @return \PHPUnit\Framework\Test
6565
*/
6666
private function randomizeSuite($suite, $seed, $order = 0, $fix_depends = true)
6767
{

src/PHPUnitRandomizer/ResultPrinter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace PHPUnitRandomizer;
44

5-
class ResultPrinter extends \PHPUnit_TextUI_ResultPrinter
5+
class ResultPrinter extends \PHPUnit\TextUI\ResultPrinter
66
{
77
/**
88
* Seed used to randomize the order of the tests.
@@ -18,7 +18,7 @@ class ResultPrinter extends \PHPUnit_TextUI_ResultPrinter
1818
* @param boolean $verbose
1919
* @param boolean $colors
2020
* @param boolean $debug
21-
* @throws PHPUnit_Framework_Exception
21+
* @throws PHPUnit\Framework\Exception
2222
* @since Method available since Release 3.0.0
2323
*/
2424
public function __construct($out = null, $verbose = false, $colors = false, $debug = false, $seed = null)
@@ -29,15 +29,15 @@ public function __construct($out = null, $verbose = false, $colors = false, $deb
2929

3030
/**
3131
* Just add to the output the seed used to randomize the test suite.
32-
*
33-
* @param PHPUnit_Framework_TestResult $result
32+
*
33+
* @param PHPUnit\Framework\TestResult $result
3434
*/
35-
protected function printFooter(\PHPUnit_Framework_TestResult $result)
35+
protected function printFooter(\PHPUnit\Framework\TestResult $result)
3636
{
3737
parent::printFooter($result);
3838

3939
$this->writeNewLine();
4040
$this->write("Randomized with seed: {$this->seed}");
4141
$this->writeNewLine();
4242
}
43-
}
43+
}

src/PHPUnitRandomizer/TestRunner.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<?php
22
namespace PHPUnitRandomizer;
33

4-
class TestRunner extends \PHPUnit_TextUI_TestRunner
4+
class TestRunner extends \PHPUnit\TextUI\TestRunner
55
{
66
/**
77
* Uses a random test suite to randomize the given test suite, and in case that no printer
88
* has been selected, uses printer that shows the random seed used to randomize.
9-
*
10-
* @param PHPUnit_Framework_Test $suite TestSuite to execute
9+
*
10+
* @param PHPUnit\Framework\Test $suite TestSuite to execute
1111
* @param array $arguments Arguments to use
1212
*/
13-
public function doRun(\PHPUnit_Framework_Test $suite, array $arguments = array(), $exit = true)
13+
public function doRun(\PHPUnit\Framework\Test $suite, array $arguments = array(), $exit = true)
1414
{
1515
$localArguments = $arguments;
1616

@@ -40,7 +40,7 @@ private function addPrinter($arguments)
4040
);
4141

4242
if (isset($arguments['printer']) &&
43-
$arguments['printer'] instanceof \PHPUnit_Util_Printer) {
43+
$arguments['printer'] instanceof \PHPUnit\Util\Printer) {
4444
$this->printer = $arguments['printer'];
4545
}
4646
}

0 commit comments

Comments
 (0)