Skip to content

Commit a981068

Browse files
author
Malte Riesch
committed
1 parent 795cd93 commit a981068

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

lib/TestDbAcle/Db/DataInserter/DataInserter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function process(\TestDbAcle\Psv\PsvTree $tableList)
3434

3535
public function processTable(\TestDbAcle\Psv\Table\Table $table)
3636
{
37-
if(!$table->getMeta()->isReplaceMode()){
37+
if(!$table->getMeta()->isReplaceMode() && !$table->getMeta()->isAppendMode()){
3838
$this->pdoFacade->clearTable($table->getName());
3939
}
4040
foreach ($table->toArray() as $valuesToBeInserted) {

lib/TestDbAcle/Psv/Table/Meta.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ public function isReplaceMode()
3737
{
3838
return $this->getAttribute('mode') == 'replace';
3939
}
40-
40+
41+
public function isAppendMode()
42+
{
43+
return $this->getAttribute('mode') == 'append';
44+
}
45+
4146
public function getIdentifyColumns()
4247
{
4348
return (array) $this->getAttribute('identifiedBy', array());

tests/Functional/tests/Php5_3/SmokeTest.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,48 @@ function test_simpleSetupAndAssertTableStateContains()
8686
}
8787

8888
}
89+
90+
/**
91+
* @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::execute()
92+
* @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::FilterTableStateByPsvCommand()
93+
* @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::SetAutoIncrementCommand()
94+
* @covers \TestDbAcle::getDefaultFactories()
95+
*/
96+
function test_SetupCanAppendData()
97+
{
98+
99+
$this->setupTables("
100+
[address]
101+
address_id |company
102+
1 |me
103+
3 |you
104+
105+
[user]
106+
user_id |name
107+
1 |mary
108+
109+
");
110+
111+
112+
$this->setupTables("
113+
[address|mode:append]
114+
company |city
115+
them |london
116+
117+
");
118+
119+
$this->assertTableStateContains("
120+
[address]
121+
address_id |company |city
122+
1 |me |T #T is the default for non-null text
123+
3 |you |T
124+
4 |them |london
125+
126+
[user]
127+
user_id |name
128+
1 |mary
129+
", array('NOW'=>date("Y-m-d")));
130+
}
89131

90132
/**
91133
* @covers \TestDbAcle\Commands\FilterTableStateByPsvCommand::execute()

0 commit comments

Comments
 (0)