Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MINOR Added deprecated SapphireTest->assertType() in order to support…

… PHPUnit 3.5 or newer, but stay backwards compatible to PHPUnit 3.4
  • Loading branch information...
commit 201506e2991d81e4b76280bf5faf50ae2efceba5 1 parent 900b0a7
@chillu chillu authored
Showing with 39 additions and 0 deletions.
  1. +39 −0 dev/SapphireTest.php
View
39 dev/SapphireTest.php
@@ -575,6 +575,45 @@ function assertDOSAllMatch($match, $dataObjectSet) {
}
/**
+ * Backported from PHPUnit 3.4 in order to maintain backwards
+ * compatibility: assertType() is deprecated in PHPUnit 3.5 (with PHP 5.2.7+),
+ * but as SilverStripe 2.3 and 2.4 support PHP 5.1 we can't require it.
+ */
+ public static function assertType($expected, $actual, $message = '') {
+ // PHPUnit_Util_DeprecatedFeature_Logger::log(
+ // 'assertType() will be removed in PHPUnit 3.6 and should no longer ' .
+ // 'be used. assertInternalType() should be used for asserting ' .
+ // 'internal types such as "integer" or "string" whereas ' .
+ // 'assertInstanceOf() should be used for asserting that an object is ' .
+ // 'an instance of a specified class or interface.'
+ // );
+
+ if (is_string($expected)) {
+ if (PHPUnit_Util_Type::isType($expected)) {
+ $constraint = new PHPUnit_Framework_Constraint_IsType(
+ $expected
+ );
+ }
+
+ else if (class_exists($expected) || interface_exists($expected)) {
+ $constraint = new PHPUnit_Framework_Constraint_IsInstanceOf(
+ $expected
+ );
+ }
+
+ else {
+ throw PHPUnit_Util_InvalidArgumentHelper::factory(
+ 1, 'class or interface name'
+ );
+ }
+ } else {
+ throw PHPUnit_Util_InvalidArgumentHelper::factory(1, 'string');
+ }
+
+ self::assertThat($actual, $constraint, $message);
+ }
+
+ /**
* Helper function for the DOS matchers
*/
private function dataObjectArrayMatch($item, $match) {
Please sign in to comment.
Something went wrong with that request. Please try again.