Skip to content
This repository
Browse code

MINOR: Fix tests on PHPUnit 3.4

  • Loading branch information...
commit 6db08cbc364a74bf5b7aed63be1f259b358e197d 1 parent 2c42ffd
Andrew O'Neil authored March 14, 2012
16  dev/SapphireTest.php
@@ -680,6 +680,22 @@ public static function assertType($expected, $actual, $message = '') {
680 680
 
681 681
       self::assertThat($actual, $constraint, $message);
682 682
   }
  683
+
  684
+  	/**
  685
+  	 * Provide assertEmpty() in PHPUnit <3.5.
  686
+  	 * We want to support PHPUnit 3.4, as this is the most recent release available
  687
+  	 * to environments running PHP <=5.2.6, such as Debian Lenny.
  688
+  	 */
  689
+	public static function assertEmpty($item, $message = '') {
  690
+		if(class_exists('PHPUnit_Framework_Constraint_IsEmpty')) {
  691
+			parent::assertEmpty($item, $message);
  692
+		} else {
  693
+			if(!empty($item)) {
  694
+				$message = $message ? $message : "Failed asserting that " . var_export($item, true) . " is empty.";
  695
+				throw new PHPUnit_Framework_AssertionFailedError($message);
  696
+			}
  697
+		}
  698
+	}
683 699
 	
684 700
 	/**
685 701
 	 * Helper function for the DOS matchers
6  tests/dev/DeprecationTest.php
@@ -29,7 +29,7 @@ function testLesserVersionTriggersNoNotice() {
29 29
 	}
30 30
 
31 31
 	/**
32  
-     * @expectedException PHPUnit_Framework_Error_Notice
  32
+     * @expectedException PHPUnit_Framework_Error
33 33
 	 */
34 34
 	function testEqualVersionTriggersNotice() {
35 35
 		Deprecation::notification_version('2.0.0');
@@ -43,7 +43,7 @@ function testBetaVersionDoesntTriggerNoticeWhenDeprecationDoesntSpecifyReleasenu
43 43
 	}
44 44
 
45 45
 	/**
46  
-    * @expectedException PHPUnit_Framework_Error_Notice
  46
+    * @expectedException PHPUnit_Framework_Error
47 47
 	 */
48 48
 	function testGreaterVersionTriggersNotice() {
49 49
 		Deprecation::notification_version('3.0.0');
@@ -57,7 +57,7 @@ function testNonMatchingModuleNotifcationVersionDoesntAffectNotice() {
57 57
 	}
58 58
 
59 59
 	/**
60  
-    * @expectedException PHPUnit_Framework_Error_Notice
  60
+    * @expectedException PHPUnit_Framework_Error
61 61
 	 */
62 62
 	function testMatchingModuleNotifcationVersionAffectsNotice() {
63 63
 		Deprecation::notification_version('1.0.0');

0 notes on commit 6db08cb

Please sign in to comment.
Something went wrong with that request. Please try again.