mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
fixing broken tests: updating fullTableName() use
At the same time, reversing arguments since phpunit wants 'expected' as the first parameter.
This commit is contained in:
parent
c4cbf1c635
commit
1f7c292651
6 changed files with 53 additions and 50 deletions
|
@ -660,7 +660,7 @@ class MysqlTest extends CakeTestCase {
|
|||
$this->assertContains('COLLATE=utf8_general_ci', $result);
|
||||
|
||||
$this->Dbo->rawQuery($result);
|
||||
$result = $this->Dbo->listDetailedSources($this->Dbo->fullTableName('altertest', false));
|
||||
$result = $this->Dbo->listDetailedSources($this->Dbo->fullTableName('altertest', false, false));
|
||||
$this->assertEquals($result['Collation'], 'utf8_general_ci');
|
||||
$this->assertEquals($result['Engine'], 'InnoDB');
|
||||
$this->assertEquals($result['charset'], 'utf8');
|
||||
|
@ -712,7 +712,7 @@ class MysqlTest extends CakeTestCase {
|
|||
$tableName = 'tinyint_' . uniqid();
|
||||
$table = $this->Dbo->fullTableName($tableName);
|
||||
$this->Dbo->rawQuery('CREATE TABLE ' . $table . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;');
|
||||
$result = $this->Dbo->readTableParameters($this->Dbo->fullTableName($tableName, false));
|
||||
$result = $this->Dbo->readTableParameters($this->Dbo->fullTableName($tableName, false, false));
|
||||
$this->Dbo->rawQuery('DROP TABLE ' . $table);
|
||||
$expected = array(
|
||||
'charset' => 'utf8',
|
||||
|
@ -722,7 +722,7 @@ class MysqlTest extends CakeTestCase {
|
|||
|
||||
$table = $this->Dbo->fullTableName($tableName);
|
||||
$this->Dbo->rawQuery('CREATE TABLE ' . $table . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id)) ENGINE=MyISAM DEFAULT CHARSET=cp1250 COLLATE=cp1250_general_ci;');
|
||||
$result = $this->Dbo->readTableParameters($this->Dbo->fullTableName($tableName, false));
|
||||
$result = $this->Dbo->readTableParameters($this->Dbo->fullTableName($tableName, false, false));
|
||||
$this->Dbo->rawQuery('DROP TABLE ' . $table);
|
||||
$expected = array(
|
||||
'charset' => 'cp1250',
|
||||
|
@ -875,7 +875,7 @@ class MysqlTest extends CakeTestCase {
|
|||
$this->assertEquals(array(), $result, 'Should be empty when table does not exist.');
|
||||
|
||||
$result = $this->Dbo->listDetailedSources();
|
||||
$tableName = $this->Dbo->fullTableName('apples', false);
|
||||
$tableName = $this->Dbo->fullTableName('apples', false, false);
|
||||
$this->assertTrue(isset($result[$tableName]), 'Key should exist');
|
||||
}
|
||||
|
||||
|
@ -928,7 +928,7 @@ class MysqlTest extends CakeTestCase {
|
|||
$this->assertEquals($result, array('`Article`.`id`'));
|
||||
|
||||
$test->expects($this->at(0))->method('execute')
|
||||
->with('SELECT `Article`.`id` FROM `articles` AS `Article` WHERE 1 = 1');
|
||||
->with('SELECT `Article`.`id` FROM ' . $test->fullTableName('articles'). ' AS `Article` WHERE 1 = 1');
|
||||
|
||||
$result = $test->read($this->Model, array(
|
||||
'fields' => $this->Model->escapeField(),
|
||||
|
@ -944,7 +944,7 @@ class MysqlTest extends CakeTestCase {
|
|||
$this->assertEquals($result, array('[Article].[id]'));
|
||||
|
||||
$test->expects($this->at(0))->method('execute')
|
||||
->with('SELECT [Article].[id] FROM [' . $test->fullTableName('articles', false) . '] AS [Article] WHERE 1 = 1');
|
||||
->with('SELECT [Article].[id] FROM ' . $test->fullTableName('articles') . ' AS [Article] WHERE 1 = 1');
|
||||
$result = $test->read($this->Model, array(
|
||||
'fields' => $this->Model->escapeField(),
|
||||
'conditions' => null,
|
||||
|
@ -1017,7 +1017,7 @@ class MysqlTest extends CakeTestCase {
|
|||
),
|
||||
'joins' => array(
|
||||
array(
|
||||
'table' => '`test_model4`',
|
||||
'table' => $this->Dbo->fullTableName($this->Model),
|
||||
'alias' => 'TestModel4Parent',
|
||||
'type' => 'LEFT',
|
||||
'conditions' => '`TestModel4`.`parent_id` = `TestModel4Parent`.`id`'
|
||||
|
@ -1106,11 +1106,13 @@ class MysqlTest extends CakeTestCase {
|
|||
->method('getDataSource')
|
||||
->will($this->returnValue($test));
|
||||
|
||||
$testModel8Table = $this->Model->TestModel8->getDataSource()->fullTableName($this->Model->TestModel8);
|
||||
|
||||
$test->expects($this->at(0))->method('execute')
|
||||
->with($this->stringContains('`TestModel9` LEFT JOIN `test_model8`'));
|
||||
->with($this->stringContains('`TestModel9` LEFT JOIN ' . $testModel8Table));
|
||||
|
||||
$test->expects($this->at(1))->method('execute')
|
||||
->with($this->stringContains('TestModel9` INNER JOIN `test_model8`'));
|
||||
->with($this->stringContains('TestModel9` INNER JOIN ' . $testModel8Table));
|
||||
|
||||
$test->read($this->Model, array('recursive' => 1));
|
||||
$this->Model->belongsTo['TestModel8']['type'] = 'INNER';
|
||||
|
@ -2914,10 +2916,11 @@ class MysqlTest extends CakeTestCase {
|
|||
->with('harry')
|
||||
->will($this->returnValue("'harry'"));
|
||||
|
||||
$modelTable = $this->Dbo->fullTableName($this->Model);
|
||||
$this->Dbo->expects($this->at(1))->method('execute')
|
||||
->with('SELECT COUNT(`TestModel`.`id`) AS count FROM `test_models` AS `TestModel` WHERE `TestModel`.`name` = \'harry\'');
|
||||
->with('SELECT COUNT(`TestModel`.`id`) AS count FROM ' .$modelTable. ' AS `TestModel` WHERE `TestModel`.`name` = \'harry\'');
|
||||
$this->Dbo->expects($this->at(2))->method('execute')
|
||||
->with('SELECT COUNT(`TestModel`.`id`) AS count FROM `test_models` AS `TestModel` WHERE 1 = 1');
|
||||
->with('SELECT COUNT(`TestModel`.`id`) AS count FROM ' .$modelTable. ' AS `TestModel` WHERE 1 = 1');
|
||||
|
||||
$this->Dbo->hasAny($this->Model, array('TestModel.name' => 'harry'));
|
||||
$this->Dbo->hasAny($this->Model, array());
|
||||
|
@ -2933,7 +2936,7 @@ class MysqlTest extends CakeTestCase {
|
|||
$this->loadFixtures('Article', 'Comment', 'Tag');
|
||||
$this->Dbo->virtualFieldSeparator = '__';
|
||||
$Article = ClassRegistry::init('Article');
|
||||
$commentsTable = $this->Dbo->fullTableName('comments', false);
|
||||
$commentsTable = $this->Dbo->fullTableName('comments', false, false);
|
||||
$Article->virtualFields = array(
|
||||
'this_moment' => 'NOW()',
|
||||
'two' => '1 + 1',
|
||||
|
@ -3003,7 +3006,7 @@ class MysqlTest extends CakeTestCase {
|
|||
*/
|
||||
public function testVirtualFieldsInConditions() {
|
||||
$Article = ClassRegistry::init('Article');
|
||||
$commentsTable = $this->Dbo->fullTableName('comments', false);
|
||||
$commentsTable = $this->Dbo->fullTableName('comments', false, false);
|
||||
|
||||
$Article->virtualFields = array(
|
||||
'this_moment' => 'NOW()',
|
||||
|
@ -3062,7 +3065,7 @@ class MysqlTest extends CakeTestCase {
|
|||
*/
|
||||
public function testVirtualFieldsInCalculate() {
|
||||
$Article = ClassRegistry::init('Article');
|
||||
$commentsTable = $this->Dbo->fullTableName('comments', false);
|
||||
$commentsTable = $this->Dbo->fullTableName('comments', false, false);
|
||||
$Article->virtualFields = array(
|
||||
'this_moment' => 'NOW()',
|
||||
'two' => '1 + 1',
|
||||
|
@ -3393,7 +3396,7 @@ class MysqlTest extends CakeTestCase {
|
|||
$this->assertTrue(!empty($result));
|
||||
|
||||
$result = $this->Dbo->fetchRow($result);
|
||||
$expected = array($this->Dbo->fullTableName('apples', false) => array(
|
||||
$expected = array($this->Dbo->fullTableName('apples', false, false) => array(
|
||||
'color' => 'Red 1',
|
||||
'name' => 'Red Apple 1'
|
||||
));
|
||||
|
@ -3401,17 +3404,17 @@ class MysqlTest extends CakeTestCase {
|
|||
|
||||
$result = $this->Dbo->fetchAll('SELECT name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id');
|
||||
$expected = array(
|
||||
array($this->Dbo->fullTableName('apples', false) => array('name' => 'Red Apple 1')),
|
||||
array($this->Dbo->fullTableName('apples', false) => array('name' => 'Bright Red Apple')),
|
||||
array($this->Dbo->fullTableName('apples', false) => array('name' => 'green blue')),
|
||||
array($this->Dbo->fullTableName('apples', false) => array('name' => 'Test Name')),
|
||||
array($this->Dbo->fullTableName('apples', false) => array('name' => 'Blue Green')),
|
||||
array($this->Dbo->fullTableName('apples', false) => array('name' => 'My new apple')),
|
||||
array($this->Dbo->fullTableName('apples', false) => array('name' => 'Some odd color'))
|
||||
array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Red Apple 1')),
|
||||
array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Bright Red Apple')),
|
||||
array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'green blue')),
|
||||
array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Test Name')),
|
||||
array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Blue Green')),
|
||||
array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'My new apple')),
|
||||
array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Some odd color'))
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$result = $this->Dbo->field($this->Dbo->fullTableName('apples', false), 'SELECT color, name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id');
|
||||
$result = $this->Dbo->field($this->Dbo->fullTableName('apples', false, false), 'SELECT color, name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id');
|
||||
$expected = array(
|
||||
'color' => 'Red 1',
|
||||
'name' => 'Red Apple 1'
|
||||
|
|
|
@ -566,7 +566,7 @@ class PostgresTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testIndexGeneration() {
|
||||
$name = $this->Dbo->fullTableName('index_test', false);
|
||||
$name = $this->Dbo->fullTableName('index_test', false, false);
|
||||
$this->Dbo->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )');
|
||||
$this->Dbo->query('CREATE INDEX pointless_bool ON ' . $name . '("bool")');
|
||||
$this->Dbo->query('CREATE UNIQUE INDEX char_index ON ' . $name . '("small_char")');
|
||||
|
@ -579,7 +579,7 @@ class PostgresTest extends CakeTestCase {
|
|||
$this->Dbo->query('DROP TABLE ' . $name);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
$name = $this->Dbo->fullTableName('index_test_2', false);
|
||||
$name = $this->Dbo->fullTableName('index_test_2', false, false);
|
||||
$this->Dbo->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )');
|
||||
$this->Dbo->query('CREATE UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")');
|
||||
$expected = array(
|
||||
|
|
|
@ -128,7 +128,7 @@ class SqliteTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testIndex() {
|
||||
$name = $this->Dbo->fullTableName('with_a_key');
|
||||
$name = $this->Dbo->fullTableName('with_a_key', false, false);
|
||||
$this->Dbo->query('CREATE TABLE ' . $name . ' ("id" int(11) PRIMARY KEY, "bool" int(1), "small_char" varchar(50), "description" varchar(40) );');
|
||||
$this->Dbo->query('CREATE INDEX pointless_bool ON ' . $name . '("bool")');
|
||||
$this->Dbo->query('CREATE UNIQUE INDEX char_index ON ' . $name . '("small_char")');
|
||||
|
|
|
@ -697,16 +697,16 @@ class DboSourceTest extends CakeTestCase {
|
|||
*/
|
||||
public function testFullTablePermutations() {
|
||||
$Article = ClassRegistry::init('Article');
|
||||
$result = $this->testDb->fullTableName($Article, false);
|
||||
$result = $this->testDb->fullTableName($Article, false, false);
|
||||
$this->assertEquals($result, 'articles');
|
||||
|
||||
$Article->tablePrefix = 'tbl_';
|
||||
$result = $this->testDb->fullTableName($Article, false);
|
||||
$result = $this->testDb->fullTableName($Article, false, false);
|
||||
$this->assertEquals($result, 'tbl_articles');
|
||||
|
||||
$Article->useTable = $Article->table = 'with spaces';
|
||||
$Article->tablePrefix = '';
|
||||
$result = $this->testDb->fullTableName($Article);
|
||||
$result = $this->testDb->fullTableName($Article, true, false);
|
||||
$this->assertEquals($result, '`with spaces`');
|
||||
}
|
||||
|
||||
|
|
|
@ -944,39 +944,39 @@ class ModelIntegrationTest extends BaseModelTest {
|
|||
|
||||
$TestModel = new Apple();
|
||||
$TestModel->setDataSource('database1');
|
||||
$this->assertEquals($this->db->fullTableName($TestModel, false), 'aaa_apples');
|
||||
$this->assertEquals($db1->fullTableName($TestModel, false), 'aaa_apples');
|
||||
$this->assertEquals($db2->fullTableName($TestModel, false), 'aaa_apples');
|
||||
$this->assertContains('aaa_apples', $this->db->fullTableName($TestModel));
|
||||
$this->assertContains('aaa_apples', $db1->fullTableName($TestModel));
|
||||
$this->assertContains('aaa_apples', $db2->fullTableName($TestModel));
|
||||
|
||||
$TestModel->setDataSource('database2');
|
||||
$this->assertEquals($this->db->fullTableName($TestModel, false), 'bbb_apples');
|
||||
$this->assertEquals($db1->fullTableName($TestModel, false), 'bbb_apples');
|
||||
$this->assertEquals($db2->fullTableName($TestModel, false), 'bbb_apples');
|
||||
$this->assertContains('bbb_apples', $this->db->fullTableName($TestModel));
|
||||
$this->assertContains('bbb_apples', $db1->fullTableName($TestModel));
|
||||
$this->assertContains('bbb_apples', $db2->fullTableName($TestModel));
|
||||
|
||||
$TestModel = new Apple();
|
||||
$TestModel->tablePrefix = 'custom_';
|
||||
$this->assertEquals($this->db->fullTableName($TestModel, false), 'custom_apples');
|
||||
$this->assertContains('custom_apples', $this->db->fullTableName($TestModel));
|
||||
$TestModel->setDataSource('database1');
|
||||
$this->assertEquals($this->db->fullTableName($TestModel, false), 'custom_apples');
|
||||
$this->assertEquals($db1->fullTableName($TestModel, false), 'custom_apples');
|
||||
$this->assertContains('custom_apples', $this->db->fullTableName($TestModel));
|
||||
$this->assertContains('custom_apples', $db1->fullTableName($TestModel));
|
||||
|
||||
$TestModel = new Apple();
|
||||
$TestModel->setDataSource('database1');
|
||||
$this->assertEquals($this->db->fullTableName($TestModel, false), 'aaa_apples');
|
||||
$this->assertContains('aaa_apples', $this->db->fullTableName($TestModel));
|
||||
$TestModel->tablePrefix = '';
|
||||
$TestModel->setDataSource('database2');
|
||||
$this->assertEquals($db2->fullTableName($TestModel, false), 'apples');
|
||||
$this->assertEquals($db1->fullTableName($TestModel, false), 'apples');
|
||||
$this->assertContains('apples', $db2->fullTableName($TestModel));
|
||||
$this->assertContains('apples', $db1->fullTableName($TestModel));
|
||||
|
||||
$TestModel->tablePrefix = null;
|
||||
$TestModel->setDataSource('database1');
|
||||
$this->assertEquals($db2->fullTableName($TestModel, false), 'aaa_apples');
|
||||
$this->assertEquals($db1->fullTableName($TestModel, false), 'aaa_apples');
|
||||
$this->assertContains('aaa_apples', $db2->fullTableName($TestModel));
|
||||
$this->assertContains('aaa_apples', $db1->fullTableName($TestModel));
|
||||
|
||||
$TestModel->tablePrefix = false;
|
||||
$TestModel->setDataSource('database2');
|
||||
$this->assertEquals($db2->fullTableName($TestModel, false), 'apples');
|
||||
$this->assertEquals($db1->fullTableName($TestModel, false), 'apples');
|
||||
$this->assertContains('apples', $db2->fullTableName($TestModel));
|
||||
$this->assertContains('apples', $db1->fullTableName($TestModel));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -282,13 +282,13 @@ class ModelReadTest extends BaseModelTest {
|
|||
$result = $Article->query($query, $params);
|
||||
$expected = array(
|
||||
'0' => array(
|
||||
$this->db->fullTableName('articles', false) => array(
|
||||
$this->db->fullTableName('articles', false, false) => array(
|
||||
'title' => 'First Article', 'published' => 'Y')
|
||||
));
|
||||
|
||||
if (isset($result[0][0])) {
|
||||
$expected[0][0] = $expected[0][$this->db->fullTableName('articles', false)];
|
||||
unset($expected[0][$this->db->fullTableName('articles', false)]);
|
||||
$expected[0][0] = $expected[0][$this->db->fullTableName('articles', false, false)];
|
||||
unset($expected[0][$this->db->fullTableName('articles', false, false)]);
|
||||
}
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
|
@ -303,7 +303,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
$result = $Article->query($query, $params, false);
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertTrue(
|
||||
isset($result[0][$this->db->fullTableName('articles', false)])
|
||||
isset($result[0][$this->db->fullTableName('articles', false, false)])
|
||||
|| isset($result[0][0])
|
||||
);
|
||||
$result = $this->db->getQueryCache($query, $params);
|
||||
|
@ -317,7 +317,7 @@ class ModelReadTest extends BaseModelTest {
|
|||
$result = $Article->query($query, $params);
|
||||
$this->assertTrue(is_array($result));
|
||||
$this->assertTrue(
|
||||
isset($result[0][$this->db->fullTableName('articles', false)]['title'])
|
||||
isset($result[0][$this->db->fullTableName('articles', false, false)]['title'])
|
||||
|| isset($result[0][0]['title'])
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue