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 passed at build time then return them as an array.
  */
 public function testWhenEntriesArePassedThenStoreThem()
 {
     $fields = [TableField::build(StringLiteral::fromNative('id'), FieldType::fromNative('int(3)'), false, FieldKeyType::fromNative('PRI'), FieldDefaultValue::fromNative(''), StringLiteral::fromNative('')), TableField::build(StringLiteral::fromNative('name'), FieldType::fromNative('varchar(255)'), false, FieldKeyType::fromNative(''), FieldDefaultValue::fromNative(''), StringLiteral::fromNative(''))];
     $instance = TableFieldCollection::build($fields);
     $response = $instance->toArray();
     $expected = [['name' => 'id', 'type' => 'int(3)', 'null' => false, 'key' => 'PRI', 'default' => '', 'extra' => ''], ['name' => 'name', 'type' => 'varchar(255)', 'null' => false, 'key' => '', 'default' => '', 'extra' => '']];
     static::assertEquals($expected, $response);
 }
 /**
  * When isNull is not boolean will throw exception.
  *
  * @expectedException \InvalidArgumentException
  * @expectedExceptionMessage The isNull argument doesn't have a boolean value.
  */
 public function testWhenIsNullIsNotBooleanWillThrowException()
 {
     $name = 'sample-name';
     $type = 'varchar(123)';
     $key = 'sample-key';
     $default = 'sample-default';
     $extra = 'sample-extra';
     TableField::build(StringLiteral::fromNative($name), FieldType::fromNative($type), 'isNull', FieldKeyType::fromNative($key), FieldDefaultValue::fromNative($default), StringLiteral::fromNative($extra));
 }
 public function buildField($name, $type, $null, $key, $default, $extra)
 {
     $nameAttribute = StringLiteral::fromNative($name);
     $typeAttribute = FieldType::fromNative($type);
     $nullAttribute = $null === 'YES';
     $keyAttribute = FieldKeyType::fromNative($key);
     $defaultAttribute = FieldDefaultValue::fromNative($default);
     $extraAttribute = StringLiteral::fromNative($extra);
     return TableField::build($nameAttribute, $typeAttribute, $nullAttribute, $keyAttribute, $defaultAttribute, $extraAttribute);
 }
 public function getKey()
 {
     return $this->key->toNative();
 }