Ejemplo n.º 1
0
 public function testModifyMultiIndexesByMultiQuery()
 {
     $tableName = 'test17_' . mt_rand();
     $fields = array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255'), 'bar' => array('name' => 'bar', 'type' => 'varchar', 'len' => '255'));
     $indexes = array('idx_foo' => array('name' => 'idx_foo', 'type' => 'index', 'fields' => array('foo')), 'idx_bar' => array('name' => 'idx_bar', 'type' => 'index', 'fields' => array('bar')));
     $this->createTableParams($tableName, $fields, $indexes);
     $indexesDB = $this->_db->get_indices($tableName);
     $this->assertEquals($indexes, $indexesDB, 'Indexes are incorrect');
     $indexesNew = $indexes;
     $indexesNew['idx_foo']['fields'] = array('bar');
     $indexesNew['idx_bar']['fields'] = array('foo');
     $queries = $this->_db->modifyIndexes($tableName, $indexesNew, false);
     $queries = explode(";\n", rtrim(trim($queries), ';'));
     $this->_db->query($queries);
     $indexesDB = $this->_db->get_indices($tableName);
     $this->assertEquals($indexesNew, $indexesDB, 'Indexes are incorrect');
 }
Ejemplo n.º 2
0
 public function testModifyIndexes()
 {
     //TODO Fix test with normal index inspection
     $this->markTestIncomplete('TODO Reimplement test not using compareIndexInTables.');
     $tablename1 = 'test21_' . mt_rand();
     $this->createTableParams($tablename1, array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255'), 'foobar' => array('name' => 'foobar', 'type' => 'varchar', 'len' => '255')), array(array('name' => 'idx_' . $tablename1, 'type' => 'index', 'fields' => array('foo'))));
     $tablename2 = 'test22_' . mt_rand();
     $this->createTableParams($tablename2, array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255'), 'foobar' => array('name' => 'foobar', 'type' => 'varchar', 'len' => '255')), array(array('name' => 'idx_' . $tablename2, 'type' => 'index', 'fields' => array('foobar'))));
     $res = $this->_db->compareIndexInTables('idx_foo', $tablename1, $tablename2);
     $this->assertEquals($res['msg'], 'no_match');
     $this->_db->modifyIndexes($tablename2, array(array('name' => 'idx_foo', 'type' => 'index', 'fields' => array('foo'))), false);
     $res = $this->_db->compareIndexInTables('idx_foo', $tablename1, $tablename2);
     $this->assertEquals($res['msg'], 'no_match');
     $this->_db->modifyIndexes($tablename2, array(array('name' => 'idx_foo', 'type' => 'index', 'fields' => array('foo'))));
     $res = $this->_db->compareIndexInTables('idx_foo', $tablename1, $tablename2);
     $this->assertEquals($res['msg'], 'match');
     $this->dropTableName($tablename1);
     $this->dropTableName($tablename2);
 }