Skip to content

Commit

Permalink
First pass at PHPUnit v9 support
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbachhuber committed Nov 6, 2022
1 parent 2641de1 commit 2b89116
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
vendor
.*.swp
composer.lock
.phpunit.result.cache
8 changes: 0 additions & 8 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php

require dirname( dirname( __FILE__ ) ) . '/lib/cli/cli.php';

/**
* Compatibility with PHPUnit 6+
*/
if ( class_exists( 'PHPUnit\Runner\Version' ) ) {
require_once dirname( __FILE__ ) . '/phpunit6-compat.php';
}

function cli_autoload( $className ) {
$className = ltrim($className, '\\');
Expand Down
19 changes: 0 additions & 19 deletions tests/phpunit6-compat.php

This file was deleted.

7 changes: 4 additions & 3 deletions tests/test-arguments.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?php

use cli\Arguments;
use PHPUnit\Framework\TestCase;

/**
* Class TestArguments
* @todo add more tests to increase coverage
*
* @backupGlobals enabled
*/
class TestArguments extends PHPUnit_Framework_TestCase
class TestArguments extends TestCase
{
/**
* Array of expected settings
Expand Down Expand Up @@ -58,7 +59,7 @@ public static function pushToArgv($args)
/**
* Set up valid flags and options
*/
public function setUp()
public function setUp(): void
{
self::clearArgv();
self::pushToArgv('my_script.php');
Expand Down Expand Up @@ -95,7 +96,7 @@ public function setUp()
/**
* Tear down fixtures
*/
public function tearDown()
public function tearDown(): void
{
$this->flags = null;
$this->options = null;
Expand Down
5 changes: 3 additions & 2 deletions tests/test-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

use cli\Colors;

class testsCli extends PHPUnit_Framework_TestCase {
use PHPUnit\Framework\TestCase;
class testsCli extends TestCase {

function setUp() {
function setUp(): void {
// Reset enable state
\cli\Colors::enable( null );

Expand Down
3 changes: 2 additions & 1 deletion tests/test-colors.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

use cli\Colors;
use PHPUnit\Framework\TestCase;

class testsColors extends PHPUnit_Framework_TestCase {
class testsColors extends TestCase {

/**
* @dataProvider dataColors
Expand Down
3 changes: 2 additions & 1 deletion tests/test-shell.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

use cli\Shell;
use PHPUnit\Framework\TestCase;

/**
* Class TestShell
*/
class TestShell extends PHPUnit_Framework_TestCase {
class TestShell extends TestCase {

/**
* Test getting TERM columns.
Expand Down
7 changes: 4 additions & 3 deletions tests/test-table-ascii.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
use cli\Table;
use cli\table\Ascii;
use cli\Colors;
use PHPUnit\Framework\TestCase;

/**
* Class Test_Table_Ascii
*
* Acceptance tests for ASCII table drawing.
* It will redirect STDOUT to temporary file and check that output matches with expected
*/
class Test_Table_Ascii extends PHPUnit_Framework_TestCase {
class Test_Table_Ascii extends TestCase {
/**
* @var string Path to temporary file, where STDOUT output will be redirected during tests
*/
Expand All @@ -24,7 +25,7 @@ class Test_Table_Ascii extends PHPUnit_Framework_TestCase {
/**
* Creates instance and redirects STDOUT to temporary file
*/
public function setUp() {
public function setUp(): void {
$this->_mockFile = tempnam(sys_get_temp_dir(), 'temp');
$resource = fopen($this->_mockFile, 'wb');
Streams::setStream('out', $resource);
Expand All @@ -36,7 +37,7 @@ public function setUp() {
/**
* Cleans temporary file
*/
public function tearDown() {
public function tearDown(): void {
if (file_exists($this->_mockFile)) {
unlink($this->_mockFile);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/test-table.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

use cli\Colors, cli\Table, cli\Table\Ascii;
use PHPUnit\Framework\TestCase;

/**
* Tests for cli\Table
*/
class Test_Table extends PHPUnit_Framework_TestCase {
class Test_Table extends TestCase {

public function test_column_value_too_long_ascii() {

Expand Down

0 comments on commit 2b89116

Please sign in to comment.