Skip to content

Commit ab153e6

Browse files
committed
#13 new placeholders are overwritten with older versions if the key has been used
1 parent d607e69 commit ab153e6

File tree

3 files changed

+62
-3
lines changed

3 files changed

+62
-3
lines changed

lib/TestDbAcle/Commands/SetupTablesCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ public function execute()
5757
public function initialise(\TestDbAcle\ServiceLocator $serviceLocator)
5858
{
5959
$this->parser = $serviceLocator->get('parser');
60-
$this->filterQueue = $serviceLocator->createNew('dataInserterFilterQueue');
60+
61+
/**
62+
* We need to use a new copy of the filter, otherwise old placeholders will override new ones.
63+
*/
64+
$this->filterQueue = clone $serviceLocator->createNew('dataInserterFilterQueue');
6165
$this->dataInserter = $serviceLocator->get('dataInserter');
6266
$this->tableList = $serviceLocator->get('tableList');
6367
$this->tableFactory = $serviceLocator->get('tableFactory');

lib/TestDbAcle/PhpUnit/AbstractTestCase.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ protected function setAutoIncrement($table, $nextIncrement)
6565
protected function setupTables($psvContent, $replace = array())
6666
{
6767
$this->getDatabaseTestHelper()->runCommand(new \TestDbAcle\Commands\SetupTablesCommand($psvContent, $replace));
68-
// $this->getDatabaseTestHelper()->setupTablesWithPlaceholders($psvContent, $replace);
6968
}
7069

7170
/**

tests/Functional/tests/Php5_3/SmokeTest.php

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,63 @@ function test_SetupAndAssertWithPlaceholders()
214214

215215

216216
}
217-
217+
218+
/**
219+
* @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::execute()
220+
* @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::FilterTableStateByPsvCommand() with placeholders
221+
* @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::SetAutoIncrementCommand()
222+
* @covers \TestDbAcle::getDefaultFactories()
223+
*/
224+
225+
function test_SetupAndAssertWithPlaceholders_PlaceholdersAreNotReused()
226+
{
227+
228+
$this->setupTables("
229+
[address]
230+
address_id |company
231+
1 |me
232+
3 |you
233+
234+
[user]
235+
user_id |name
236+
1 |mary
237+
238+
",array('you'=>'Johnny'));
239+
240+
$this->setupTables("
241+
[address]
242+
address_id |company
243+
1 |me
244+
3 |you
245+
246+
[user]
247+
user_id |name
248+
1 |mary
249+
250+
",array('you'=>'John'));
251+
252+
$exampleService = new ExampleService($this->getPdo());
253+
254+
$this->setAutoIncrement('address', 1000);
255+
256+
$exampleService->addEntry("them");
257+
258+
259+
$this->assertTableStateContains("
260+
[address]
261+
address_id |company
262+
1 |me
263+
3 |John
264+
1000 |them
265+
266+
[user]
267+
user_id |name
268+
1 |mary
269+
");
270+
271+
272+
}
273+
218274
/**
219275
* @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::execute()
220276
* @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::FilterTableStateByPsvCommand() with placeholders

0 commit comments

Comments
 (0)