Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing and invalid assertions in tests #481

Merged
merged 1 commit into from Feb 16, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/Cake/Test/Case/Console/AllConsoleLibsTest.php
Expand Up @@ -34,7 +34,6 @@ class AllConsoleLibsTest extends PHPUnit_Framework_TestSuite {
public static function suite() { public static function suite() {
$suite = new CakeTestSuite('All console lib classes'); $suite = new CakeTestSuite('All console lib classes');


$path = CORE_TEST_CASES . DS . 'Console';
foreach (new DirectoryIterator(dirname(__FILE__)) as $file) { foreach (new DirectoryIterator(dirname(__FILE__)) as $file) {
if (!$file->isFile() || strpos($file, 'All') === 0) { if (!$file->isFile() || strpos($file, 'All') === 0) {
continue; continue;
Expand Down
Expand Up @@ -253,7 +253,6 @@ public function testConfirmController() {
$scaffold = false; $scaffold = false;
$helpers = array('Ajax', 'Time'); $helpers = array('Ajax', 'Time');
$components = array('Acl', 'Auth'); $components = array('Acl', 'Auth');
$uses = array('Comment', 'User');


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


//fake plugin path //fake plugin path
CakePlugin::load('ControllerTest', array('path' => APP . 'Plugin' . DS . 'ControllerTest' . DS)); CakePlugin::load('ControllerTest', array('path' => APP . 'Plugin' . DS . 'ControllerTest' . DS));
Expand Down
16 changes: 15 additions & 1 deletion lib/Cake/Test/Case/Console/Command/Task/ModelTaskTest.php
Expand Up @@ -283,21 +283,27 @@ public function testFieldValidationGuessing() {


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


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


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


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


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


$result = $this->Task->fieldValidation('test', array('type' => 'boolean', 'length' => 10, 'null' => false)); $result = $this->Task->fieldValidation('test', array('type' => 'boolean', 'length' => 10, 'null' => false));
$expected = array('numeric' => 'numeric'); $expected = array('boolean' => 'boolean');
$this->assertEquals($expected, $result);
} }


/** /**
Expand Down Expand Up @@ -589,6 +595,13 @@ public function testDoAssociationsNonInteractive() {
$model = new Model(array('ds' => 'test', 'name' => 'BakeArticle')); $model = new Model(array('ds' => 'test', 'name' => 'BakeArticle'));
$result = $this->Task->doAssociations($model); $result = $this->Task->doAssociations($model);
$expected = array( $expected = array(
'belongsTo' => array(
array(
'alias' => 'BakeUser',
'className' => 'BakeUser',
'foreignKey' => 'bake_user_id',
),
),
'hasMany' => array( 'hasMany' => array(
array( array(
'alias' => 'BakeComment', 'alias' => 'BakeComment',
Expand All @@ -606,6 +619,7 @@ public function testDoAssociationsNonInteractive() {
), ),
), ),
); );
$this->assertEquals($result, $expected);
} }


/** /**
Expand Down
Expand Up @@ -428,7 +428,6 @@ public function testRespondAs() {
$this->RequestHandler->response->expects($this->at(1))->method('type') $this->RequestHandler->response->expects($this->at(1))->method('type')
->with('text/xml'); ->with('text/xml');


$RequestHandler = $this->getMock('RequestHandlerComponent', array('_header'), array(&$this->Controller->Components));
$result = $this->RequestHandler->respondAs('json'); $result = $this->RequestHandler->respondAs('json');
$this->assertTrue($result); $this->assertTrue($result);
$result = $this->RequestHandler->respondAs('text/xml'); $result = $this->RequestHandler->respondAs('text/xml');
Expand Down
Expand Up @@ -480,7 +480,6 @@ public function testValidatePostNoSession() {
public function testValidatePostFormHacking() { public function testValidatePostFormHacking() {
$this->Controller->Security->startup($this->Controller); $this->Controller->Security->startup($this->Controller);
$key = $this->Controller->params['_Token']['key']; $key = $this->Controller->params['_Token']['key'];
$fields = 'a5475372b40f6e3ccbf9f8af191f20e1642fd877%3AModel.valid';
$unlocked = ''; $unlocked = '';


$this->Controller->request->data = array( $this->Controller->request->data = array(
Expand Down
3 changes: 0 additions & 3 deletions lib/Cake/Test/Case/Controller/ControllerTest.php
Expand Up @@ -490,7 +490,6 @@ public function testLoadModelInPlugins() {
*/ */
public function testConstructClasses() { public function testConstructClasses() {
$request = new CakeRequest('controller_posts/index'); $request = new CakeRequest('controller_posts/index');
$Controller = new Controller($request);


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


$this->assertTrue(isset($Controller->TestPluginPost)); $this->assertTrue(isset($Controller->TestPluginPost));
$this->assertTrue(is_a($Controller->TestPluginPost, 'TestPluginPost')); $this->assertTrue(is_a($Controller->TestPluginPost, 'TestPluginPost'));

unset($Controller);
} }


/** /**
Expand Down
3 changes: 1 addition & 2 deletions lib/Cake/Test/Case/I18n/I18nTest.php
Expand Up @@ -57,13 +57,12 @@ public function tearDown() {
*/ */
public function testTranslationCaching() { public function testTranslationCaching() {
Configure::write('Config.language', 'cache_test_po'); Configure::write('Config.language', 'cache_test_po');
$i18n = I18n::getInstance();


// reset internally stored entries // reset internally stored entries
I18n::clear(); I18n::clear();


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


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


Expand Down
2 changes: 0 additions & 2 deletions lib/Cake/Test/Case/I18n/MultibyteTest.php
Expand Up @@ -8800,7 +8800,6 @@ public function testUsingMbSubstr() {
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);


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


$string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; $string = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ';
$find = 'Ċ';
$result = Multibyte::substr($string, 4, 7); $result = Multibyte::substr($string, 4, 7);
$expected = 'ĈĊČĎĐĒĔ'; $expected = 'ĈĊČĎĐĒĔ';
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Test/Case/Model/Datasource/Database/MysqlTest.php
Expand Up @@ -1142,7 +1142,6 @@ public function testGenerateAssociationQuerySelfJoinWithConditionsInHasOneBindin
$null = null; $null = null;


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


Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Model/ModelDeleteTest.php
Expand Up @@ -636,7 +636,7 @@ public function testDeleteDependent() {
$this->assertEquals(4, $result); $this->assertEquals(4, $result);


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


$result = $Article->Comment->find('count', array( $result = $Article->Comment->find('count', array(
'conditions' => array('Comment.article_id' => 1) 'conditions' => array('Comment.article_id' => 1)
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/Model/ModelReadTest.php
Expand Up @@ -76,7 +76,6 @@ public function testFetchingNonUniqueFKJoinTableRecords() {
* @return void * @return void
*/ */
public function testGroupBy() { public function testGroupBy() {
$db = ConnectionManager::getDataSource('test');
$isStrictGroupBy = $this->db instanceof Postgres || $this->db instanceof Sqlite || $this->db instanceof Oracle || $this->db instanceof Sqlserver; $isStrictGroupBy = $this->db instanceof Postgres || $this->db instanceof Sqlite || $this->db instanceof Oracle || $this->db instanceof Sqlserver;
$message = 'Postgres, Oracle, SQLite and SQL Server have strict GROUP BY and are incompatible with this test.'; $message = 'Postgres, Oracle, SQLite and SQL Server have strict GROUP BY and are incompatible with this test.';


Expand Down Expand Up @@ -6769,6 +6768,7 @@ public function testFindCount() {
$this->db->fullDebug = true; $this->db->fullDebug = true;
$TestModel->order = 'User.id'; $TestModel->order = 'User.id';
$result = $TestModel->find('count'); $result = $TestModel->find('count');
$this->db->fullDebug = $fullDebug;
$this->assertEquals($result, 4); $this->assertEquals($result, 4);


$log = $this->db->getLog(); $log = $this->db->getLog();
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/Case/Network/CakeSocketTest.php
Expand Up @@ -181,6 +181,7 @@ public function testTimeOutConnection() {
$this->assertTrue($this->Socket->connect()); $this->assertTrue($this->Socket->connect());


$config = array('host' => '127.0.0.1', 'timeout' => 0.00001); $config = array('host' => '127.0.0.1', 'timeout' => 0.00001);
$this->Socket = new CakeSocket($config);
$this->assertFalse($this->Socket->read(1024 * 1024)); $this->assertFalse($this->Socket->read(1024 * 1024));
$this->assertEquals($this->Socket->lastError(), '2: ' . __d('cake_dev', 'Connection timed out')); $this->assertEquals($this->Socket->lastError(), '2: ' . __d('cake_dev', 'Connection timed out'));
} }
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Test/Case/Routing/RouterTest.php
Expand Up @@ -969,7 +969,8 @@ public function testUrlParsing() {
Router::reload(); Router::reload();
Router::connect('/page/*', array('controller' => 'test')); Router::connect('/page/*', array('controller' => 'test'));
$result = Router::parse('/page/my-page'); $result = Router::parse('/page/my-page');
$expected = array('pass' => array('my-page'), 'plugin' => null, 'controller' => 'test', 'action' => 'index'); $expected = array('pass' => array('my-page'), 'plugin' => null, 'controller' => 'test', 'action' => 'index', 'named' => array());
$this->assertEquals($expected, $result);


Router::reload(); Router::reload();
Router::connect('/:language/contact', array('language' => 'eng', 'plugin' => 'contact', 'controller' => 'contact', 'action' => 'index'), array('language' => '[a-z]{3}')); Router::connect('/:language/contact', array('language' => 'eng', 'plugin' => 'contact', 'controller' => 'contact', 'action' => 'index'), array('language' => '[a-z]{3}'));
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/Test/Case/TestSuite/CakeTestSuiteTest.php
Expand Up @@ -60,7 +60,7 @@ public function testAddTestDirectory() {
* *
* @return void * @return void
*/ */
public function testAddTestDirectoryRecursive() {return; public function testAddTestDirectoryRecursive() {
$testFolder = CORE_TEST_CASES . DS . 'Cache'; $testFolder = CORE_TEST_CASES . DS . 'Cache';
$count = count(glob($testFolder . DS . '*Test.php')); $count = count(glob($testFolder . DS . '*Test.php'));
$count += count(glob($testFolder . DS . 'Engine' . DS . '*Test.php')); $count += count(glob($testFolder . DS . 'Engine' . DS . '*Test.php'));
Expand Down
3 changes: 2 additions & 1 deletion lib/Cake/Test/Case/View/Helper/PaginatorHelperTest.php
Expand Up @@ -2140,8 +2140,9 @@ public function testWithPlugin() {
$this->Paginator->options(array('url' => array('plugin' => null))); $this->Paginator->options(array('url' => array('plugin' => null)));
$result = $this->Paginator->link('Page 3', array('page' => 3)); $result = $this->Paginator->link('Page 3', array('page' => 3));
$expected = array( $expected = array(
'a' => array('/magazines/index/page:3'), 'Page 3', '/a' 'a' => array('href' => '/magazines/index/page:3'), 'Page 3', '/a'
); );
$this->assertTags($result, $expected);


$this->Paginator->options(array('url' => array('plugin' => null, 'controller' => 'issues'))); $this->Paginator->options(array('url' => array('plugin' => null, 'controller' => 'issues')));
$result = $this->Paginator->link('Page 3', array('page' => 3)); $result = $this->Paginator->link('Page 3', array('page' => 3));
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/Test/Case/View/Helper/SessionHelperTest.php
Expand Up @@ -168,6 +168,7 @@ public function testFlashElementInAttrs() {
'params' => array('title' => 'Notice!', 'name' => 'Alert!') 'params' => array('title' => 'Notice!', 'name' => 'Alert!')
)); ));
$expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a calling</p>\n</div>"; $expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a calling</p>\n</div>";
$this->assertEquals($expected, $result);
} }


/** /**
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Test/Case/View/MediaViewTest.php
Expand Up @@ -35,7 +35,6 @@ class MediaViewTest extends CakeTestCase {
*/ */
public function setUp() { public function setUp() {
parent::setUp(); parent::setUp();
$controller = new Controller();
$this->MediaView = $this->getMock('MediaView', array('_isActive', '_clearBuffer', '_flushBuffer')); $this->MediaView = $this->getMock('MediaView', array('_isActive', '_clearBuffer', '_flushBuffer'));
$this->MediaView->response = $this->getMock('CakeResponse'); $this->MediaView->response = $this->getMock('CakeResponse');
} }
Expand Down
1 change: 0 additions & 1 deletion lib/Cake/Test/Case/View/ViewTest.php
Expand Up @@ -1082,7 +1082,6 @@ public function testRenderCache() {
$View->renderCache($path, '+1 second'); $View->renderCache($path, '+1 second');
$result = ob_get_clean(); $result = ob_get_clean();


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


@unlink($path); @unlink($path);
Expand Down