Skip to content

Commit 5213958

Browse files
committed
test: Improve test coverage
+ Remove checks for dbal v2
1 parent af14ef3 commit 5213958

File tree

2 files changed

+39
-33
lines changed

2 files changed

+39
-33
lines changed

tests/FluidColumnTest.php

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -80,36 +80,31 @@ public function testTypes()
8080
$column->object();
8181
$this->assertSame(Type::getType(Types::OBJECT), $dbalColumn->getType());
8282

83-
if (defined('Doctrine\\DBAL\\Types\\Types::BINARY')) {
84-
$column->binary(43);
85-
$this->assertSame(Type::getType(Types::BINARY), $dbalColumn->getType());
86-
$this->assertSame(43, $dbalColumn->getLength());
87-
$this->assertSame(false, $dbalColumn->getFixed());
88-
}
83+
$column->binary(43);
84+
$this->assertSame(Type::getType(Types::BINARY), $dbalColumn->getType());
85+
$this->assertSame(43, $dbalColumn->getLength());
86+
$this->assertSame(false, $dbalColumn->getFixed());
8987

90-
if (defined('Doctrine\\DBAL\\Types\\Types::DATE_IMMUTABLE')) {
91-
// Doctrine DBAL 2.6+
92-
$column->dateImmutable();
93-
$this->assertSame(Type::getType('date_immutable'), $dbalColumn->getType());
88+
$column->dateImmutable();
89+
$this->assertSame(Type::getType('date_immutable'), $dbalColumn->getType());
9490

95-
$column->datetimeImmutable();
96-
$this->assertSame(Type::getType(Types::DATETIME_IMMUTABLE), $dbalColumn->getType());
91+
$column->datetimeImmutable();
92+
$this->assertSame(Type::getType(Types::DATETIME_IMMUTABLE), $dbalColumn->getType());
9793

98-
$column->datetimeTzImmutable();
99-
$this->assertSame(Type::getType(Types::DATETIMETZ_IMMUTABLE), $dbalColumn->getType());
94+
$column->datetimeTzImmutable();
95+
$this->assertSame(Type::getType(Types::DATETIMETZ_IMMUTABLE), $dbalColumn->getType());
10096

101-
$column->time();
102-
$this->assertSame(Type::getType(Types::TIME_MUTABLE), $dbalColumn->getType());
97+
$column->time();
98+
$this->assertSame(Type::getType(Types::TIME_MUTABLE), $dbalColumn->getType());
10399

104-
$column->timeImmutable();
105-
$this->assertSame(Type::getType(Types::TIME_IMMUTABLE), $dbalColumn->getType());
100+
$column->timeImmutable();
101+
$this->assertSame(Type::getType(Types::TIME_IMMUTABLE), $dbalColumn->getType());
106102

107-
$column->dateInterval();
108-
$this->assertSame(Type::getType(Types::DATEINTERVAL), $dbalColumn->getType());
103+
$column->dateInterval();
104+
$this->assertSame(Type::getType(Types::DATEINTERVAL), $dbalColumn->getType());
109105

110-
$column->json();
111-
$this->assertSame(Type::getType(Types::JSON), $dbalColumn->getType());
112-
}
106+
$column->json();
107+
$this->assertSame(Type::getType(Types::JSON), $dbalColumn->getType());
113108

114109
$this->assertSame('foo', $column->getDbalColumn()->getName());
115110
}

tests/FluidTableTest.php

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,15 @@ public function testUuid()
102102

103103
public function testTimestamps()
104104
{
105-
if (defined('Doctrine\\DBAL\\Types\\Types::DATE_IMMUTABLE')) {
106-
$schema = new Schema();
107-
$fluid = new FluidSchema($schema);
105+
$schema = new Schema();
106+
$fluid = new FluidSchema($schema);
108107

109-
$posts = $fluid->table('posts');
108+
$posts = $fluid->table('posts');
110109

111-
$posts->timestamps();
110+
$posts->timestamps();
112111

113-
$this->assertTrue($schema->getTable('posts')->hasColumn('created_at'));
114-
$this->assertTrue($schema->getTable('posts')->hasColumn('updated_at'));
115-
} else {
116-
$this->markTestSkipped("Only available from Doctrine DBAL 2.6");
117-
}
112+
$this->assertTrue($schema->getTable('posts')->hasColumn('created_at'));
113+
$this->assertTrue($schema->getTable('posts')->hasColumn('updated_at'));
118114
}
119115

120116
public function testInherits()
@@ -138,6 +134,21 @@ public function testInherits()
138134
$this->assertSame(['id'], $fk->getLocalColumns());
139135
}
140136

137+
public function testCannotInheritFromATableWithMultiplePrimaryKeys()
138+
{
139+
$schema = new Schema();
140+
$fluid = new FluidSchema($schema);
141+
142+
$contacts = $fluid->table('contacts');
143+
$contacts->column('foo')->string();
144+
$contacts->column('bar')->string();
145+
$contacts->primaryKey(['foo', 'bar']);
146+
147+
$this->expectException(FluidSchemaException::class);
148+
149+
$fluid->table('users')->extends('contacts');
150+
}
151+
141152
public function testGetDbalTable()
142153
{
143154
$schema = new Schema();

0 commit comments

Comments
 (0)