| @@ 116-134 (lines=19) @@ | ||
| 113 | $this->assertSame('foo', $column->getDbalColumn()->getName()); |
|
| 114 | } |
|
| 115 | ||
| 116 | public function testReference() |
|
| 117 | { |
|
| 118 | $schema = new Schema(); |
|
| 119 | $fluid = new TdbmFluidSchema($schema); |
|
| 120 | ||
| 121 | $countries = $fluid->table('countries'); |
|
| 122 | $countries->id(); |
|
| 123 | ||
| 124 | $users = $fluid->table('users'); |
|
| 125 | $users->column('country_id')->references('countries', 'myfk'); |
|
| 126 | ||
| 127 | $dbalColumn = $schema->getTable('users')->getColumn('country_id'); |
|
| 128 | ||
| 129 | $this->assertSame(Type::getType(Type::INTEGER), $dbalColumn->getType()); |
|
| 130 | $fk = $schema->getTable('users')->getForeignKey('myfk'); |
|
| 131 | $this->assertSame('users', $fk->getLocalTableName()); |
|
| 132 | $this->assertSame('countries', $fk->getForeignTableName()); |
|
| 133 | $this->assertSame(['country_id'], $fk->getLocalColumns()); |
|
| 134 | } |
|
| 135 | ||
| 136 | public function testReferenceException() |
|
| 137 | { |
|
| @@ 168-187 (lines=20) @@ | ||
| 165 | } |
|
| 166 | } |
|
| 167 | ||
| 168 | public function testInherits() |
|
| 169 | { |
|
| 170 | $schema = new Schema(); |
|
| 171 | $fluid = new TdbmFluidSchema($schema); |
|
| 172 | ||
| 173 | $contacts = $fluid->table('contacts'); |
|
| 174 | $contacts->id(); |
|
| 175 | ||
| 176 | $fluid->table('users')->extends('contacts'); |
|
| 177 | ||
| 178 | $dbalColumn = $schema->getTable('users')->getColumn('id'); |
|
| 179 | ||
| 180 | $this->assertSame(Type::getType(Type::INTEGER), $dbalColumn->getType()); |
|
| 181 | $fks = $schema->getTable('users')->getForeignKeys(); |
|
| 182 | $this->assertCount(1, $fks); |
|
| 183 | $fk = array_pop($fks); |
|
| 184 | $this->assertSame('users', $fk->getLocalTableName()); |
|
| 185 | $this->assertSame('contacts', $fk->getForeignTableName()); |
|
| 186 | $this->assertSame(['id'], $fk->getLocalColumns()); |
|
| 187 | } |
|
| 188 | ||
| 189 | public function testGetDbalTable() |
|
| 190 | { |
|