From 6db08cbc364a74bf5b7aed63be1f259b358e197d Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Wed, 14 Mar 2012 14:43:45 +1300 Subject: [PATCH] MINOR: Fix tests on PHPUnit 3.4 --- dev/SapphireTest.php | 16 ++++++++++++++++ tests/dev/DeprecationTest.php | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dev/SapphireTest.php b/dev/SapphireTest.php index 34381a1bb..97c6114b5 100644 --- a/dev/SapphireTest.php +++ b/dev/SapphireTest.php @@ -680,6 +680,22 @@ class SapphireTest extends PHPUnit_Framework_TestCase { self::assertThat($actual, $constraint, $message); } + + /** + * Provide assertEmpty() in PHPUnit <3.5. + * We want to support PHPUnit 3.4, as this is the most recent release available + * to environments running PHP <=5.2.6, such as Debian Lenny. + */ + public static function assertEmpty($item, $message = '') { + if(class_exists('PHPUnit_Framework_Constraint_IsEmpty')) { + parent::assertEmpty($item, $message); + } else { + if(!empty($item)) { + $message = $message ? $message : "Failed asserting that " . var_export($item, true) . " is empty."; + throw new PHPUnit_Framework_AssertionFailedError($message); + } + } + } /** * Helper function for the DOS matchers diff --git a/tests/dev/DeprecationTest.php b/tests/dev/DeprecationTest.php index fb5247929..7591cb21f 100644 --- a/tests/dev/DeprecationTest.php +++ b/tests/dev/DeprecationTest.php @@ -29,7 +29,7 @@ class DeprecationTest extends SapphireTest { } /** - * @expectedException PHPUnit_Framework_Error_Notice + * @expectedException PHPUnit_Framework_Error */ function testEqualVersionTriggersNotice() { Deprecation::notification_version('2.0.0'); @@ -43,7 +43,7 @@ class DeprecationTest extends SapphireTest { } /** - * @expectedException PHPUnit_Framework_Error_Notice + * @expectedException PHPUnit_Framework_Error */ function testGreaterVersionTriggersNotice() { Deprecation::notification_version('3.0.0'); @@ -57,7 +57,7 @@ class DeprecationTest extends SapphireTest { } /** - * @expectedException PHPUnit_Framework_Error_Notice + * @expectedException PHPUnit_Framework_Error */ function testMatchingModuleNotifcationVersionAffectsNotice() { Deprecation::notification_version('1.0.0');