public function buildTableIndexCollectionFromPersistence(array $indexes)
 {
     $indexList = [];
     $length = count($indexes);
     for ($i = 0; $i < $length; $i++) {
         /** @var \DatabaseInspect\Persistence\Models\TableIndex $persistenceIndex */
         $persistenceIndex = $indexes[$i];
         // @todo Throw exception when the item is not a TableIndex.
         $table = $persistenceIndex->getTable();
         $nonUnique = $persistenceIndex->getNonUnique();
         $keyName = $persistenceIndex->getKeyName();
         $seqInIndex = $persistenceIndex->getSeqInIndex();
         $columnName = $persistenceIndex->getColumnName();
         $collation = $persistenceIndex->getCollation();
         $cardinality = $persistenceIndex->getCardinality();
         $subPart = $persistenceIndex->getSubPart();
         $packed = $persistenceIndex->getPacked();
         $isNull = $persistenceIndex->getIsNull();
         $indexType = $persistenceIndex->getIndexType();
         $comment = $persistenceIndex->getComment();
         $indexComment = $persistenceIndex->getIndexComment();
         $domainIndex = $this->buildIndex($table, $nonUnique, $keyName, $seqInIndex, $columnName, $collation, $cardinality, $subPart, $packed, $isNull, $indexType, $comment, $indexComment);
         $indexList[] = $domainIndex;
     }
     return TableIndexCollection::build($indexList);
 }
 public static function getInstanceSample()
 {
     $name = StringLiteral::fromNative('sample_table_name');
     $fields = TableFieldCollection::build([TableField::build(StringLiteral::fromNative('sample-name'), FieldType::fromNative('varchar(123)'), true, FieldKeyType::fromNative('sample-key'), FieldDefaultValue::fromNative('sample-default'), StringLiteral::fromNative('sample-extra'))]);
     $indexes = TableIndexCollection::build([TableIndex::build(new StringLiteral('sample-table'), new StringLiteral('sample-nonUnique'), new StringLiteral('sample-keyName'), new StringLiteral('sample-seqInIndex'), new StringLiteral('sample-columnName'), new StringLiteral('sample-collation'), new StringLiteral('sample-cardinality'), new StringLiteral('sample-subPart'), new StringLiteral('sample-packed'), false, new StringLiteral('sample-indexType'), new StringLiteral('sample-comment'), new StringLiteral('sample-indexComment'))]);
     $instance = Table::build($name, $fields, $indexes);
     return $instance;
 }
 /**
  * When entries are set then return their array representation.
  */
 public function testWhenEntriesAreSetThenReturnTheirArrayRepresentation()
 {
     $index0 = TableIndex::build(new StringLiteral('sample-0-table'), new StringLiteral('sample-0-nonUnique'), new StringLiteral('sample-0-keyName'), new StringLiteral('sample-0-seqInIndex'), new StringLiteral('sample-0-columnName'), new StringLiteral('sample-0-collation'), new StringLiteral('sample-0-cardinality'), new StringLiteral('sample-0-subPart'), new StringLiteral('sample-0-packed'), true, new StringLiteral('sample-0-indexType'), new StringLiteral('sample-0-comment'), new StringLiteral('sample-0-indexComment'));
     $index1 = TableIndex::build(new StringLiteral('sample-1-table'), new StringLiteral('sample-1-nonUnique'), new StringLiteral('sample-1-keyName'), new StringLiteral('sample-1-seqInIndex'), new StringLiteral('sample-1-columnName'), new StringLiteral('sample-1-collation'), new StringLiteral('sample-1-cardinality'), new StringLiteral('sample-1-subPart'), new StringLiteral('sample-1-packed'), false, new StringLiteral('sample-1-indexType'), new StringLiteral('sample-1-comment'), new StringLiteral('sample-1-indexComment'));
     $input = [$index0, $index1];
     $instance = TableIndexCollection::build($input);
     $output = $instance->toArray();
     $expected = [['table' => 'sample-0-table', 'nonUnique' => 'sample-0-nonUnique', 'keyName' => 'sample-0-keyName', 'seqInIndex' => 'sample-0-seqInIndex', 'columnName' => 'sample-0-columnName', 'collation' => 'sample-0-collation', 'cardinality' => 'sample-0-cardinality', 'subPart' => 'sample-0-subPart', 'packed' => 'sample-0-packed', 'isNull' => true, 'indexType' => 'sample-0-indexType', 'comment' => 'sample-0-comment', 'indexComment' => 'sample-0-indexComment'], ['table' => 'sample-1-table', 'nonUnique' => 'sample-1-nonUnique', 'keyName' => 'sample-1-keyName', 'seqInIndex' => 'sample-1-seqInIndex', 'columnName' => 'sample-1-columnName', 'collation' => 'sample-1-collation', 'cardinality' => 'sample-1-cardinality', 'subPart' => 'sample-1-subPart', 'packed' => 'sample-1-packed', 'isNull' => false, 'indexType' => 'sample-1-indexType', 'comment' => 'sample-1-comment', 'indexComment' => 'sample-1-indexComment']];
     static::assertEquals($expected, $output);
 }
 /**
  * Store entries.
  */
 public function testStoreEntries()
 {
     $name = StringLiteral::fromNative('sample_table_name');
     $fields = TableFieldCollection::build([]);
     $indexes = TableIndexCollection::build([]);
     $instance = Table::build($name, $fields, $indexes);
     static::assertInstanceOf(Table::class, $instance);
     $helper = \ClassHelper::instance($instance);
     static::assertSame($name, $helper->name);
     static::assertSame($fields, $helper->fields);
     static::assertSame($indexes, $helper->indexes);
 }
 /**
  * When fields are not instance of tableindex then throw exception.
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage Invalid index entries.
  */
 public function testWhenFieldsAreNotInstanceOfTableindexThenThrowException()
 {
     $input = [new TableIndex(), new TableIndex(), new TableField()];
     TableIndexCollection::build($input);
 }