From 14559aabd9b545c40790aa0e8074fddbad0ab3e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Tue, 4 May 2010 13:47:08 -0430 Subject: [PATCH] Adding compatibility assert methods for CakeTestCase to ease the transition to PHPUnit --- cake/tests/lib/cake_test_case.php | 35 ++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index b2799e44d..50aebfe76 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -82,7 +82,7 @@ class CakeTestDispatcher extends Dispatcher { * @package cake * @subpackage cake.cake.tests.lib */ -class CakeTestCase extends UnitTestCase { +class CakeTestCase extends PHPUnit_Framework_TestCase { /** * Methods used internally. @@ -191,8 +191,10 @@ class CakeTestCase extends UnitTestCase { * @param string $message * @return boolean */ - public function skipIf($shouldSkip, $message = '%s') { - parent::skipIf($shouldSkip, $message); + public function skipIf($shouldSkip, $message = '') { + if ($shouldSkip) { + $this->markTestSkipped($message); + } return $shouldSkip; } @@ -298,7 +300,7 @@ class CakeTestCase extends UnitTestCase { * @param mixed $params Parameters (see above), or simply a string of what to return * @return mixed Whatever is returned depending of requested result */ - public function testAction($url, $params = array()) { + public function runTestAction($url, $params = array()) { $default = array( 'return' => 'result', 'fixturize' => false, @@ -685,7 +687,7 @@ class CakeTestCase extends UnitTestCase { return false; } } - return $this->assert(new TrueExpectation(), true, '%s'); + return $this->assertTrue(true, '%s'); } /** @@ -817,5 +819,28 @@ class CakeTestCase extends UnitTestCase { return $permuted; } } + + protected function assertEqual($a, $b) { + return $this->assertEquals($a, $b); + } + + protected function assertPattern($pattern, $string, $message = '') { + return $this->assertRegExp($pattern, $string, $message); + } + + protected function assertIdentical($expected, $actual, $message = '') { + return $this->assertSame($expected, $actual, $message); + } + + protected function assertNoPattern($pattern, $string, $message = '') { + return $this->assertNotRegExp($pattern, $string, $message); + } + + protected function assertNoErrors() { + } + + protected function expectException($name = null) { + $this->setExpectedException($name); + } } ?> \ No newline at end of file