Total Complexity | 9 |
Total Lines | 227 |
Duplicated Lines | 0 % |
Changes | 3 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | final class DB2SchemaManagerTest extends TestCase |
||
20 | { |
||
21 | /** @var Connection|MockObject */ |
||
22 | private $conn; |
||
23 | |||
24 | /** @var DB2SchemaManager */ |
||
25 | private $manager; |
||
26 | |||
27 | protected function setUp() : void |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @see https://github.com/doctrine/dbal/issues/2701 |
||
42 | * |
||
43 | * @group DBAL-2701 |
||
44 | */ |
||
45 | public function testListTableNamesFiltersAssetNamesCorrectly() : void |
||
61 | ); |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return void |
||
66 | * |
||
67 | * @group DBAL-3692 |
||
68 | */ |
||
69 | public function testListAllTableNamesFiltersAssetNamesCorrectly() : void |
||
70 | { |
||
71 | $this->conn->getConfiguration()->setFilterSchemaAssetsExpression('/^(?!T_)/'); |
||
1 ignored issue
–
show
|
|||
72 | $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ |
||
73 | ['name' => 'FOO'], |
||
74 | ['name' => 'T_FOO'], |
||
75 | ['name' => 'BAR'], |
||
76 | ['name' => 'T_BAR'], |
||
77 | ])); |
||
78 | |||
79 | self::assertSame( |
||
80 | [ |
||
81 | 'FOO', |
||
82 | 'T_FOO', |
||
83 | 'BAR', |
||
84 | 'T_BAR', |
||
85 | ], |
||
86 | $this->manager->listAllTableNames() |
||
87 | ); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * @return void |
||
92 | * |
||
93 | * @group DBAL-3692 |
||
94 | */ |
||
95 | public function testTablesExistWithoutFilteredParameter() : void |
||
96 | { |
||
97 | $this->conn->getConfiguration()->setFilterSchemaAssetsExpression('/^(?!T_)/'); |
||
1 ignored issue
–
show
|
|||
98 | $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ |
||
99 | ['name' => 'FOO'], |
||
100 | ['name' => 'T_FOO'], |
||
101 | ])); |
||
102 | |||
103 | self::assertEquals(false, $this->manager->tablesExist('T_FOO')); |
||
104 | } |
||
105 | |||
106 | /** |
||
107 | * @return void |
||
108 | * |
||
109 | * @group DBAL-3692 |
||
110 | */ |
||
111 | public function testTablesExistWhithFilteredFalseParameter() : void |
||
112 | { |
||
113 | $this->conn->getConfiguration()->setFilterSchemaAssetsExpression('/^(?!T_)/'); |
||
1 ignored issue
–
show
|
|||
114 | $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ |
||
115 | ['name' => 'FOO'], |
||
116 | ['name' => 'T_FOO'], |
||
117 | ])); |
||
118 | |||
119 | self::assertEquals(true, $this->manager->allTablesExistInSchema(['T_FOO'])); |
||
120 | } |
||
121 | |||
122 | /** |
||
123 | * @group DBAL-2701 |
||
124 | */ |
||
125 | public function testAssetFilteringSetsACallable() : void |
||
126 | { |
||
127 | $filterExpression = '/^(?!T_)/'; |
||
128 | $this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression); |
||
1 ignored issue
–
show
|
|||
129 | $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ |
||
130 | ['name' => 'FOO'], |
||
131 | ['name' => 'T_FOO'], |
||
132 | ['name' => 'BAR'], |
||
133 | ['name' => 'T_BAR'], |
||
134 | ])); |
||
135 | |||
136 | self::assertSame( |
||
137 | [ |
||
138 | 'FOO', |
||
139 | 'BAR', |
||
140 | ], |
||
141 | $this->manager->listTableNames() |
||
142 | ); |
||
143 | |||
144 | $callable = $this->conn->getConfiguration()->getSchemaAssetsFilter(); |
||
145 | self::assertIsCallable($callable); |
||
146 | |||
147 | // BC check: Test that regexp expression is still preserved & accessible. |
||
148 | $this->assertEquals($filterExpression, $this->conn->getConfiguration()->getFilterSchemaAssetsExpression()); |
||
149 | } |
||
150 | |||
151 | public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable() : void |
||
152 | { |
||
153 | $accepted = ['T_FOO', 'T_BAR']; |
||
154 | $this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) { |
||
155 | return in_array($assetName, $accepted); |
||
156 | }); |
||
157 | $this->conn->expects($this->any())->method('quote'); |
||
158 | $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ |
||
159 | ['name' => 'FOO'], |
||
160 | ['name' => 'T_FOO'], |
||
161 | ['name' => 'BAR'], |
||
162 | ['name' => 'T_BAR'], |
||
163 | ])); |
||
164 | |||
165 | self::assertSame( |
||
166 | [ |
||
167 | 'T_FOO', |
||
168 | 'T_BAR', |
||
169 | ], |
||
170 | $this->manager->listTableNames() |
||
171 | ); |
||
172 | |||
173 | $this->assertNull($this->conn->getConfiguration()->getFilterSchemaAssetsExpression()); |
||
174 | } |
||
175 | |||
176 | public function testSettingNullExpressionWillResetCallable() : void |
||
211 | } |
||
212 | |||
213 | public function testSettingNullAsCallableClearsExpression() : void |
||
214 | { |
||
215 | $filterExpression = '/^(?!T_)/'; |
||
216 | $this->conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression); |
||
248 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.