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);
 }
 /**
  * When the isNull parameter is not boolean then throw exception.
  *
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The isNull argument doesn't have a boolean value.
  */
 public function testWhenTheIsNullParameterIsNotBooleanThenThrowException()
 {
     $table = new StringLiteral('sample-table');
     $nonUnique = new StringLiteral('sample-nonUnique');
     $keyName = new StringLiteral('sample-keyName');
     $seqInIndex = new StringLiteral('sample-seqInIndex');
     $columnName = new StringLiteral('sample-columnName');
     $collation = new StringLiteral('sample-collation');
     $cardinality = new StringLiteral('sample-cardinality');
     $subPart = new StringLiteral('sample-subPart');
     $packed = new StringLiteral('sample-packed');
     $isNull = 'notbool';
     $indexType = new StringLiteral('sample-indexType');
     $comment = new StringLiteral('sample-comment');
     $indexComment = new StringLiteral('sample-indexComment');
     TableIndex::build($table, $nonUnique, $keyName, $seqInIndex, $columnName, $collation, $cardinality, $subPart, $packed, $isNull, $indexType, $comment, $indexComment);
 }
 /**
  * @todo improve types for TableIndex attributes
  *
  * @param $table
  * @param $nonUnique
  * @param $keyName
  * @param $seqInIndex
  * @param $columnName
  * @param $collation
  * @param $cardinality
  * @param $subPart
  * @param $packed
  * @param $isNull
  * @param $indexType
  * @param $comment
  * @param $indexComment
  *
  * @return TableIndex
  */
 public function buildIndex($table, $nonUnique, $keyName, $seqInIndex, $columnName, $collation, $cardinality, $subPart, $packed, $isNull, $indexType, $comment, $indexComment)
 {
     $tableAttribute = StringLiteral::fromNative($table);
     $nonUniqueAttribute = StringLiteral::fromNative($nonUnique);
     $keyNameAttribute = StringLiteral::fromNative($keyName);
     $seqInIndexAttribute = StringLiteral::fromNative($seqInIndex);
     $columnNameAttribute = StringLiteral::fromNative($columnName);
     $collationAttribute = StringLiteral::fromNative($collation);
     $cardinalityAttribute = StringLiteral::fromNative($cardinality);
     $subPartAttribute = null === $subPart ? NullValue::create() : StringLiteral::fromNative($subPart);
     $packedAttribute = null === $packed ? NullValue::create() : StringLiteral::fromNative($packed);
     $isNullAttribute = (bool) $isNull;
     $indexTypeAttribute = StringLiteral::fromNative($indexType);
     $commentAttribute = StringLiteral::fromNative($comment);
     $indexCommentAttribute = StringLiteral::fromNative($indexComment);
     $tableIndex = TableIndex::build($tableAttribute, $nonUniqueAttribute, $keyNameAttribute, $seqInIndexAttribute, $columnNameAttribute, $collationAttribute, $cardinalityAttribute, $subPartAttribute, $packedAttribute, $isNullAttribute, $indexTypeAttribute, $commentAttribute, $indexCommentAttribute);
     return $tableIndex;
 }