Skip to content

Commit 2b89116

Browse files
First pass at PHPUnit v9 support
1 parent 2641de1 commit 2b89116

File tree

9 files changed

+18
-38
lines changed

9 files changed

+18
-38
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
vendor
33
.*.swp
44
composer.lock
5+
.phpunit.result.cache

tests/bootstrap.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
<?php
22

3-
require dirname( dirname( __FILE__ ) ) . '/lib/cli/cli.php';
4-
5-
/**
6-
* Compatibility with PHPUnit 6+
7-
*/
8-
if ( class_exists( 'PHPUnit\Runner\Version' ) ) {
9-
require_once dirname( __FILE__ ) . '/phpunit6-compat.php';
10-
}
113

124
function cli_autoload( $className ) {
135
$className = ltrim($className, '\\');

tests/phpunit6-compat.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/test-arguments.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
<?php
22

33
use cli\Arguments;
4+
use PHPUnit\Framework\TestCase;
45

56
/**
67
* Class TestArguments
78
* @todo add more tests to increase coverage
89
*
910
* @backupGlobals enabled
1011
*/
11-
class TestArguments extends PHPUnit_Framework_TestCase
12+
class TestArguments extends TestCase
1213
{
1314
/**
1415
* Array of expected settings
@@ -58,7 +59,7 @@ public static function pushToArgv($args)
5859
/**
5960
* Set up valid flags and options
6061
*/
61-
public function setUp()
62+
public function setUp(): void
6263
{
6364
self::clearArgv();
6465
self::pushToArgv('my_script.php');
@@ -95,7 +96,7 @@ public function setUp()
9596
/**
9697
* Tear down fixtures
9798
*/
98-
public function tearDown()
99+
public function tearDown(): void
99100
{
100101
$this->flags = null;
101102
$this->options = null;

tests/test-cli.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
use cli\Colors;
44

5-
class testsCli extends PHPUnit_Framework_TestCase {
5+
use PHPUnit\Framework\TestCase;
6+
class testsCli extends TestCase {
67

7-
function setUp() {
8+
function setUp(): void {
89
// Reset enable state
910
\cli\Colors::enable( null );
1011

tests/test-colors.php

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

33
use cli\Colors;
4+
use PHPUnit\Framework\TestCase;
45

5-
class testsColors extends PHPUnit_Framework_TestCase {
6+
class testsColors extends TestCase {
67

78
/**
89
* @dataProvider dataColors

tests/test-shell.php

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

33
use cli\Shell;
4+
use PHPUnit\Framework\TestCase;
45

56
/**
67
* Class TestShell
78
*/
8-
class TestShell extends PHPUnit_Framework_TestCase {
9+
class TestShell extends TestCase {
910

1011
/**
1112
* Test getting TERM columns.

tests/test-table-ascii.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
use cli\Table;
55
use cli\table\Ascii;
66
use cli\Colors;
7+
use PHPUnit\Framework\TestCase;
78

89
/**
910
* Class Test_Table_Ascii
1011
*
1112
* Acceptance tests for ASCII table drawing.
1213
* It will redirect STDOUT to temporary file and check that output matches with expected
1314
*/
14-
class Test_Table_Ascii extends PHPUnit_Framework_TestCase {
15+
class Test_Table_Ascii extends TestCase {
1516
/**
1617
* @var string Path to temporary file, where STDOUT output will be redirected during tests
1718
*/
@@ -24,7 +25,7 @@ class Test_Table_Ascii extends PHPUnit_Framework_TestCase {
2425
/**
2526
* Creates instance and redirects STDOUT to temporary file
2627
*/
27-
public function setUp() {
28+
public function setUp(): void {
2829
$this->_mockFile = tempnam(sys_get_temp_dir(), 'temp');
2930
$resource = fopen($this->_mockFile, 'wb');
3031
Streams::setStream('out', $resource);
@@ -36,7 +37,7 @@ public function setUp() {
3637
/**
3738
* Cleans temporary file
3839
*/
39-
public function tearDown() {
40+
public function tearDown(): void {
4041
if (file_exists($this->_mockFile)) {
4142
unlink($this->_mockFile);
4243
}

tests/test-table.php

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

33
use cli\Colors, cli\Table, cli\Table\Ascii;
4+
use PHPUnit\Framework\TestCase;
45

56
/**
67
* Tests for cli\Table
78
*/
8-
class Test_Table extends PHPUnit_Framework_TestCase {
9+
class Test_Table extends TestCase {
910

1011
public function test_column_value_too_long_ascii() {
1112

0 commit comments

Comments
 (0)