Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify.

  • Loading branch information...
commit e9c0f9e0c6dc255b15e1714894650e2cbe750860 1 parent 896f96f
@sebastianbergmann authored
Showing with 20 additions and 60 deletions.
  1. +20 −60 PHPUnit/Framework/Assert.php
View
80 PHPUnit/Framework/Assert.php
@@ -94,9 +94,7 @@ public static function assertArrayHasKey($key, array $array, $message = '')
$constraint = new PHPUnit_Framework_Constraint_ArrayHasKey($key);
- if (!$constraint->evaluate($array)) {
- $constraint->fail($array, $message);
- }
+ self::assertThat($array, $constraint, $message);
}
/**
@@ -119,9 +117,7 @@ public static function assertArrayNotHasKey($key, array $array, $message = '')
new PHPUnit_Framework_Constraint_ArrayHasKey($key)
);
- if (!$constraint->evaluate($array)) {
- $constraint->fail($array, $message);
- }
+ self::assertThat($array, $constraint, $message);
}
/**
@@ -149,9 +145,7 @@ public static function assertContains($needle, $haystack, $message = '')
throw new InvalidArgumentException;
}
- if (!$constraint->evaluate($haystack)) {
- $constraint->fail($haystack, $message);
- }
+ self::assertThat($haystack, $constraint, $message);
}
/**
@@ -208,9 +202,7 @@ public static function assertNotContains($needle, $haystack, $message = '')
throw new InvalidArgumentException;
}
- if (!$constraint->evaluate($haystack)) {
- $constraint->fail($haystack, $message);
- }
+ self::assertThat($haystack, $constraint, $message);
}
/**
@@ -257,9 +249,7 @@ public static function assertEquals($expected, $actual, $message = '', $delta =
$maxDepth
);
- if (!$constraint->evaluate($actual)) {
- $constraint->fail($actual, $message);
- }
+ self::assertThat($actual, $constraint, $message);
}
/**
@@ -311,9 +301,7 @@ public static function assertNotEquals($expected, $actual, $message = '', $delta
)
);
- if (!$constraint->evaluate($actual)) {
- $constraint->fail($actual, $message);
- }
+ self::assertThat($actual, $constraint, $message);
}
/**
@@ -360,9 +348,7 @@ public static function assertFileExists($filename, $message = '')
$constraint = new PHPUnit_Framework_Constraint_FileExists;
- if (!$constraint->evaluate($filename)) {
- $constraint->fail($filename, $message);
- }
+ self::assertThat($filename, $constraint, $message);
}
/**
@@ -384,9 +370,7 @@ public static function assertFileNotExists($filename, $message = '')
new PHPUnit_Framework_Constraint_FileExists
);
- if (!$constraint->evaluate($filename)) {
- $constraint->fail($filename, $message);
- }
+ self::assertThat($filename, $constraint, $message);
}
/**
@@ -407,9 +391,7 @@ public static function assertTrue($condition, $message = '')
$constraint = new PHPUnit_Framework_Constraint_IsIdentical(TRUE);
- if (!$constraint->evaluate($condition)) {
- $constraint->fail($condition, $message);
- }
+ self::assertThat($condition, $constraint, $message);
}
/**
@@ -430,9 +412,7 @@ public static function assertFalse($condition, $message = '')
$constraint = new PHPUnit_Framework_Constraint_IsIdentical(FALSE);
- if (!$constraint->evaluate($condition)) {
- $constraint->fail($condition, $message);
- }
+ self::assertThat($condition, $constraint, $message);
}
/**
@@ -449,9 +429,7 @@ public static function assertNotNull($actual, $message = '')
new PHPUnit_Framework_Constraint_IsIdentical(NULL)
);
- if (!$constraint->evaluate($actual)) {
- $constraint->fail($actual, $message);
- }
+ self::assertThat($actual, $constraint, $message);
}
/**
@@ -466,9 +444,7 @@ public static function assertNull($actual, $message = '')
{
$constraint = new PHPUnit_Framework_Constraint_IsIdentical(NULL);
- if (!$constraint->evaluate($actual)) {
- $constraint->fail($actual, $message);
- }
+ self::assertThat($actual, $constraint, $message);
}
/**
@@ -489,9 +465,7 @@ public static function assertObjectHasAttribute($attributeName, $object, $messag
$constraint = new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName);
- if (!$constraint->evaluate($object)) {
- $constraint->fail($object, $message);
- }
+ self::assertThat($object, $constraint, $message);
}
/**
@@ -514,9 +488,7 @@ public static function assertObjectNotHasAttribute($attributeName, $object, $mes
new PHPUnit_Framework_Constraint_ObjectHasAttribute($attributeName)
);
- if (!$constraint->evaluate($object)) {
- $constraint->fail($object, $message);
- }
+ self::assertThat($object, $constraint, $message);
}
/**
@@ -534,9 +506,7 @@ public static function assertSame($expected, $actual, $message = '')
{
$constraint = new PHPUnit_Framework_Constraint_IsIdentical($expected);
- if (!$constraint->evaluate($actual)) {
- $constraint->fail($actual, $message);
- }
+ self::assertThat($actual, $constraint, $message);
}
/**
@@ -580,9 +550,7 @@ public static function assertNotSame($expected, $actual, $message = '')
new PHPUnit_Framework_Constraint_IsIdentical($expected)
);
- if (!$constraint->evaluate($actual)) {
- $constraint->fail($actual, $message);
- }
+ self::assertThat($actual, $constraint, $message);
}
/**
@@ -633,9 +601,7 @@ public static function assertType($expected, $actual, $message = '')
throw new InvalidArgumentException;
}
- if (!$constraint->evaluate($actual)) {
- $constraint->fail($actual, $message);
- }
+ self::assertThat($actual, $constraint, $message);
}
/**
@@ -665,9 +631,7 @@ public static function assertNotType($expected, $actual, $message = '')
throw new InvalidArgumentException;
}
- if (!$constraint->evaluate($actual)) {
- $constraint->fail($actual, $message);
- }
+ self::assertThat($actual, $constraint, $message);
}
/**
@@ -687,9 +651,7 @@ public static function assertRegExp($pattern, $string, $message = '')
$constraint = new PHPUnit_Framework_Constraint_PCREMatch($pattern);
- if (!$constraint->evaluate($string)) {
- $constraint->fail($string, $message);
- }
+ self::assertThat($string, $constraint, $message);
}
/**
@@ -712,9 +674,7 @@ public static function assertNotRegExp($pattern, $string, $message = '')
new PHPUnit_Framework_Constraint_PCREMatch($pattern)
);
- if (!$constraint->evaluate($string)) {
- $constraint->fail($string, $message);
- }
+ self::assertThat($string, $constraint, $message);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.