1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace TheCodingMachine\FluidSchema; |
4
|
|
|
|
5
|
|
|
use Doctrine\DBAL\Schema\Schema; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
|
8
|
|
|
class TdbmFluidSchemaTest extends TestCase |
9
|
|
|
{ |
10
|
|
|
public function testTable() |
11
|
|
|
{ |
12
|
|
|
$schema = new Schema(); |
13
|
|
|
$fluid = new TdbmFluidSchema($schema); |
14
|
|
|
|
15
|
|
|
$posts = $fluid->table('posts'); |
16
|
|
|
|
17
|
|
|
$this->assertTrue($schema->hasTable('posts')); |
18
|
|
|
|
19
|
|
|
$this->assertSame($posts, $fluid->table('posts'), 'Failed asserting that the same instance is returned.'); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
public function testExistingTable() |
23
|
|
|
{ |
24
|
|
|
$schema = new Schema(); |
25
|
|
|
$postsSchemaTable = $schema->createTable('posts'); |
26
|
|
|
$fluid = new TdbmFluidSchema($schema); |
27
|
|
|
|
28
|
|
|
$posts = $fluid->table('posts'); |
29
|
|
|
$posts->column('foo'); |
30
|
|
|
|
31
|
|
|
$this->assertTrue($postsSchemaTable->hasColumn('foo')); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testJunctionTable() |
35
|
|
|
{ |
36
|
|
|
$schema = new Schema(); |
37
|
|
|
$db = new TdbmFluidSchema($schema); |
38
|
|
|
$db->table('users')->id(); |
39
|
|
|
$db->table('roles')->id(); |
40
|
|
|
$db->junctionTable('users', 'roles'); |
41
|
|
|
|
42
|
|
|
$this->assertTrue($schema->hasTable('users_roles')); |
43
|
|
|
$this->assertCount(2, $schema->getTable('users_roles')->getColumns()); |
|
|
|
|
44
|
|
|
$this->assertNotNull($schema->getTable('users_roles')->getColumn('user_id')); |
45
|
|
|
$this->assertNotNull($schema->getTable('users_roles')->getColumn('role_id')); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testGetDbalSchema() |
49
|
|
|
{ |
50
|
|
|
$schema = new Schema(); |
51
|
|
|
$fluid = new TdbmFluidSchema($schema); |
52
|
|
|
|
53
|
|
|
$this->assertSame($schema, $fluid->getDbalSchema()); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: