public function test_can_create_index_with_custom_name() { //create it $this->adapter->execute_ddl("CREATE TABLE `users` ( name varchar(20), age int(3) );"); $base = new Ruckusing_BaseMigration(); $base->set_adapter($this->adapter); $base->add_index("users", "name", array('name' => 'my_special_index')); //ensure it exists $this->assertEquals(true, $this->adapter->has_index("users", "name", array('name' => 'my_special_index'))); //drop it $base->remove_index("users", "name", array('name' => 'my_special_index')); $this->assertEquals(false, $this->adapter->has_index("users", "my_special_index")); }
public function test_index_name_too_long_throws_exception() { $this->setExpectedException('Ruckusing_InvalidIndexNameException'); $bm = new Ruckusing_BaseMigration(); $bm->set_adapter($this->adapter); $ts = microtime(); $table_name = "users_{$ts}"; $table = $bm->create_table($table_name, array('id' => false)); $table->column('somecolumnthatiscrazylong', 'integer'); $table->column('anothercolumnthatiscrazylongrodeclown', 'integer'); $sql = $table->finish(); $bm->add_index($table_name, array('somecolumnthatiscrazylong', 'anothercolumnthatiscrazylongrodeclown')); $this->remove_table($table_name); }