File tree Expand file tree Collapse file tree 2 files changed +90
-2
lines changed
tests/Functional/tests/Php5_3 Expand file tree Collapse file tree 2 files changed +90
-2
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,8 @@ public function execute()
3838 foreach ($ filteredParsedTree ->getTables () as $ table ){
3939 $ tableName = $ table ->getName ();
4040 $ expectedData [$ tableName ]=$ table ->toArray ();
41- $ columnsToSelect = array_keys ($ expectedData [$ tableName ][0 ]);
42- $ data = $ this ->pdoFacade ->getQuery ("select " . implode ( " , " , $ columnsToSelect). " from $ tableName " );
41+ $ columnsToSelect = isset ( $ expectedData [ $ tableName ][ 0 ]) ? implode ( " , " , array_keys ($ expectedData [$ tableName ][0 ])) : ' * ' ;
42+ $ data = $ this ->pdoFacade ->getQuery ("select $ columnsToSelect from $ tableName " );
4343 $ actualData [$ tableName ] = $ this ->truncateDatetimeFields ($ table , $ data );
4444 }
4545 $ this ->actualData = $ actualData ;
Original file line number Diff line number Diff line change @@ -215,7 +215,95 @@ function test_DatetimeColumnsGetTruncatedWhenComparing()
215215
216216 }
217217
218+ /**
219+ * @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::execute()
220+ * @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::FilterTableStateByPsvCommand()
221+ * @covers \TestDbAcle::getDefaultFactories()
222+ */
223+ function test_AssertTableStateContains_handlesEmptyTables ()
224+ {
225+
226+ $ this ->setupTables ("
227+ [address]
228+ address_id |company
229+
230+ [user]
231+
232+ " );
233+
234+ $ this ->assertTableStateContains ("
235+ [address]
236+ address_id |company
237+
238+
239+ [user]
240+
241+ " );
242+
243+ }
218244
245+ /**
246+ * @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::execute()
247+ * @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::FilterTableStateByPsvCommand()
248+ * @covers \TestDbAcle::getDefaultFactories()
249+ */
250+ function test_AssertTableStateContains_handlesEmptyTables_raisesExceptionIfEmptyExpectedButNotEmpty ()
251+ {
252+
253+ $ this ->setupTables ("
254+ [address]
255+ address_id |company
256+
257+ [user]
258+ user_id |name
259+ 1 |foo
260+
261+ " );
262+
263+ try {
264+ $ this ->assertTableStateContains ("
265+ [address]
266+ address_id |company
267+
268+
269+ [user]
270+ user_id |name
271+
272+ " );
273+ $ this ->fail ("assertTableStateContains fails if the information in the table is different " );
274+ } catch (\PHPUnit_Framework_ExpectationFailedException $ e ){
275+ //do nothing
276+ }
277+
278+ }
279+
280+ /**
281+ * @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::execute()
282+ * @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::FilterTableStateByPsvCommand()
283+ * @covers \TestDbAcle::getDefaultFactories()
284+ */
285+ function test_AssertTableStateContains_handlesEmptyTables_raisesExceptionIfEmptyExpectedButNotEmpty_EmptyTableSpecifiedWithoutColumns ()
286+ {
287+
288+ $ this ->setupTables ("
289+ [user]
290+ user_id |name
291+ 1 |foo
292+
293+ " );
294+
295+ try {
296+ $ this ->assertTableStateContains ("
297+ [user]
298+ user_id |name
299+
300+ " );
301+ $ this ->fail ("assertTableStateContains fails if the information in the table is different " );
302+ } catch (\PHPUnit_Framework_ExpectationFailedException $ e ){
303+ //do nothing
304+ }
305+
306+ }
219307}
220308
221309class ExampleService
You can’t perform that action at this time.
0 commit comments