コード例 #1
0
 public function testAddIndex()
 {
     $instance = new Table('Foo');
     $instance->addIndex('bar');
     $expected = array('indicies' => array('bar'));
     $this->assertEquals($expected, $instance->getConfiguration());
     $this->assertInternalType('string', $instance->getHash());
 }
コード例 #2
0
 public function testCreateIndex()
 {
     $connection = $this->getMockBuilder('\\DatabaseBase')->disableOriginalConstructor()->setMethods(array('tableExists', 'query'))->getMockForAbstractClass();
     $connection->expects($this->any())->method('getType')->will($this->returnValue('sqlite'));
     $connection->expects($this->any())->method('tableExists')->will($this->returnValue(false));
     $connection->expects($this->at(3))->method('query')->with($this->stringContains('PRAGMA index_list("foo")'))->will($this->returnValue(array()));
     $connection->expects($this->at(4))->method('query')->with($this->stringContains('CREATE INDEX "foo"_index0'));
     $instance = SQLiteTableBuilder::factory($connection);
     $table = new Table('foo');
     $table->addColumn('bar', 'text');
     $table->addIndex('bar');
     $instance->create($table);
 }
コード例 #3
0
 public function testCreateIndex()
 {
     $connection = $this->getMockBuilder('\\DatabaseBase')->disableOriginalConstructor()->setMethods(array('tableExists', 'query'))->getMockForAbstractClass();
     $connection->expects($this->any())->method('getType')->will($this->returnValue('mysql'));
     $connection->expects($this->any())->method('tableExists')->will($this->returnValue(false));
     $connection->expects($this->at(3))->method('query')->with($this->stringContains('SHOW INDEX'))->will($this->returnValue(array()));
     $connection->expects($this->at(4))->method('query')->with($this->stringContains('ALTER TABLE "foo" ADD INDEX (bar)'));
     $instance = MySQLTableBuilder::factory($connection);
     $table = new Table('foo');
     $table->addColumn('bar', 'text');
     $table->addIndex('bar');
     $instance->create($table);
 }
コード例 #4
0
 public function testCreateIndex()
 {
     $connection = $this->getMockBuilder('\\DatabaseBase')->disableOriginalConstructor()->setMethods(array('tableExists', 'query', 'indexInfo'))->getMockForAbstractClass();
     $connection->expects($this->any())->method('getType')->will($this->returnValue('postgres'));
     $connection->expects($this->any())->method('tableExists')->will($this->returnValue(false));
     $connection->expects($this->any())->method('indexInfo')->will($this->returnValue(false));
     $connection->expects($this->at(3))->method('query')->with($this->stringContains('SELECT  i.relname AS indexname'))->will($this->returnValue(array()));
     $connection->expects($this->at(5))->method('query')->with($this->stringContains('CREATE INDEX foo_index0 ON foo (bar)'));
     $instance = PostgresTableBuilder::factory($connection);
     $table = new Table('foo');
     $table->addColumn('bar', 'text');
     $table->addIndex('bar');
     $instance->create($table);
 }
コード例 #5
0
 public function testUpdateIndex_NoIndexChange()
 {
     $messageReporter = $this->messageReporterFactory->newSpyMessageReporter();
     $this->tableBuilder->setMessageReporter($messageReporter);
     $table = new Table($this->tableName);
     $table->addColumn('id', FieldType::FIELD_ID_PRIMARY);
     $table->addColumn('t_text', array(FieldType::TYPE_BLOB, 'NOT NULL'));
     $table->addColumn('t_num', array(FieldType::TYPE_DOUBLE, 'NOT NULL'));
     $table->addColumn('t_int', array(FieldType::TYPE_INT));
     $table->addIndex(array('id', 'UNIQUE INDEX'));
     $this->tableBuilder->create($table);
     $expected = array('Checking index structures for table rdbms_test', 'index id is fine');
     if ($this->tableBuilder instanceof SQLiteTableBuilder) {
         $expected = str_replace('index id is fine', 'creating new index id', $expected);
         $expected = 'removing index';
     }
     $this->stringValidator->assertThatStringContains($expected, $messageReporter->getMessagesAsString());
 }
コード例 #6
0
 private function newPropertyStatisticsTable()
 {
     // PROPERTY_STATISTICS_TABLE
     $table = new Table(SQLStore::PROPERTY_STATISTICS_TABLE);
     $table->addColumn('p_id', FieldType::FIELD_ID);
     $table->addColumn('usage_count', FieldType::FIELD_USAGE_COUNT);
     $table->addIndex(array('p_id', 'UNIQUE INDEX'));
     $table->addIndex('usage_count');
     return $table;
 }