Example #1
0
 public function testConstruct()
 {
     $pdo = $this->factory->getConnection();
     $pdo->query('CREATE TABLE foo (
         id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
         name varchar(255) null
     )');
     $table = new Table('foo', $this->factory);
     $this->assertEquals('foo', $table->getTableName());
     $this->assertCount(2, $table->getTableColumns());
     $this->assertArrayHasKey('id', $table->getTableColumns());
     $this->assertArrayHasKey('name', $table->getTableColumns());
     $id = $table->getColumn('id');
     $this->assertNotNull($id);
     $this->assertEquals(null, $id->getDefault());
     $this->assertEquals(false, $id->getIsNull());
     $this->assertEquals(true, $id->getIsPrimary());
     $this->assertEquals('id', $id->getName());
     $this->assertEquals('integer', $id->getType());
     $name = $table->getColumn('name');
     $this->assertNotNull($name);
     $this->assertEquals(null, $name->getDefault());
     $this->assertEquals(true, $name->getIsNull());
     $this->assertEquals(false, $name->getIsPrimary());
     $this->assertEquals('name', $name->getName());
     $this->assertEquals('string', $name->getType());
 }