From bc2cd00123df0e0f983d3eeeb28aa0e165667b4c Mon Sep 17 00:00:00 2001 From: euromark Date: Sat, 21 Apr 2012 15:02:35 +0200 Subject: [PATCH] cake 2.2 test case fixes (assert corrections, correct class names) --- lib/Cake/Console/Templates/default/classes/test.ctp | 2 +- .../Test/Case/Console/Command/Task/TestTaskTest.php | 10 +++++----- .../Controller/Component/CookieComponentTest.php | 8 ++++---- .../Case/Model/Behavior/TranslateBehaviorTest.php | 2 +- lib/Cake/Test/Case/Model/ModelWriteTest.php | 6 +++--- lib/Cake/Test/Case/Network/CakeResponseTest.php | 6 +++--- .../Test/Case/Routing/Route/PluginShortRouteTest.php | 2 +- .../Test/Case/Routing/Route/RedirectRouteTest.php | 2 +- lib/Cake/Test/Case/Routing/RouterTest.php | 4 ++-- lib/Cake/Test/Case/Utility/CakeNumberTest.php | 4 ++-- lib/Cake/Test/Case/Utility/HashTest.php | 6 +++--- lib/Cake/Test/Case/Utility/SetTest.php | 2 +- lib/Cake/Test/Case/View/Helper/FormHelperTest.php | 4 ++-- lib/Cake/Test/Case/View/HelperTest.php | 6 +++--- lib/Cake/Test/Case/View/JsonViewTest.php | 12 ++++++------ lib/Cake/Test/Case/View/ViewTest.php | 6 +++--- lib/Cake/Test/Case/View/XmlViewTest.php | 10 +++++----- 17 files changed, 46 insertions(+), 46 deletions(-) diff --git a/lib/Cake/Console/Templates/default/classes/test.ctp b/lib/Cake/Console/Templates/default/classes/test.ctp index ecf8ea8a5d1..78fe39799c9 100644 --- a/lib/Cake/Console/Templates/default/classes/test.ctp +++ b/lib/Cake/Console/Templates/default/classes/test.ctp @@ -54,7 +54,7 @@ class Test extends { * Test Case * */ -class TestCase extends CakeTestCase { +class Test extends CakeTestCase { /** * Fixtures diff --git a/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php b/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php index f5f9177cd2b..37f854b2e26 100644 --- a/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php +++ b/lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php @@ -437,7 +437,7 @@ public function testBakeModelTest() { $result = $this->Task->bake('Model', 'TestTaskArticle'); $this->assertContains("App::uses('TestTaskArticle', 'Model')", $result); - $this->assertContains('class TestTaskArticleTestCase extends CakeTestCase', $result); + $this->assertContains('class TestTaskArticleTest extends CakeTestCase', $result); $this->assertContains('function setUp()', $result); $this->assertContains("\$this->TestTaskArticle = ClassRegistry::init('TestTaskArticle')", $result); @@ -468,7 +468,7 @@ public function testBakeControllerTest() { $result = $this->Task->bake('Controller', 'TestTaskComments'); $this->assertContains("App::uses('TestTaskCommentsController', 'Controller')", $result); - $this->assertContains('class TestTaskCommentsControllerTestCase extends CakeTestCase', $result); + $this->assertContains('class TestTaskCommentsControllerTest extends CakeTestCase', $result); $this->assertContains('class TestTestTaskCommentsController extends TestTaskCommentsController', $result); $this->assertContains('public $autoRender = false', $result); @@ -655,7 +655,7 @@ public function testExecuteWithOneArg() { $this->Task->expects($this->once())->method('createFile') ->with( $this->anything(), - $this->stringContains('class TestTaskTagTestCase extends CakeTestCase') + $this->stringContains('class TestTaskTagTest extends CakeTestCase') ); $this->Task->execute(); } @@ -671,7 +671,7 @@ public function testExecuteWithTwoArgs() { $this->Task->expects($this->once())->method('createFile') ->with( $this->anything(), - $this->stringContains('class TestTaskTagTestCase extends CakeTestCase') + $this->stringContains('class TestTaskTagTest extends CakeTestCase') ); $this->Task->expects($this->any())->method('isLoadableClass')->will($this->returnValue(true)); $this->Task->execute(); @@ -688,7 +688,7 @@ public function testExecuteWithTwoArgsLowerCase() { $this->Task->expects($this->once())->method('createFile') ->with( $this->anything(), - $this->stringContains('class TestTaskTagTestCase extends CakeTestCase') + $this->stringContains('class TestTaskTagTest extends CakeTestCase') ); $this->Task->expects($this->any())->method('isLoadableClass')->will($this->returnValue(true)); $this->Task->execute(); diff --git a/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php b/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php index 7924876441b..87c5bd7d62c 100644 --- a/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php +++ b/lib/Cake/Test/Case/Controller/Component/CookieComponentTest.php @@ -518,10 +518,10 @@ public function testReadEmpty() { 'Empty' => '', 'String' => '{"somewhat:"broken"}' ); - $this->assertEqual(array('name' => 'value'), $this->Cookie->read('JSON')); - $this->assertEqual('value', $this->Cookie->read('JSON.name')); - $this->assertEqual('', $this->Cookie->read('Empty')); - $this->assertEqual('{"somewhat:"broken"}', $this->Cookie->read('String')); + $this->assertEquals(array('name' => 'value'), $this->Cookie->read('JSON')); + $this->assertEquals('value', $this->Cookie->read('JSON.name')); + $this->assertEquals('', $this->Cookie->read('Empty')); + $this->assertEquals('{"somewhat:"broken"}', $this->Cookie->read('String')); } /** diff --git a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php index a28655cdc54..d280f7fac45 100644 --- a/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php +++ b/lib/Cake/Test/Case/Model/Behavior/TranslateBehaviorTest.php @@ -64,7 +64,7 @@ public function testCountWithConditions() { 'I18n__content.locale' => 'eng' ) )); - $this->assertEqual(3, $result); + $this->assertEquals(3, $result); } /** diff --git a/lib/Cake/Test/Case/Model/ModelWriteTest.php b/lib/Cake/Test/Case/Model/ModelWriteTest.php index 984e5649d41..72c3309d838 100644 --- a/lib/Cake/Test/Case/Model/ModelWriteTest.php +++ b/lib/Cake/Test/Case/Model/ModelWriteTest.php @@ -6370,7 +6370,7 @@ public function testSaveAllFieldListValidateBelongsTo() { $TestModel = new Post(); $result = $TestModel->find('all'); - $this->assertEqual(3, count($result)); + $this->assertEquals(3, count($result)); $this->assertFalse(isset($result[3])); $ts = date('Y-m-d H:i:s'); @@ -6411,7 +6411,7 @@ public function testSaveAllFieldListValidateBelongsTo() { ), ); $this->assertEquals($expected, $result[3]); - $this->assertEqual(4, count($result)); + $this->assertEquals(4, count($result)); $this->assertEquals('', $result[3]['Post']['body']); $this->assertEquals('working', $result[3]['Author']['test']); @@ -6542,7 +6542,7 @@ public function testSaveAllDeepFieldListValidateBelongsTo() { $TestModel->recursive = 2; $result = $TestModel->find('all'); - $this->assertEqual(3, count($result)); + $this->assertEquals(3, count($result)); $this->assertFalse(isset($result[3])); $ts = date('Y-m-d H:i:s'); diff --git a/lib/Cake/Test/Case/Network/CakeResponseTest.php b/lib/Cake/Test/Case/Network/CakeResponseTest.php index f27ac1f1f1d..b3df124f655 100644 --- a/lib/Cake/Test/Case/Network/CakeResponseTest.php +++ b/lib/Cake/Test/Case/Network/CakeResponseTest.php @@ -943,7 +943,7 @@ public function testCookieSettings() { 'secure' => false, 'httpOnly' => false); $result = $response->cookie('CakeTestCookie[Testing]'); - $this->assertEqual($result, $expected); + $this->assertEquals($result, $expected); $cookie = array( 'name' => 'CakeTestCookie[Testing2]', @@ -975,7 +975,7 @@ public function testCookieSettings() { ); $result = $response->cookie(); - $this->assertEqual($result, $expected); + $this->assertEquals($result, $expected); $cookie = $expected['CakeTestCookie[Testing]']; $cookie['value'] = 'test'; @@ -1002,7 +1002,7 @@ public function testCookieSettings() { ); $result = $response->cookie(); - $this->assertEqual($result, $expected); + $this->assertEquals($result, $expected); } } diff --git a/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php b/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php index 7be78935709..4438d47ec7d 100644 --- a/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php @@ -25,7 +25,7 @@ * * @package Cake.Test.Case.Routing.Route */ -class PluginShortRouteTestCase extends CakeTestCase { +class PluginShortRouteTest extends CakeTestCase { /** * setUp method diff --git a/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php b/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php index 1e6666740f5..33b4276b0d1 100644 --- a/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php +++ b/lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php @@ -26,7 +26,7 @@ * * @package Cake.Test.Case.Routing.Route */ -class RedirectRouteTestCase extends CakeTestCase { +class RedirectRouteTest extends CakeTestCase { /** * setUp method diff --git a/lib/Cake/Test/Case/Routing/RouterTest.php b/lib/Cake/Test/Case/Routing/RouterTest.php index 55d4e5d02cc..d45cafa17b0 100644 --- a/lib/Cake/Test/Case/Routing/RouterTest.php +++ b/lib/Cake/Test/Case/Routing/RouterTest.php @@ -2551,8 +2551,8 @@ public function testDefaultRouteClassGetter() { $routeClass = 'TestDefaultRouteClass'; Router::defaultRouteClass($routeClass); - $this->assertEqual($routeClass, Router::defaultRouteClass()); - $this->assertEqual($routeClass, Router::defaultRouteClass(null)); + $this->assertEquals($routeClass, Router::defaultRouteClass()); + $this->assertEquals($routeClass, Router::defaultRouteClass(null)); } /** diff --git a/lib/Cake/Test/Case/Utility/CakeNumberTest.php b/lib/Cake/Test/Case/Utility/CakeNumberTest.php index 1d0acdcf3c2..1895c4db261 100644 --- a/lib/Cake/Test/Case/Utility/CakeNumberTest.php +++ b/lib/Cake/Test/Case/Utility/CakeNumberTest.php @@ -87,7 +87,7 @@ public function testMultibyteFormat() { 'before' => '', )); $expected = '5 199 100&001'; - $this->assertEqual($expected, $result); + $this->assertEquals($expected, $result); $value = 1000.45; $result = $this->Number->format($value, array( @@ -96,7 +96,7 @@ public function testMultibyteFormat() { 'escape' => false, )); $expected = '$1,,000.a45'; - $this->assertEqual($expected, $result); + $this->assertEquals($expected, $result); $value = 519919827593784.00; $this->Number->addFormat('RUR', array( diff --git a/lib/Cake/Test/Case/Utility/HashTest.php b/lib/Cake/Test/Case/Utility/HashTest.php index 588a8d0cb66..5305cb889e7 100644 --- a/lib/Cake/Test/Case/Utility/HashTest.php +++ b/lib/Cake/Test/Case/Utility/HashTest.php @@ -2088,7 +2088,7 @@ public function testExpand() { $data = array('My', 'Array', 'To', 'Flatten'); $flat = Hash::flatten($data); $result = Hash::expand($flat); - $this->assertEqual($data, $result); + $this->assertEquals($data, $result); $data = array( '0.Post.id' => '1', '0.Post.author_id' => '1', '0.Post.title' => 'First Post', '0.Author.id' => '1', @@ -2107,7 +2107,7 @@ public function testExpand() { 'Author' => array('id' => '3', 'user' => 'larry', 'password' => null), ) ); - $this->assertEqual($result, $expected); + $this->assertEquals($result, $expected); $data = array( '0/Post/id' => 1, @@ -2122,7 +2122,7 @@ public function testExpand() { ) ) ); - $this->assertEqual($result, $expected); + $this->assertEquals($result, $expected); } } diff --git a/lib/Cake/Test/Case/Utility/SetTest.php b/lib/Cake/Test/Case/Utility/SetTest.php index daa46666119..41f781bddad 100644 --- a/lib/Cake/Test/Case/Utility/SetTest.php +++ b/lib/Cake/Test/Case/Utility/SetTest.php @@ -3034,7 +3034,7 @@ public function testExpand() { $data = array('My', 'Array', 'To', 'Flatten'); $flat = Set::flatten($data); $result = Set::expand($flat); - $this->assertEqual($data, $result); + $this->assertEquals($data, $result); } /** diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index aa7f4009383..1accaa47120 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -1492,12 +1492,12 @@ public function testTagIsInvalid() { $this->Form->setEntity('Contact.1.email'); $result = $this->Form->tagIsInvalid(); $expected = false; - $this->assertIdentical($expected, $result); + $this->assertSame($expected, $result); $this->Form->setEntity('Contact.0.name'); $result = $this->Form->tagIsInvalid(); $expected = false; - $this->assertIdentical($expected, $result); + $this->assertSame($expected, $result); } /** diff --git a/lib/Cake/Test/Case/View/HelperTest.php b/lib/Cake/Test/Case/View/HelperTest.php index 5cb5801d6f9..63f32b0b740 100644 --- a/lib/Cake/Test/Case/View/HelperTest.php +++ b/lib/Cake/Test/Case/View/HelperTest.php @@ -620,7 +620,7 @@ public function testAssetUrl() { $this->assertEquals(FULL_BASE_URL . '/foo.jpg', $result); $result = $this->Helper->assetUrl('style', array('ext' => '.css')); - $this->assertEqual('style.css', $result); + $this->assertEquals('style.css', $result); $result = $this->Helper->assetUrl('foo.jpg?one=two&three=four'); $this->assertEquals('foo.jpg?one=two&three=four', $result); @@ -636,10 +636,10 @@ public function testAssetUrlPlugin() { CakePlugin::load('TestPlugin'); $result = $this->Helper->assetUrl('TestPlugin.style', array('ext' => '.css')); - $this->assertEqual('test_plugin/style.css', $result); + $this->assertEquals('test_plugin/style.css', $result); $result = $this->Helper->assetUrl('TestPlugin.style', array('ext' => '.css', 'plugin' => false)); - $this->assertEqual('TestPlugin.style.css', $result); + $this->assertEquals('TestPlugin.style.css', $result); CakePlugin::unload('TestPlugin'); } diff --git a/lib/Cake/Test/Case/View/JsonViewTest.php b/lib/Cake/Test/Case/View/JsonViewTest.php index 9515a94723b..f384ee6ba24 100644 --- a/lib/Cake/Test/Case/View/JsonViewTest.php +++ b/lib/Cake/Test/Case/View/JsonViewTest.php @@ -43,8 +43,8 @@ public function testRenderWithoutView() { $View = new JsonView($Controller); $output = $View->render(false); - $this->assertIdentical(json_encode($data), $output); - $this->assertIdentical('application/json', $Response->type()); + $this->assertSame(json_encode($data), $output); + $this->assertSame('application/json', $Response->type()); } /** @@ -62,8 +62,8 @@ public function testRenderWithoutViewMultiple() { $View = new JsonView($Controller); $output = $View->render(false); - $this->assertIdentical(json_encode(array('no' => $data['no'], 'user' => $data['user'])), $output); - $this->assertIdentical('application/json', $Response->type()); + $this->assertSame(json_encode(array('no' => $data['no'], 'user' => $data['user'])), $output); + $this->assertSame('application/json', $Response->type()); } /** @@ -94,8 +94,8 @@ public function testRenderWithView() { $output = $View->render('index'); $expected = json_encode(array('user' => 'fake', 'list' => array('item1', 'item2'))); - $this->assertIdentical($expected, $output); - $this->assertIdentical('application/json', $Response->type()); + $this->assertSame($expected, $output); + $this->assertSame('application/json', $Response->type()); } } diff --git a/lib/Cake/Test/Case/View/ViewTest.php b/lib/Cake/Test/Case/View/ViewTest.php index 11bbb44a165..b3dbb656cd6 100644 --- a/lib/Cake/Test/Case/View/ViewTest.php +++ b/lib/Cake/Test/Case/View/ViewTest.php @@ -640,8 +640,8 @@ public function testElement() { $this->assertEquals('this is the plugin element using params[plugin]', $result); $result = $this->View->element('test_plugin.plugin_element'); - $this->assertPattern('/Not Found:/', $result); - $this->assertPattern('/test_plugin.plugin_element/', $result); + $this->assertRegExp('/Not Found:/', $result); + $this->assertRegExp('/test_plugin.plugin_element/', $result); $this->View->plugin = 'TestPlugin'; $result = $this->View->element('test_plugin_element'); @@ -1040,7 +1040,7 @@ public function testViewFileName() { $this->assertRegExp('/Posts(\/|\\\)index.ctp/', $result); $result = $View->getViewFileName('TestPlugin.index'); - $this->assertPattern('/Posts(\/|\\\)index.ctp/', $result); + $this->assertRegExp('/Posts(\/|\\\)index.ctp/', $result); $result = $View->getViewFileName('/Pages/home'); $this->assertRegExp('/Pages(\/|\\\)home.ctp/', $result); diff --git a/lib/Cake/Test/Case/View/XmlViewTest.php b/lib/Cake/Test/Case/View/XmlViewTest.php index 055894525a0..51243ccb14d 100644 --- a/lib/Cake/Test/Case/View/XmlViewTest.php +++ b/lib/Cake/Test/Case/View/XmlViewTest.php @@ -45,7 +45,7 @@ public function testRenderWithoutView() { $expected = '' . "\n" . 'user1user2'; $this->assertTextEquals($expected, trim($output)); - $this->assertIdentical('application/xml', $Response->type()); + $this->assertSame('application/xml', $Response->type()); } /** @@ -66,8 +66,8 @@ public function testRenderWithoutViewMultiple() { $expected = array( 'response' => array('no' => $data['no'], 'user' => $data['user']) ); - $this->assertIdentical(Xml::build($expected)->asXML(), $output); - $this->assertIdentical('application/xml', $Response->type()); + $this->assertSame(Xml::build($expected)->asXML(), $output); + $this->assertSame('application/xml', $Response->type()); } /** @@ -101,8 +101,8 @@ public function testRenderWithView() { $output = $View->render('index'); $expected = 'user1user2'; - $this->assertIdentical($expected, str_replace(array("\r", "\n"), '', $output)); - $this->assertIdentical('application/xml', $Response->type()); + $this->assertSame($expected, str_replace(array("\r", "\n"), '', $output)); + $this->assertSame('application/xml', $Response->type()); $this->assertInstanceOf('HelperCollection', $View->Helpers); }