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

MINOR: Fix tests on PHPUnit 3.4
This commit is contained in:
Hamish Friedlander 2012-03-13 20:09:04 -07:00
commit 37ae36cd58
2 changed files with 19 additions and 3 deletions

View File

@ -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

View File

@ -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');