Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit a502c24

Browse files
authored
Extend PHPUnit support (#4)
* Extend PHPUnit support * empty * try to support 7.2 even on 4.0 * Revert "try to support 7.2 even on 4.0" This reverts commit 46e733b. * debug * Revert "debug" This reverts commit 27d3369. * respect php vs phpunit incompatibilities * series method is not available on 4.0
1 parent 7c96a2d commit a502c24

File tree

7 files changed

+63
-12
lines changed

7 files changed

+63
-12
lines changed

.travis.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,26 @@ before_install:
3030
install: skip
3131

3232
script:
33-
- ./run-tests.sh 4.8.35 || travis_terminate 1
33+
- ./run-tests.sh ~4.0.0 || travis_terminate 1
34+
- ./run-tests.sh ~4.1.0 || travis_terminate 1
35+
- ./run-tests.sh ~4.2.0 || travis_terminate 1
36+
- ./run-tests.sh ~4.3.0 || travis_terminate 1
37+
- ./run-tests.sh ~4.4.0 || travis_terminate 1
38+
- ./run-tests.sh ~4.5.0 || travis_terminate 1
39+
- ./run-tests.sh ~4.6.0 || travis_terminate 1
40+
- ./run-tests.sh ~4.7.0 || travis_terminate 1
41+
- ./run-tests.sh ~4.8.0 || travis_terminate 1
42+
- ./run-tests.sh ~5.0.0 || travis_terminate 1
43+
- ./run-tests.sh ~5.1.0 || travis_terminate 1
44+
- ./run-tests.sh ~5.2.0 || travis_terminate 1
45+
- ./run-tests.sh ~5.3.0 || travis_terminate 1
3446
- ./run-tests.sh ~5.4.0 || travis_terminate 1
3547
- ./run-tests.sh ~5.5.0 || travis_terminate 1
3648
- ./run-tests.sh ~5.6.0 || travis_terminate 1
3749
- ./run-tests.sh ~5.7.0 || travis_terminate 1
50+
- ./run-tests.sh ~6.0.0 || travis_terminate 1
51+
- ./run-tests.sh ~6.1.0 || travis_terminate 1
52+
- ./run-tests.sh ~6.2.0 || travis_terminate 1
3853

3954
jobs:
4055
include:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"php": "^5.3.6 || ^7.0"
1414
},
1515
"require-dev": {
16-
"phpunit/phpunit": "^4.8.35 || ^5.4.3"
16+
"phpunit/phpunit": "^4 || ^5 || ^6"
1717
},
1818
"conflict": {
1919
"hhvm": "*"

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
66
backupGlobals="false"
77
backupStaticAttributes="false"
8-
bootstrap="./vendor/autoload.php"
8+
bootstrap="./tests/bootstrap.php"
99
colors="true"
1010
columns="max"
1111
convertErrorsToExceptions="true"

run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fi
1212

1313
echo -e "\e[46m§ Trying to execute tests under PHPUnit ${PHPUNIT}.\e[0m"
1414

15-
rm -rf composer.lock vendor/
15+
rm -f composer.lock
1616

1717
echo -e "\n\e[46m§ Installing deps...\e[0m"
1818
composer require -q --dev --no-update phpunit/phpunit:${PHPUNIT}

tests/ReporterTest.php

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

1212
namespace PHPUnitGoodPractices\Tests;
1313

14+
use PHPUnit\Framework\Error\Warning;
1415
use PHPUnit\Framework\TestCase;
1516
use PHPUnitGoodPractices\Reporter;
1617

@@ -31,10 +32,10 @@ public function testReportWithDefaults()
3132
$expectedMessage = "PHPUnit good practice has been abused.\nFoo.";
3233

3334
if (is_callable(array($this, 'expectException'))) {
34-
$this->expectException(\PHPUnit_Framework_Error_Warning::class);
35+
$this->expectException(Warning::class);
3536
$this->expectExceptionMessage($expectedMessage);
3637
} else {
37-
$this->setExpectedException(\PHPUnit_Framework_Error_Warning::class, $expectedMessage);
38+
$this->setExpectedException(Warning::class, $expectedMessage);
3839
}
3940

4041
Reporter::report('Foo.');
@@ -47,10 +48,10 @@ public function testReportWithoutHeaders()
4748
$expectedMessage = 'Foo.';
4849

4950
if (is_callable(array($this, 'expectException'))) {
50-
$this->expectException(\PHPUnit_Framework_Error_Warning::class);
51+
$this->expectException(Warning::class);
5152
$this->expectExceptionMessage($expectedMessage);
5253
} else {
53-
$this->setExpectedException(\PHPUnit_Framework_Error_Warning::class, $expectedMessage);
54+
$this->setExpectedException(Warning::class, $expectedMessage);
5455
}
5556

5657
Reporter::report('Foo.');
@@ -75,9 +76,9 @@ public function testReportAfterClearingCustomReporter()
7576

7677
Reporter::clearCustomReporter();
7778
if (is_callable(array($this, 'expectException'))) {
78-
$this->expectException(\PHPUnit_Framework_Error_Warning::class);
79+
$this->expectException(Warning::class);
7980
} else {
80-
$this->setExpectedException(\PHPUnit_Framework_Error_Warning::class);
81+
$this->setExpectedException(Warning::class);
8182
}
8283
Reporter::report('Foo.');
8384
}

tests/StrictAssertionTraitTest.php

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

1212
namespace PHPUnitGoodPractices\Tests;
1313

14+
use PHPUnit\Framework\Error\Warning;
1415
use PHPUnit\Framework\TestCase;
1516
use PHPUnitGoodPractices\StrictAssertionTrait;
1617

@@ -41,9 +42,9 @@ public function testAssertEqualsFails()
4142
$data = 5;
4243

4344
if (is_callable(array($this, 'expectException'))) {
44-
$this->expectException(\PHPUnit_Framework_Error_Warning::class);
45+
$this->expectException(Warning::class);
4546
} else {
46-
$this->setExpectedException(\PHPUnit_Framework_Error_Warning::class);
47+
$this->setExpectedException(Warning::class);
4748
}
4849

4950
$this->assertEquals($data, $data);

tests/bootstrap.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of PHPUnit Good Practices.
5+
*
6+
* (c) Dariusz Rumiński <[email protected]>
7+
*
8+
* This source file is subject to the MIT license that is bundled
9+
* with this source code in the file LICENSE.
10+
*/
11+
12+
if (!class_exists('PHPUnit\Framework\Error\Warning')) {
13+
class_alias('PHPUnit_Framework_Error_Warning', 'PHPUnit\Framework\Error\Warning');
14+
}
15+
16+
if (!class_exists('PHPUnit\Framework\TestCase')) {
17+
class_alias('PHPUnit_Framework_TestCase', 'PHPUnit\Framework\TestCase');
18+
}
19+
20+
if (!class_exists('PHPUnit\Runner\Version')) {
21+
class_alias('PHPUnit_Runner_Version', 'PHPUnit\Runner\Version');
22+
}
23+
24+
if (
25+
PHP_VERSION_ID >= 70200 && version_compare(PHPUnit\Runner\Version::id(), '4.1') < 0
26+
) {
27+
die(sprintf(
28+
"\e[45mPHPUnit %s: Is not compatible with PHP %s.\e[0m",
29+
PHPUnit\Runner\Version::id(),
30+
PHP_VERSION
31+
));
32+
}
33+
34+
require __DIR__.'/../vendor/autoload.php';

0 commit comments

Comments
 (0)