Skip to content

Commit

Permalink
cake 2.2 test case fixes (assert corrections, correct class names)
Browse files Browse the repository at this point in the history
  • Loading branch information
euromark committed Apr 21, 2012
1 parent 2480ee1 commit bc2cd00
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Console/Templates/default/classes/test.ctp
Expand Up @@ -54,7 +54,7 @@ class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> {
* <?php echo $fullClassName; ?> Test Case
*
*/
class <?php echo $fullClassName; ?>TestCase extends CakeTestCase {
class <?php echo $fullClassName; ?>Test extends CakeTestCase {
<?php if (!empty($fixtures)): ?>
/**
* Fixtures
Expand Down
10 changes: 5 additions & 5 deletions lib/Cake/Test/Case/Console/Command/Task/TestTaskTest.php
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Expand Up @@ -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'));
}

/**
Expand Down
Expand Up @@ -64,7 +64,7 @@ public function testCountWithConditions() {
'I18n__content.locale' => 'eng'
)
));
$this->assertEqual(3, $result);
$this->assertEquals(3, $result);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/Model/ModelWriteTest.php
Expand Up @@ -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');

Expand Down Expand Up @@ -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']);

Expand Down Expand Up @@ -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');

Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/Network/CakeResponseTest.php
Expand Up @@ -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]',
Expand Down Expand Up @@ -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';
Expand All @@ -1002,7 +1002,7 @@ public function testCookieSettings() {
);

$result = $response->cookie();
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);
}

}
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Routing/Route/PluginShortRouteTest.php
Expand Up @@ -25,7 +25,7 @@
*
* @package Cake.Test.Case.Routing.Route
*/
class PluginShortRouteTestCase extends CakeTestCase {
class PluginShortRouteTest extends CakeTestCase {

/**
* setUp method
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Routing/Route/RedirectRouteTest.php
Expand Up @@ -26,7 +26,7 @@
*
* @package Cake.Test.Case.Routing.Route
*/
class RedirectRouteTestCase extends CakeTestCase {
class RedirectRouteTest extends CakeTestCase {

/**
* setUp method
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Routing/RouterTest.php
Expand Up @@ -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));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/Utility/CakeNumberTest.php
Expand Up @@ -87,7 +87,7 @@ public function testMultibyteFormat() {
'before' => '',
));
$expected = '5&nbsp;199&nbsp;100&amp;001';
$this->assertEqual($expected, $result);
$this->assertEquals($expected, $result);

$value = 1000.45;
$result = $this->Number->format($value, array(
Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/Utility/HashTest.php
Expand Up @@ -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',
Expand All @@ -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,
Expand All @@ -2122,7 +2122,7 @@ public function testExpand() {
)
)
);
$this->assertEqual($result, $expected);
$this->assertEquals($result, $expected);
}

}
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Utility/SetTest.php
Expand Up @@ -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);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -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);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/View/HelperTest.php
Expand Up @@ -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&amp;three=four', $result);
Expand All @@ -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');
}
Expand Down
12 changes: 6 additions & 6 deletions lib/Cake/Test/Case/View/JsonViewTest.php
Expand Up @@ -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());
}

/**
Expand All @@ -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());
}

/**
Expand Down Expand Up @@ -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());
}

}
6 changes: 3 additions & 3 deletions lib/Cake/Test/Case/View/ViewTest.php
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 5 additions & 5 deletions lib/Cake/Test/Case/View/XmlViewTest.php
Expand Up @@ -45,7 +45,7 @@ public function testRenderWithoutView() {

$expected = '<?xml version="1.0" encoding="UTF-8"?>' . "\n" . '<users><user>user1</user><user>user2</user></users>';
$this->assertTextEquals($expected, trim($output));
$this->assertIdentical('application/xml', $Response->type());
$this->assertSame('application/xml', $Response->type());
}

/**
Expand All @@ -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());
}

/**
Expand Down Expand Up @@ -101,8 +101,8 @@ public function testRenderWithView() {
$output = $View->render('index');

$expected = '<?xml version="1.0" encoding="UTF-8"?><users><user>user1</user><user>user2</user></users>';
$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);
}

Expand Down

0 comments on commit bc2cd00

Please sign in to comment.