Permalink
Browse files

Merge pull request #242 from silverstripe-big-o/phpunit53

MINOR: Fix tests on PHPUnit 3.4
  • Loading branch information...
2 parents 5ce1dc1 + 6db08cb commit 37ae36cd581f8844a2793f898f6ff58b5c2b46a3 Hamish Friedlander committed Mar 14, 2012
Showing with 19 additions and 3 deletions.
  1. +16 −0 dev/SapphireTest.php
  2. +3 −3 tests/dev/DeprecationTest.php
View
@@ -680,6 +680,22 @@ public static function assertType($expected, $actual, $message = '') {
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
@@ -29,7 +29,7 @@ function testLesserVersionTriggersNoNotice() {
}
/**
- * @expectedException PHPUnit_Framework_Error_Notice
+ * @expectedException PHPUnit_Framework_Error
*/
function testEqualVersionTriggersNotice() {
Deprecation::notification_version('2.0.0');
@@ -43,7 +43,7 @@ function testBetaVersionDoesntTriggerNoticeWhenDeprecationDoesntSpecifyReleasenu
}
/**
- * @expectedException PHPUnit_Framework_Error_Notice
+ * @expectedException PHPUnit_Framework_Error
*/
function testGreaterVersionTriggersNotice() {
Deprecation::notification_version('3.0.0');
@@ -57,7 +57,7 @@ function testNonMatchingModuleNotifcationVersionDoesntAffectNotice() {
}
/**
- * @expectedException PHPUnit_Framework_Error_Notice
+ * @expectedException PHPUnit_Framework_Error
*/
function testMatchingModuleNotifcationVersionAffectsNotice() {
Deprecation::notification_version('1.0.0');

0 comments on commit 37ae36c

Please sign in to comment.