public function loadStatement($statement) { preg_match("/^[`]*[a-zA-Z-_]*[`]*\\s*(CHAR|VARCHAR|TEXT|INTEGER|PRIMARY\\sKEY)/i", $statement, $outputArray); $this->countColumn($statement); if (!isset($outputArray[1]) || empty($outputArray[1])) { throw new InvalidColumnException($statement, 'Statement Not Found.'); } if (strpos(trim(strtolower($statement)), 'primary key') !== false) { $this->getPrimaryKey()->checkColumn($statement); } $column = ColumnFactory::instantiate($statement); $this->getCollection()->add($column->getName(), $column); }
/** * @expectedException Highideas\SqlToMigration\Exceptions\InvalidColumnException * @expectedExceptionMessage Column Not Found. */ public function testInstantiateShouldReturnInvalidColumnExceptionWhenUnknownColumnInformed() { ColumnFactory::instantiate('`Active` boolean NOT NULL'); }