/** * Parse table create statement. * * @throws SchemaException */ protected function parseTableCS() { $lines = explode("\n", $this->tableCS); foreach ($lines as $index => $line) { $line = trim($line); // Column definitions start with ` if (0 === strpos($line, '`')) { $this->addColumn(new Column($line, $index, $this)); } elseif (Index::isIndexDef($line)) { $this->addIndex(new Index($line, $this)); } elseif (Constraint::isConstraintDef($line)) { $this->addConstraint(new Constraint($line, $this)); } elseif (preg_match('/CREATE TABLE `(.*?)`/', $line, $matches) === 1) { $this->name = $matches[1]; $this->type = TableItf::TYPE_TABLE; } elseif (preg_match('/VIEW `(.*?)` AS /i', $line, $matches) === 1) { $this->name = $matches[1]; $this->type = TableItf::TYPE_VIEW; } } }
/** * @dataProvider isConstraintDefProvider * * @covers ::isConstraintDef * * @param string $constraintDef * @param bool $expected */ public function test_isConstraintDef($constraintDef, $expected) { // When $got = Constraint::isConstraintDef($constraintDef); // Then $this->assertSame($expected, $got); }