Skip to content

Commit d41e562

Browse files
committed
Fix missing and invalid assertions in tests.
Remove unused variables and dead code.
1 parent ed445d8 commit d41e562

18 files changed

+25
-23
lines changed

lib/Cake/Test/Case/Console/AllConsoleLibsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class AllConsoleLibsTest extends PHPUnit_Framework_TestSuite {
3434
public static function suite() {
3535
$suite = new CakeTestSuite('All console lib classes');
3636

37-
$path = CORE_TEST_CASES . DS . 'Console';
3837
foreach (new DirectoryIterator(dirname(__FILE__)) as $file) {
3938
if (!$file->isFile() || strpos($file, 'All') === 0) {
4039
continue;

lib/Cake/Test/Case/Console/Command/Task/ControllerTaskTest.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ public function testConfirmController() {
253253
$scaffold = false;
254254
$helpers = array('Ajax', 'Time');
255255
$components = array('Acl', 'Auth');
256-
$uses = array('Comment', 'User');
257256

258257
$this->Task->expects($this->at(4))->method('out')->with("Controller Name:\n\t$controller");
259258
$this->Task->expects($this->at(5))->method('out')->with("Helpers:\n\tAjax, Time");
@@ -302,9 +301,6 @@ public function testBake() {
302301
*/
303302
public function testBakeWithPlugin() {
304303
$this->Task->plugin = 'ControllerTest';
305-
$helpers = array('Ajax', 'Time');
306-
$components = array('Acl', 'Auth');
307-
$uses = array('Comment', 'User');
308304

309305
//fake plugin path
310306
CakePlugin::load('ControllerTest', array('path' => APP . 'Plugin' . DS . 'ControllerTest' . DS));

lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,21 +283,27 @@ public function testFieldValidationGuessing() {
283283

284284
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
285285
$expected = array('notempty' => 'notempty');
286+
$this->assertEquals($expected, $result);
286287

287288
$result = $this->Task->fieldValidation('text', array('type' => 'date', 'length' => 10, 'null' => false));
288289
$expected = array('date' => 'date');
290+
$this->assertEquals($expected, $result);
289291

290292
$result = $this->Task->fieldValidation('text', array('type' => 'time', 'length' => 10, 'null' => false));
291293
$expected = array('time' => 'time');
294+
$this->assertEquals($expected, $result);
292295

293296
$result = $this->Task->fieldValidation('email', array('type' => 'string', 'length' => 10, 'null' => false));
294297
$expected = array('email' => 'email');
298+
$this->assertEquals($expected, $result);
295299

296300
$result = $this->Task->fieldValidation('test', array('type' => 'integer', 'length' => 10, 'null' => false));
297301
$expected = array('numeric' => 'numeric');
302+
$this->assertEquals($expected, $result);
298303

299304
$result = $this->Task->fieldValidation('test', array('type' => 'boolean', 'length' => 10, 'null' => false));
300-
$expected = array('numeric' => 'numeric');
305+
$expected = array('boolean' => 'boolean');
306+
$this->assertEquals($expected, $result);
301307
}
302308

303309
/**
@@ -589,6 +595,13 @@ public function testDoAssociationsNonInteractive() {
589595
$model = new Model(array('ds' => 'test', 'name' => 'BakeArticle'));
590596
$result = $this->Task->doAssociations($model);
591597
$expected = array(
598+
'belongsTo' => array(
599+
array(
600+
'alias' => 'BakeUser',
601+
'className' => 'BakeUser',
602+
'foreignKey' => 'bake_user_id',
603+
),
604+
),
592605
'hasMany' => array(
593606
array(
594607
'alias' => 'BakeComment',
@@ -606,6 +619,7 @@ public function testDoAssociationsNonInteractive() {
606619
),
607620
),
608621
);
622+
$this->assertEquals($result, $expected);
609623
}
610624

611625
/**

lib/Cake/Test/Case/Controller/Component/RequestHandlerComponentTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,6 @@ public function testRespondAs() {
428428
$this->RequestHandler->response->expects($this->at(1))->method('type')
429429
->with('text/xml');
430430

431-
$RequestHandler = $this->getMock('RequestHandlerComponent', array('_header'), array(&$this->Controller->Components));
432431
$result = $this->RequestHandler->respondAs('json');
433432
$this->assertTrue($result);
434433
$result = $this->RequestHandler->respondAs('text/xml');

lib/Cake/Test/Case/Controller/Component/SecurityComponentTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,6 @@ public function testValidatePostNoSession() {
480480
public function testValidatePostFormHacking() {
481481
$this->Controller->Security->startup($this->Controller);
482482
$key = $this->Controller->params['_Token']['key'];
483-
$fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3AModel.valid';
484483
$unlocked = '';
485484

486485
$this->Controller->request->data = array(

lib/Cake/Test/Case/Controller/ControllerTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,6 @@ public function testLoadModelInPlugins() {
490490
*/
491491
public function testConstructClasses() {
492492
$request = new CakeRequest('controller_posts/index');
493-
$Controller = new Controller($request);
494493

495494
$Controller = new Controller($request);
496495
$Controller->uses = array('ControllerPost', 'ControllerComment');
@@ -511,8 +510,6 @@ public function testConstructClasses() {
511510

512511
$this->assertTrue(isset($Controller->TestPluginPost));
513512
$this->assertTrue(is_a($Controller->TestPluginPost, 'TestPluginPost'));
514-
515-
unset($Controller);
516513
}
517514

518515
/**

lib/Cake/Test/Case/I18n/I18nTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,12 @@ public function tearDown() {
5757
*/
5858
public function testTranslationCaching() {
5959
Configure::write('Config.language', 'cache_test_po');
60-
$i18n = I18n::getInstance();
6160

6261
// reset internally stored entries
6362
I18n::clear();
6463

6564
Cache::clear(false, '_cake_core_');
66-
$lang = Configure::read('Config.language');#$i18n->l10n->locale;
65+
$lang = Configure::read('Config.language');
6766

6867
Cache::config('_cake_core_', Cache::config('default'));
6968

lib/Cake/Test/Case/I18n/MultibyteTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8800,7 +8800,6 @@ public function testUsingMbSubstr() {
88008800
$this->assertEquals($expected, $result);
88018801

88028802
$string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ';
8803-
$find = 'Ċ';
88048803
$result = mb_substr($string, 4, 7);
88058804
$expected = 'ĈĊČĎĐĒĔ';
88068805
$this->assertEquals($expected, $result);
@@ -8958,7 +8957,6 @@ public function testMultibyteSubstr() {
89588957
$this->assertEquals($expected, $result);
89598958

89608959
$string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ';
8961-
$find = 'Ċ';
89628960
$result = Multibyte::substr($string, 4, 7);
89638961
$expected = 'ĈĊČĎĐĒĔ';
89648962
$this->assertEquals($expected, $result);

lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,6 @@ public function testGenerateAssociationQuerySelfJoinWithConditionsInHasOneBindin
11421142
$null = null;
11431143

11441144
$params = &$this->_prepareAssociationQuery($this->Model, $queryData, $binding);
1145-
$_queryData = $queryData;
11461145
$result = $this->Dbo->generateAssociationQuery($this->Model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet);
11471146
$this->assertTrue($result);
11481147

lib/Cake/Test/Case/Model/ModelDeleteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ public function testDeleteDependent() {
636636
$this->assertEquals(4, $result);
637637

638638
$result = $Article->delete(1, true);
639-
$this->assertIdentical(true, true);
639+
$this->assertSame($result, true);
640640

641641
$result = $Article->Comment->find('count', array(
642642
'conditions' => array('Comment.article_id' => 1)

lib/Cake/Test/Case/Model/ModelReadTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public function testFetchingNonUniqueFKJoinTableRecords() {
7676
* @return void
7777
*/
7878
public function testGroupBy() {
79-
$db = ConnectionManager::getDataSource('test');
8079
$isStrictGroupBy = $this->db instanceof Postgres || $this->db instanceof Sqlite || $this->db instanceof Oracle || $this->db instanceof Sqlserver;
8180
$message = 'Postgres, Oracle, SQLite and SQL Server have strict GROUP BY and are incompatible with this test.';
8281

@@ -6769,6 +6768,7 @@ public function testFindCount() {
67696768
$this->db->fullDebug = true;
67706769
$TestModel->order = 'User.id';
67716770
$result = $TestModel->find('count');
6771+
$this->db->fullDebug = $fullDebug;
67726772
$this->assertEquals($result, 4);
67736773

67746774
$log = $this->db->getLog();

lib/Cake/Test/Case/Network/CakeSocketTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public function testTimeOutConnection() {
181181
$this->assertTrue($this->Socket->connect());
182182

183183
$config = array('host' => '127.0.0.1', 'timeout' => 0.00001);
184+
$this->Socket = new CakeSocket($config);
184185
$this->assertFalse($this->Socket->read(1024 * 1024));
185186
$this->assertEquals($this->Socket->lastError(), '2: ' . __d('cake_dev', 'Connection timed out'));
186187
}

lib/Cake/Test/Case/Routing/RouterTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,8 @@ public function testUrlParsing() {
969969
Router::reload();
970970
Router::connect('/page/*', array('controller' => 'test'));
971971
$result = Router::parse('/page/my-page');
972-
$expected = array('pass' => array('my-page'), 'plugin' => null, 'controller' => 'test', 'action' => 'index');
972+
$expected = array('pass' => array('my-page'), 'plugin' => null, 'controller' => 'test', 'action' => 'index', 'named' => array());
973+
$this->assertEquals($expected, $result);
973974

974975
Router::reload();
975976
Router::connect('/:language/contact', array('language' => 'eng', 'plugin' => 'contact', 'controller' => 'contact', 'action' => 'index'), array('language' => '[a-z]{3}'));

lib/Cake/Test/Case/TestSuite/CakeTestSuiteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testAddTestDirectory() {
6060
*
6161
* @return void
6262
*/
63-
public function testAddTestDirectoryRecursive() {return;
63+
public function testAddTestDirectoryRecursive() {
6464
$testFolder = CORE_TEST_CASES . DS . 'Cache';
6565
$count = count(glob($testFolder . DS . '*Test.php'));
6666
$count += count(glob($testFolder . DS . 'Engine' . DS . '*Test.php'));

lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2140,8 +2140,9 @@ public function testWithPlugin() {
21402140
$this->Paginator->options(array('url' => array('plugin' => null)));
21412141
$result = $this->Paginator->link('Page 3', array('page' => 3));
21422142
$expected = array(
2143-
'a' => array('/magazines/index/page:3'), 'Page 3', '/a'
2143+
'a' => array('href' => '/magazines/index/page:3'), 'Page 3', '/a'
21442144
);
2145+
$this->assertTags($result, $expected);
21452146

21462147
$this->Paginator->options(array('url' => array('plugin' => null, 'controller' => 'issues')));
21472148
$result = $this->Paginator->link('Page 3', array('page' => 3));

lib/Cake/Test/Case/View/Helper/SessionHelperTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public function testFlashElementInAttrs() {
168168
'params' => array('title' => 'Notice!', 'name' => 'Alert!')
169169
));
170170
$expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a calling</p>\n</div>";
171+
$this->assertEquals($expected, $result);
171172
}
172173

173174
/**

lib/Cake/Test/Case/View/MediaViewTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ class MediaViewTest extends CakeTestCase {
3535
*/
3636
public function setUp() {
3737
parent::setUp();
38-
$controller = new Controller();
3938
$this->MediaView = $this->getMock('MediaView', array('_isActive', '_clearBuffer', '_flushBuffer'));
4039
$this->MediaView->response = $this->getMock('CakeResponse');
4140
}

lib/Cake/Test/Case/View/ViewTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,6 @@ public function testRenderCache() {
10821082
$View->renderCache($path, '+1 second');
10831083
$result = ob_get_clean();
10841084

1085-
$expected = 'some cacheText';
10861085
$this->assertRegExp('/^some cacheText/', $result);
10871086

10881087
@unlink($path);

0 commit comments

Comments
 (0)