Beispiel #1
0
 public function testGetIndicesContainsPrimary()
 {
     $indices = $this->_db->get_indices('accounts');
     // find if any are primary
     $found = false;
     foreach ($indices as $index) {
         if ($index['type'] == "primary") {
             $found = true;
             break;
         }
     }
     $this->assertTrue($found, 'Primary Key Not Found On Module');
 }
Beispiel #2
0
 /**
  * @depends testAddPrimaryKey
  */
 public function testRemovePrimaryKey()
 {
     $tablename = 'testConstraints';
     $this->created[$tablename] = true;
     $sql = $this->_db->add_drop_constraint($tablename, array('name' => 'testConstraints_pk', 'type' => 'primary', 'fields' => array('id')), true);
     $result = $this->_db->query($sql);
     $indices = $this->_db->get_indices($tablename);
     // find if any are primary
     $found = false;
     foreach ($indices as $index) {
         if ($index['type'] == "primary") {
             $found = true;
             break;
         }
     }
     $this->assertFalse($found, 'Primary Key Found On Table');
 }
 public function testRepairTableParamsAddIndexAndData()
 {
     $tableName = 'test1_' . mt_rand();
     $params = array('foo' => array('name' => 'foo', 'type' => 'varchar', 'len' => '255'), 'bar' => array('name' => 'bar', 'type' => 'int'));
     $index = array('name' => 'test_index', 'type' => 'index', 'fields' => array('foo', 'bar'));
     if ($this->_db->tableExists($tableName)) {
         $this->_db->dropTableName($tableName);
     }
     $this->createTableParams($tableName, $params, array());
     $repair = $this->_db->repairTableParams($tableName, $params, array($index), false);
     $this->assertRegExp('#MISSING INDEX IN DATABASE.*test_index#i', $repair);
     $repair = $this->_db->repairTableParams($tableName, $params, array($index), true);
     $idx = $this->_db->get_indices($tableName);
     $this->assertArrayHasKey('test_index', $idx);
     $this->assertContains('foo', $idx['test_index']['fields']);
     $this->assertContains('bar', $idx['test_index']['fields']);
     $this->dropTableName($tableName);
 }