private function createIndexes(Table $table) { if (empty($table->getIndexes())) { return ''; } $indexes = []; foreach ($table->getIndexes() as $index) { $indexes[] = $this->createIndex($index); } return ',' . implode(',', $indexes); }
public function testGetters() { $table = new Table('test'); $this->assertInstanceOf('\\Phoenix\\Database\\Element\\Table', $table->addColumn(new Column('title', 'string'))); $this->assertInstanceOf('\\Phoenix\\Database\\Element\\Table', $table->addColumn(new Column('total', 'int'))); $this->assertInstanceOf('\\Phoenix\\Database\\Element\\Table', $table->addColumn(new Column('bodytext', 'text'))); $columns = $table->getColumns(); $this->assertCount(3, $columns); foreach ($columns as $column) { $this->assertInstanceOf('\\Phoenix\\Database\\Element\\Column', $column); } $this->assertInstanceOf('\\Phoenix\\Database\\Element\\Column', $table->getColumn('title')); $this->assertInstanceOf('\\Phoenix\\Database\\Element\\Table', $table->addIndex(new Index('title', 'title', 'unique'))); $this->assertInstanceOf('\\Phoenix\\Database\\Element\\Table', $table->addIndex(new Index(['title', 'alias'], 'title_alias'))); $this->assertInstanceOf('\\Phoenix\\Database\\Element\\Table', $table->addIndex(new Index(['bodytext'], 'bodytext', 'fulltext'))); $indexes = $table->getIndexes(); $this->assertCount(3, $indexes); foreach ($indexes as $index) { $this->assertInstanceOf('\\Phoenix\\Database\\Element\\Index', $index); } $this->setExpectedException('\\Exception', 'Column "unknown_column" not found'); $table->getColumn('unknown_column'); }