Permalink
Browse files

More test helpers

  • Loading branch information...
1 parent 98d38d2 commit cea738d40d8d75703eabce8e9b1118c74f44fd6a @c9s committed Sep 10, 2012
Showing with 48 additions and 0 deletions.
  1. +48 −0 src/PHPUnit/TestMore.php
View
@@ -141,10 +141,58 @@ function dir_ok($path, $msg = null)
$test->assertTrue( is_dir($path) , "Path $path is a directory." );
}
+function same_ok($e,$v)
+{
+ $test = get_testcase_object();
+ $test->assertSame($e,$v);
+}
+
+function null_ok($e)
+{
+ $test = get_testcase_object();
+ $test->assertNull($e);
+}
+
+
+/**
+ * Assert object has an attribute
+ *
+ */
+function object_attribute_ok($o,$attributeName)
+{
+ $test = get_testcase_object();
+ $test->assertNotNull($o, "object " . get_class($o) . " is not empty");
+ $test->assertObjectHasAttribute($attributeName, $o);
+}
+
+function is_empty($e,$msg = null)
+{
+ $test = get_testcase_object();
+ $test->assertEmpty($e,$msg);
+}
+
+function array_key_ok($array,$key,$msg = null)
+{
+ $test = get_testcase_object();
+ $test->assertArrayHasKey($key,$array, $msg);
+}
+
+
+/**
+ * Assert html tags
+ */
+function tag_ok($matcher,$actual, $message = '',$isHtml = true)
+{
+ $test = get_testcase_object();
+ $test->assertTag($matcher,$actual, $message, $isHtml);
+}
+
+
function dump($e)
{
var_dump($e);
ob_flush();
}
+

0 comments on commit cea738d

Please sign in to comment.