Skip to content

Commit 40e1598

Browse files
committed
dep: update phpunit
PHPUnit 5 is not supported anymore and does not work correctly with PHP 7.2. PHPUnit 6/7 don't support PHP 5.x anymore, so tests won't work correctly anymore on older PHP versions. If testable code gets added/changed in the future, raise the minimum required PHP version to 7.0!
1 parent 626269b commit 40e1598

File tree

6 files changed

+27
-17
lines changed

6 files changed

+27
-17
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818

1919
"require-dev": {
20-
"phpunit/phpunit": "4.*",
20+
"phpunit/phpunit": "^6",
2121
"php-coveralls/php-coveralls": "^2.0"
2222
},
2323

test/01-IncompleteClassTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
namespace mle86\Value\Tests;
33

44
use mle86\Value\AbstractValue;
5+
use mle86\Value\NotImplementedException;
6+
use PHPUnit\Framework\TestCase;
57

68

79
/**
@@ -11,13 +13,11 @@ class BadTestWrapper extends AbstractValue { }
1113

1214

1315
class IncompleteClassTest
14-
extends \PHPUnit_Framework_TestCase
16+
extends TestCase
1517
{
1618

17-
/**
18-
* @expectedException \mle86\Value\NotImplementedException
19-
*/
2019
public function testConstructor () {
20+
$this->expectException(NotImplementedException::class);
2121
new BadTestWrapper ("1");
2222
}
2323

test/10-ValueTest.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
use mle86\Value\AbstractValue;
55
use mle86\Value\Value;
6+
use PHPUnit\Framework\Error\Error;
7+
use PHPUnit\Framework\TestCase;
8+
69
require_once 'helpers/TestWrapper4.php';
710
require_once 'helpers/TestWrapper9.php';
811
require_once 'helpers/ExtTestWrapper4.php';
@@ -14,7 +17,7 @@
1417
* and their default methods inherited from AbstractValue.
1518
*/
1619
class ValueTest
17-
extends \PHPUnit_Framework_TestCase
20+
extends TestCase
1821
{
1922

2023
/** @var TestWrapper4 */
@@ -84,9 +87,9 @@ public function testConstructor9 ($initializer) {
8487
*
8588
* @depends testConstructor
8689
* @dataProvider invalidInputs
87-
* @expectedException \InvalidArgumentException
8890
*/
8991
public function testInvalidInitializer ($initializer) {
92+
$this->expectException(\InvalidArgumentException::class);
9093
new TestWrapper4 ($initializer);
9194
}
9295

@@ -97,9 +100,9 @@ public function testInvalidInitializer ($initializer) {
97100
* @depends testConstructor
98101
* @depends testConstructor9
99102
* @dataProvider validInputs9
100-
* @expectedException \InvalidArgumentException
101103
*/
102104
public function testCrossInvalidInitializer ($initializer) {
105+
$this->expectException(\InvalidArgumentException::class);
103106
new TestWrapper4 ($initializer);
104107
}
105108

@@ -150,9 +153,9 @@ public function testEquals () {
150153

151154
/**
152155
* @depends testEquals
153-
* @expectedException \PHPUnit_Framework_Error
154156
*/
155157
public function testBuiltinEqualsZero () {
158+
$this->expectException(Error::class);
156159
$this->assertFalse((self::$tw1 == 0 || 0 == self::$tw1),
157160
"wrapper is considered equal to zero by builtin== !");
158161
}
@@ -217,20 +220,20 @@ public function testWrap () {
217220
/**
218221
* @depends testWrap
219222
* @dataProvider invalidInputs
220-
* @expectedException \InvalidArgumentException
221223
*/
222224
public function testWrapInvalid ($initializer) {
223225
$v = $initializer;
226+
$this->expectException(\InvalidArgumentException::class);
224227
TestWrapper4::Wrap($v);
225228
}
226229

227230
/**
228231
* @depends testWrapInvalid
229232
* @dataProvider validInputs9
230-
* @expectedException \InvalidArgumentException
231233
*/
232234
public function testWrapCrossInvalid ($initializer) {
233235
$v = $initializer;
236+
$this->expectException(\InvalidArgumentException::class);
234237
TestWrapper4::Wrap($v);
235238
}
236239

@@ -254,9 +257,9 @@ public function testRewrap (TestWrapper9 $tw) {
254257
* Wrapping an instance of a different class must fail.
255258
*
256259
* @depends testRewrap
257-
* @expectedException \InvalidArgumentException
258260
*/
259261
public function testRewrapInvalid (TestWrapper9 $tx) {
262+
$this->expectException(\InvalidArgumentException::class);
260263
TestWrapper4::Wrap($tx);
261264
}
262265

@@ -442,11 +445,11 @@ public function testExtendedBuiltinEquals ($additional_property, ExtTestWrapper4
442445
* @depends testExtendedObject
443446
* @depends testExtendedBuiltinEquals
444447
* @depends testBuiltinEqualsZero
445-
* @expectedException \PHPUnit_Framework_Error
446448
*/
447449
public function testExtendedBuiltinEqualsZero ($additional_property, ExtTestWrapper4 $ew) {
448450
$ew->set_additional_property($additional_property);
449451

452+
$this->expectException(Error::class);
450453
$this->assertFalse(($ew == 0 || 0 == $ew),
451454
"Extended wrapper object is considered equal to zero by builtin== !");
452455
}

test/15-SerializableValueTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
use mle86\Value\AbstractSerializableValue;
55
use mle86\Value\Value;
6+
use PHPUnit\Framework\Error\Error;
7+
use PHPUnit\Framework\TestCase;
8+
69
require_once 'helpers/TestSWrapper6.php';
710

811

@@ -11,7 +14,7 @@
1114
* and its default methods inherited from AbstractSerializableValue.
1215
*/
1316
class SerializableValueTest
14-
extends \PHPUnit_Framework_TestCase
17+
extends TestCase
1518
{
1619

1720
const VALID_INPUT = "61234";
@@ -80,9 +83,9 @@ public function testBuiltinEquals (AbstractSerializableValue $tw) {
8083
/**
8184
* @depends testInstance
8285
* @depends testBuiltinEquals
83-
* @expectedException \PHPUnit_Framework_Error
8486
*/
8587
public function testBuiltinEqualsZero (AbstractSerializableValue $tw) {
88+
$this->expectException(Error::class);
8689
$this->assertFalse(($tw == 0),
8790
"serializable wrapper considered zero as ==equal !");
8891
}

test/90-DoubleConstructorCallTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
use mle86\Value\AbstractValue;
55
use mle86\Value\Value;
6+
use PHPUnit\Framework\TestCase;
7+
68
require_once 'helpers/TestWrapper4.php';
79

810

@@ -11,7 +13,7 @@
1113
* cannot be used to change the stored value.
1214
*/
1315
class DoubleConstructorCallTest
14-
extends \PHPUnit_Framework_TestCase
16+
extends TestCase
1517
{
1618

1719
const VALID_VALUE1 = "41111";

test/90-MagicPropertiesTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
use mle86\Value\AbstractValue;
55
use mle86\Value\Value;
6+
use PHPUnit\Framework\TestCase;
7+
68
require_once 'helpers/TestWrapper4.php';
79

810

@@ -15,7 +17,7 @@
1517
* but we cannot really prevent that.
1618
*/
1719
class MagicPropertiesTest
18-
extends \PHPUnit_Framework_TestCase
20+
extends TestCase
1921
{
2022

2123
const VALID_VALUE = "41111";

0 commit comments

Comments
 (0)