mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 19:38:26 +00:00
0a53242e3e
$expected is the first argument. Now certain test results start to make sense: 1) MultibyteTest::testUsingMbStrtolower Failed asserting that two strings are equal. --- Expected +++ Actual @@ @@ -ႠႡႢႣႤႥႦႧႨႩႪႫႬႭႮႯႰႱႲႳႴႵႶႷႸႹႺႻႼႽႾႿჀჁჂჃჄჅ +ⴀⴁⴂⴃⴄⴅⴆⴇⴈⴉⴊⴋⴌⴍⴎⴏⴐⴑⴒⴓⴔⴕⴖⴗⴘⴙⴚⴛⴜⴝⴞⴟⴠⴡⴢⴣⴤⴥ
3411 lines
133 KiB
PHP
3411 lines
133 KiB
PHP
<?php
|
||
/**
|
||
* DboMysqlTest file
|
||
*
|
||
* PHP 5
|
||
*
|
||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||
*
|
||
* Licensed under The MIT License
|
||
* Redistributions of files must retain the above copyright notice.
|
||
*
|
||
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||
* @link http://cakephp.org CakePHP(tm) Project
|
||
* @package cake.libs
|
||
* @since CakePHP(tm) v 1.2.0
|
||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||
*/
|
||
App::uses('Model', 'Model');
|
||
App::uses('AppModel', 'Model');
|
||
App::uses('Mysql', 'Model/Datasource/Database');
|
||
App::uses('CakeSchema', 'Model');
|
||
|
||
require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php';
|
||
|
||
/**
|
||
* DboMysqlTest class
|
||
*
|
||
* @package cake.tests.cases.libs.model.datasources.dbo
|
||
*/
|
||
class DboMysqlTest extends CakeTestCase {
|
||
/**
|
||
* autoFixtures property
|
||
*
|
||
* @var bool false
|
||
* @access public
|
||
*/
|
||
public $autoFixtures = false;
|
||
|
||
/**
|
||
* fixtures property
|
||
*
|
||
* @var array
|
||
* @access public
|
||
*/
|
||
public $fixtures = array(
|
||
'core.apple', 'core.article', 'core.articles_tag', 'core.attachment', 'core.comment',
|
||
'core.sample', 'core.tag', 'core.user', 'core.post', 'core.author', 'core.data_test',
|
||
'core.binary_test'
|
||
);
|
||
|
||
/**
|
||
* The Dbo instance to be tested
|
||
*
|
||
* @var DboSource
|
||
* @access public
|
||
*/
|
||
public $Dbo = null;
|
||
|
||
/**
|
||
* Sets up a Dbo class instance for testing
|
||
*
|
||
*/
|
||
public function setUp() {
|
||
$this->Dbo = ConnectionManager::getDataSource('test');
|
||
if (!($this->Dbo instanceof Mysql)) {
|
||
$this->markTestSkipped('The MySQL extension is not available.');
|
||
}
|
||
$this->_debug = Configure::read('debug');
|
||
Configure::write('debug', 1);
|
||
$this->model = new MysqlTestModel();
|
||
}
|
||
|
||
/**
|
||
* Sets up a Dbo class instance for testing
|
||
*
|
||
*/
|
||
public function tearDown() {
|
||
unset($this->model);
|
||
ClassRegistry::flush();
|
||
Configure::write('debug', $this->_debug);
|
||
}
|
||
|
||
/**
|
||
* Test Dbo value method
|
||
*
|
||
* @group quoting
|
||
*/
|
||
public function testQuoting() {
|
||
$result = $this->Dbo->fields($this->model);
|
||
$expected = array(
|
||
'`MysqlTestModel`.`id`',
|
||
'`MysqlTestModel`.`client_id`',
|
||
'`MysqlTestModel`.`name`',
|
||
'`MysqlTestModel`.`login`',
|
||
'`MysqlTestModel`.`passwd`',
|
||
'`MysqlTestModel`.`addr_1`',
|
||
'`MysqlTestModel`.`addr_2`',
|
||
'`MysqlTestModel`.`zip_code`',
|
||
'`MysqlTestModel`.`city`',
|
||
'`MysqlTestModel`.`country`',
|
||
'`MysqlTestModel`.`phone`',
|
||
'`MysqlTestModel`.`fax`',
|
||
'`MysqlTestModel`.`url`',
|
||
'`MysqlTestModel`.`email`',
|
||
'`MysqlTestModel`.`comments`',
|
||
'`MysqlTestModel`.`last_login`',
|
||
'`MysqlTestModel`.`created`',
|
||
'`MysqlTestModel`.`updated`'
|
||
);
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$expected = 1.2;
|
||
$result = $this->Dbo->value(1.2, 'float');
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$expected = "'1,2'";
|
||
$result = $this->Dbo->value('1,2', 'float');
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$expected = "'4713e29446'";
|
||
$result = $this->Dbo->value('4713e29446');
|
||
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$expected = 'NULL';
|
||
$result = $this->Dbo->value('', 'integer');
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$expected = "'0'";
|
||
$result = $this->Dbo->value('', 'boolean');
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$expected = 10010001;
|
||
$result = $this->Dbo->value(10010001);
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$expected = "'00010010001'";
|
||
$result = $this->Dbo->value('00010010001');
|
||
$this->assertEqual($expected, $result);
|
||
}
|
||
|
||
/**
|
||
* test that localized floats don't cause trouble.
|
||
*
|
||
* @group quoting
|
||
* @return void
|
||
*/
|
||
function testLocalizedFloats() {
|
||
$this->skipIf(DS === '\\', 'The locale is not supported in Windows and affect the others tests.');
|
||
|
||
$restore = setlocale(LC_ALL, null);
|
||
setlocale(LC_ALL, 'de_DE');
|
||
|
||
$result = $this->Dbo->value(3.141593, 'float');
|
||
$this->assertEqual((string)$result, '3.141593');
|
||
|
||
$result = $this->Dbo->value(3.141593);
|
||
$this->assertEqual((string)$result, '3.141593');
|
||
|
||
setlocale(LC_ALL, $restore);
|
||
}
|
||
|
||
/**
|
||
* testTinyintCasting method
|
||
*
|
||
*
|
||
* @return void
|
||
*/
|
||
function testTinyintCasting() {
|
||
$this->Dbo->cacheSources = false;
|
||
$tableName = 'tinyint_' . uniqid();
|
||
$this->Dbo->rawQuery('CREATE TABLE ' . $this->Dbo->fullTableName($tableName) . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
|
||
|
||
$this->model = new CakeTestModel(array(
|
||
'name' => 'Tinyint', 'table' => $tableName, 'ds' => 'test'
|
||
));
|
||
|
||
$result = $this->model->schema();
|
||
$this->assertEqual($result['bool']['type'], 'boolean');
|
||
$this->assertEqual($result['small_int']['type'], 'integer');
|
||
|
||
$this->assertTrue((bool)$this->model->save(array('bool' => 5, 'small_int' => 5)));
|
||
$result = $this->model->find('first');
|
||
$this->assertIdentical($result['Tinyint']['bool'], true);
|
||
$this->assertIdentical($result['Tinyint']['small_int'], '5');
|
||
$this->model->deleteAll(true);
|
||
|
||
$this->assertTrue((bool)$this->model->save(array('bool' => 0, 'small_int' => 100)));
|
||
$result = $this->model->find('first');
|
||
$this->assertIdentical($result['Tinyint']['bool'], false);
|
||
$this->assertIdentical($result['Tinyint']['small_int'], '100');
|
||
$this->model->deleteAll(true);
|
||
|
||
$this->assertTrue((bool)$this->model->save(array('bool' => true, 'small_int' => 0)));
|
||
$result = $this->model->find('first');
|
||
$this->assertIdentical($result['Tinyint']['bool'], true);
|
||
$this->assertIdentical($result['Tinyint']['small_int'], '0');
|
||
$this->model->deleteAll(true);
|
||
|
||
$this->Dbo->rawQuery('DROP TABLE ' . $this->Dbo->fullTableName($tableName));
|
||
}
|
||
|
||
/**
|
||
* testIndexDetection method
|
||
*
|
||
* @group indices
|
||
* @return void
|
||
*/
|
||
public function testIndexDetection() {
|
||
$this->Dbo->cacheSources = false;
|
||
|
||
$name = $this->Dbo->fullTableName('simple');
|
||
$this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id));');
|
||
$expected = array('PRIMARY' => array('column' => 'id', 'unique' => 1));
|
||
$result = $this->Dbo->index('simple', false);
|
||
$this->Dbo->rawQuery('DROP TABLE ' . $name);
|
||
$this->assertEqual($expected, $result);
|
||
|
||
|
||
$name = $this->Dbo->fullTableName('with_a_key');
|
||
$this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ));');
|
||
$expected = array(
|
||
'PRIMARY' => array('column' => 'id', 'unique' => 1),
|
||
'pointless_bool' => array('column' => 'bool', 'unique' => 0),
|
||
);
|
||
$result = $this->Dbo->index('with_a_key', false);
|
||
$this->Dbo->rawQuery('DROP TABLE ' . $name);
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$name = $this->Dbo->fullTableName('with_two_keys');
|
||
$this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ));');
|
||
$expected = array(
|
||
'PRIMARY' => array('column' => 'id', 'unique' => 1),
|
||
'pointless_bool' => array('column' => 'bool', 'unique' => 0),
|
||
'pointless_small_int' => array('column' => 'small_int', 'unique' => 0),
|
||
);
|
||
$result = $this->Dbo->index('with_two_keys', false);
|
||
$this->Dbo->rawQuery('DROP TABLE ' . $name);
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$name = $this->Dbo->fullTableName('with_compound_keys');
|
||
$this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ), KEY `one_way` ( `bool`, `small_int` ));');
|
||
$expected = array(
|
||
'PRIMARY' => array('column' => 'id', 'unique' => 1),
|
||
'pointless_bool' => array('column' => 'bool', 'unique' => 0),
|
||
'pointless_small_int' => array('column' => 'small_int', 'unique' => 0),
|
||
'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0),
|
||
);
|
||
$result = $this->Dbo->index('with_compound_keys', false);
|
||
$this->Dbo->rawQuery('DROP TABLE ' . $name);
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$name = $this->Dbo->fullTableName('with_multiple_compound_keys');
|
||
$this->Dbo->rawQuery('CREATE TABLE ' . $name . ' (id int(11) AUTO_INCREMENT, bool tinyint(1), small_int tinyint(2), primary key(id), KEY `pointless_bool` ( `bool` ), KEY `pointless_small_int` ( `small_int` ), KEY `one_way` ( `bool`, `small_int` ), KEY `other_way` ( `small_int`, `bool` ));');
|
||
$expected = array(
|
||
'PRIMARY' => array('column' => 'id', 'unique' => 1),
|
||
'pointless_bool' => array('column' => 'bool', 'unique' => 0),
|
||
'pointless_small_int' => array('column' => 'small_int', 'unique' => 0),
|
||
'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0),
|
||
'other_way' => array('column' => array('small_int', 'bool'), 'unique' => 0),
|
||
);
|
||
$result = $this->Dbo->index('with_multiple_compound_keys', false);
|
||
$this->Dbo->rawQuery('DROP TABLE ' . $name);
|
||
$this->assertEqual($expected, $result);
|
||
}
|
||
|
||
/**
|
||
* testBuildColumn method
|
||
*
|
||
* @return void
|
||
*/
|
||
function testBuildColumn() {
|
||
$restore = $this->Dbo->columns;
|
||
$this->Dbo->columns = array('varchar(255)' => 1);
|
||
$data = array(
|
||
'name' => 'testName',
|
||
'type' => 'varchar(255)',
|
||
'default',
|
||
'null' => true,
|
||
'key',
|
||
'comment' => 'test'
|
||
);
|
||
$result = $this->Dbo->buildColumn($data);
|
||
$expected = '`testName` DEFAULT NULL COMMENT \'test\'';
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$data = array(
|
||
'name' => 'testName',
|
||
'type' => 'varchar(255)',
|
||
'default',
|
||
'null' => true,
|
||
'key',
|
||
'charset' => 'utf8',
|
||
'collate' => 'utf8_unicode_ci'
|
||
);
|
||
$result = $this->Dbo->buildColumn($data);
|
||
$expected = '`testName` CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL';
|
||
$this->assertEqual($expected, $result);
|
||
$this->Dbo->columns = $restore;
|
||
}
|
||
|
||
/**
|
||
* MySQL 4.x returns index data in a different format,
|
||
* Using a mock ensure that MySQL 4.x output is properly parsed.
|
||
*
|
||
* @group indices
|
||
* @return void
|
||
*/
|
||
function testIndexOnMySQL4Output() {
|
||
$name = $this->Dbo->fullTableName('simple');
|
||
|
||
$mockDbo = $this->getMock('Mysql', array('connect', '_execute', 'getVersion'));
|
||
$columnData = array(
|
||
array('0' => array(
|
||
'Table' => 'with_compound_keys',
|
||
'Non_unique' => '0',
|
||
'Key_name' => 'PRIMARY',
|
||
'Seq_in_index' => '1',
|
||
'Column_name' => 'id',
|
||
'Collation' => 'A',
|
||
'Cardinality' => '0',
|
||
'Sub_part' => NULL,
|
||
'Packed' => NULL,
|
||
'Null' => '',
|
||
'Index_type' => 'BTREE',
|
||
'Comment' => ''
|
||
)),
|
||
array('0' => array(
|
||
'Table' => 'with_compound_keys',
|
||
'Non_unique' => '1',
|
||
'Key_name' => 'pointless_bool',
|
||
'Seq_in_index' => '1',
|
||
'Column_name' => 'bool',
|
||
'Collation' => 'A',
|
||
'Cardinality' => NULL,
|
||
'Sub_part' => NULL,
|
||
'Packed' => NULL,
|
||
'Null' => 'YES',
|
||
'Index_type' => 'BTREE',
|
||
'Comment' => ''
|
||
)),
|
||
array('0' => array(
|
||
'Table' => 'with_compound_keys',
|
||
'Non_unique' => '1',
|
||
'Key_name' => 'pointless_small_int',
|
||
'Seq_in_index' => '1',
|
||
'Column_name' => 'small_int',
|
||
'Collation' => 'A',
|
||
'Cardinality' => NULL,
|
||
'Sub_part' => NULL,
|
||
'Packed' => NULL,
|
||
'Null' => 'YES',
|
||
'Index_type' => 'BTREE',
|
||
'Comment' => ''
|
||
)),
|
||
array('0' => array(
|
||
'Table' => 'with_compound_keys',
|
||
'Non_unique' => '1',
|
||
'Key_name' => 'one_way',
|
||
'Seq_in_index' => '1',
|
||
'Column_name' => 'bool',
|
||
'Collation' => 'A',
|
||
'Cardinality' => NULL,
|
||
'Sub_part' => NULL,
|
||
'Packed' => NULL,
|
||
'Null' => 'YES',
|
||
'Index_type' => 'BTREE',
|
||
'Comment' => ''
|
||
)),
|
||
array('0' => array(
|
||
'Table' => 'with_compound_keys',
|
||
'Non_unique' => '1',
|
||
'Key_name' => 'one_way',
|
||
'Seq_in_index' => '2',
|
||
'Column_name' => 'small_int',
|
||
'Collation' => 'A',
|
||
'Cardinality' => NULL,
|
||
'Sub_part' => NULL,
|
||
'Packed' => NULL,
|
||
'Null' => 'YES',
|
||
'Index_type' => 'BTREE',
|
||
'Comment' => ''
|
||
))
|
||
);
|
||
|
||
$mockDbo->expects($this->once())->method('getVersion')->will($this->returnValue('4.1'));
|
||
$resultMock = $this->getMock('PDOStatement', array('fetch'));
|
||
$mockDbo->expects($this->once())
|
||
->method('_execute')
|
||
->with('SHOW INDEX FROM ' . $name)
|
||
->will($this->returnValue($resultMock));
|
||
|
||
foreach ($columnData as $i => $data) {
|
||
$resultMock->expects($this->at($i))->method('fetch')->will($this->returnValue((object) $data));
|
||
}
|
||
|
||
$result = $mockDbo->index($name, false);
|
||
$expected = array(
|
||
'PRIMARY' => array('column' => 'id', 'unique' => 1),
|
||
'pointless_bool' => array('column' => 'bool', 'unique' => 0),
|
||
'pointless_small_int' => array('column' => 'small_int', 'unique' => 0),
|
||
'one_way' => array('column' => array('bool', 'small_int'), 'unique' => 0),
|
||
);
|
||
$this->assertEqual($expected, $result);
|
||
}
|
||
|
||
/**
|
||
* testColumn method
|
||
*
|
||
* @return void
|
||
*/
|
||
public function testColumn() {
|
||
$result = $this->Dbo->column('varchar(50)');
|
||
$expected = 'string';
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$result = $this->Dbo->column('text');
|
||
$expected = 'text';
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$result = $this->Dbo->column('int(11)');
|
||
$expected = 'integer';
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$result = $this->Dbo->column('int(11) unsigned');
|
||
$expected = 'integer';
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$result = $this->Dbo->column('tinyint(1)');
|
||
$expected = 'boolean';
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$result = $this->Dbo->column('boolean');
|
||
$expected = 'boolean';
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$result = $this->Dbo->column('float');
|
||
$expected = 'float';
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$result = $this->Dbo->column('float unsigned');
|
||
$expected = 'float';
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$result = $this->Dbo->column('double unsigned');
|
||
$expected = 'float';
|
||
$this->assertEqual($expected, $result);
|
||
|
||
$result = $this->Dbo->column('decimal(14,7) unsigned');
|
||
$expected = 'float';
|
||
$this->assertEqual($expected, $result);
|
||
}
|
||
|
||
/**
|
||
* testAlterSchemaIndexes method
|
||
*
|
||
* @group indices
|
||
* @return void
|
||
*/
|
||
function testAlterSchemaIndexes() {
|
||
$this->Dbo->cacheSources = $this->Dbo->testing = false;
|
||
$table = $this->Dbo->fullTableName('altertest');
|
||
|
||
$schema1 = new CakeSchema(array(
|
||
'name' => 'AlterTest1',
|
||
'connection' => 'test',
|
||
'altertest' => array(
|
||
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
||
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
|
||
'group1' => array('type' => 'integer', 'null' => true),
|
||
'group2' => array('type' => 'integer', 'null' => true)
|
||
)));
|
||
$result = $this->Dbo->createSchema($schema1);
|
||
$this->assertContains('`id` int(11) DEFAULT 0 NOT NULL,', $result);
|
||
$this->assertContains('`name` varchar(50) NOT NULL,', $result);
|
||
$this->assertContains('`group1` int(11) DEFAULT NULL', $result);
|
||
$this->assertContains('`group2` int(11) DEFAULT NULL', $result);
|
||
|
||
//Test that the string is syntactically correct
|
||
$query = $this->Dbo->getConnection()->prepare($result);
|
||
$this->assertEquals($result, $query->queryString);
|
||
|
||
$schema2 = new CakeSchema(array(
|
||
'name' => 'AlterTest2',
|
||
'connection' => 'test',
|
||
'altertest' => array(
|
||
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
||
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
|
||
'group1' => array('type' => 'integer', 'null' => true),
|
||
'group2' => array('type' => 'integer', 'null' => true),
|
||
'indexes' => array(
|
||
'name_idx' => array('column' => 'name', 'unique' => 0),
|
||
'group_idx' => array('column' => 'group1', 'unique' => 0),
|
||
'compound_idx' => array('column' => array('group1', 'group2'), 'unique' => 0),
|
||
'PRIMARY' => array('column' => 'id', 'unique' => 1))
|
||
)));
|
||
|
||
$result = $this->Dbo->alterSchema($schema2->compare($schema1));
|
||
$this->assertContains("ALTER TABLE $table", $result);
|
||
$this->assertContains('ADD KEY name_idx (`name`),', $result);
|
||
$this->assertContains('ADD KEY group_idx (`group1`),', $result);
|
||
$this->assertContains('ADD KEY compound_idx (`group1`, `group2`),', $result);
|
||
$this->assertContains('ADD PRIMARY KEY (`id`);', $result);
|
||
|
||
//Test that the string is syntactically correct
|
||
$query = $this->Dbo->getConnection()->prepare($result);
|
||
$this->assertEquals($result, $query->queryString);
|
||
|
||
// Change three indexes, delete one and add another one
|
||
$schema3 = new CakeSchema(array(
|
||
'name' => 'AlterTest3',
|
||
'connection' => 'test',
|
||
'altertest' => array(
|
||
'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
|
||
'name' => array('type' => 'string', 'null' => false, 'length' => 50),
|
||
'group1' => array('type' => 'integer', 'null' => true),
|
||
'group2' => array('type' => 'integer', 'null' => true),
|
||
'indexes' => array(
|
||
'name_idx' => array('column' => 'name', 'unique' => 1),
|
||
'group_idx' => array('column' => 'group2', 'unique' => 0),
|
||
'compound_idx' => array('column' => array('group2', 'group1'), 'unique' => 0),
|
||
'id_name_idx' => array('column' => array('id', 'name'), 'unique' => 0))
|
||
)));
|
||
|
||
$result = $this->Dbo->alterSchema($schema3->compare($schema2));
|
||
$this->assertContains("ALTER TABLE $table", $result);
|
||
$this->assertContains('DROP PRIMARY KEY,', $result);
|
||
$this->assertContains('DROP KEY name_idx,', $result);
|
||
$this->assertContains('DROP KEY group_idx,', $result);
|
||
$this->assertContains('DROP KEY compound_idx,', $result);
|
||
$this->assertContains('ADD KEY id_name_idx (`id`, `name`),', $result);
|
||
$this->assertContains('ADD UNIQUE KEY name_idx (`name`),', $result);
|
||
$this->assertContains('ADD KEY group_idx (`group2`),', $result);
|
||
$this->assertContains('ADD KEY compound_idx (`group2`, `group1`);', $result);
|
||
|
||
$query = $this->Dbo->getConnection()->prepare($result);
|
||
$this->assertEquals($result, $query->queryString);
|
||
|
||
// Compare us to ourself.
|
||
$this->assertEqual($schema3->compare($schema3), array());
|
||
|
||
// Drop the indexes
|
||
$result = $this->Dbo->alterSchema($schema1->compare($schema3));
|
||
|
||
$this->assertContains("ALTER TABLE $table", $result);
|
||
$this->assertContains('DROP KEY name_idx,', $result);
|
||
$this->assertContains('DROP KEY group_idx,', $result);
|
||
$this->assertContains('DROP KEY compound_idx,', $result);
|
||
$this->assertContains('DROP KEY id_name_idx;', $result);
|
||
|
||
$query = $this->Dbo->getConnection()->prepare($result);
|
||
$this->assertEquals($result, $query->queryString);
|
||
}
|
||
|
||
/**
|
||
* test saving and retrieval of blobs
|
||
*
|
||
* @return void
|
||
*/
|
||
function testBlobSaving() {
|
||
$this->loadFixtures('BinaryTest');
|
||
$this->Dbo->cacheSources = false;
|
||
$data = "GIF87ab |