/** * @covers Amiss\Sql\TableBuilder::buildFields * @group tablebuilder */ public function testCreateTableWithCustomTypeUsesTypeHandler() { $this->mapper->addTypeHandler(new TestCreateWithCustomTypeTypeHandler(), 'slappywag'); $pattern = "\n CREATE TABLE `bar` (\n `testCreateId` INTEGER NOT NULL AUTO_INCREMENT,\n `foo1` OH YEAH,\n `foo2` OH YEAH,\n `pants` int unsigned not null,\n PRIMARY KEY (`testCreateId`)\n ) ENGINE=InnoDB;\n "; $last = TableBuilder::createSQL($this->connector, $this->mapper, $this->class); $this->assertLoose($pattern, $last[0]); }
/** * @covers Amiss\Sql\TableBuilder::buildFields * @group tablebuilder */ public function testCreateTableWithCustomTypeUsesTypeHandler() { $this->mapper->addTypeHandler(new RecordCreateCustomTypeWithEmptyColumnTypeHandler(), 'int'); $pattern = "\n CREATE TABLE `bar` (\n `id` INTEGER NOT NULL AUTO_INCREMENT,\n `foo1` int,\n PRIMARY KEY (`id`)\n ) ENGINE=InnoDB;\n "; $last = TableBuilder::createSQL($this->connector, $this->mapper, $this->class); $this->assertLoose($pattern, $last[0]); }
/** * @group tablebuilder * @expectedException Amiss\Exception */ public function testCreateTableFailsWhenFieldsNotDefined() { TableBuilder::createSQL($this->deps->connector, $this->deps->mapper, __NAMESPACE__ . '\\TestNoFieldsCreate'); }