Skip to content

Commit 69ba4dc

Browse files
committed
Fix compatibility for PHPUnit 5 and 6
1 parent 55e1060 commit 69ba4dc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

tests/EnumTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,13 +250,27 @@ public function testUnserialize()
250250
}
251251

252252
/**
253-
* @expectedException \PHPUnit_Framework_Error_Notice
253+
* __wakeup()
254254
*/
255255
public function testUnserializeError()
256256
{
257+
$this->expectError('Notice');
257258
$ser = 'O:30:"MyCLabs\Tests\Enum\EnumFixture":2:{'
258259
. 's:23:"#MyCLabs\Enum\Enum#name";s:3:"FOO";'
259260
. 's:24:"#MyCLabs\Enum\Enum#value";s:3:"foo";}';
260261
$foo = unserialize(strtr($ser, "#", "\0"));
261262
}
263+
264+
/**
265+
* Set expectedException for errors
266+
* @param string $name Exception
267+
*/
268+
private function expectError($name)
269+
{
270+
$ex = "PHPUnit_Framework_Error_$name";
271+
if (class_exists($ex))
272+
$this->expectException($ex);
273+
else
274+
$this->expectException(strtr($ex, '_', '\\'));
275+
}
262276
}

0 commit comments

Comments
 (0)