Skip to content

Commit 79a2434

Browse files
author
Marco Bunge
committed
Update unit of work
1 parent a05a31c commit 79a2434

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/UnitOfWork.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ public function commit()
182182
{
183183

184184
$connection = $this->connection;
185+
$this->processed = [];
186+
$this->modified = [];
185187

186188
try {
187189
$connection->beginTransaction();

tests/IntegrationTest.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,32 @@ public function testUoWIntegration()
174174
$this->assertEquals($foundResult['username'], $foundUserEntity->getUsername());
175175
}
176176

177+
$firstPost = $postMapper->find(['id' => 1]);
178+
/** @var PostEntity $secondPost */
179+
$secondPost = $postMapper->find(['id' => 2]);
180+
$secondPost->setContent('Bam');
181+
$thirdPost = new PostEntity();
182+
$thirdPost->setContent('FooBar');
183+
184+
$firstUser = $userMapper->find(['id' => 1]);
185+
/** @var UserEntity $secondUser */
186+
$secondUser = $userMapper->find(['id' => 2]);
187+
$secondUser->setUsername('Andrew');
188+
$thirdUser = new UserEntity();
189+
$thirdUser->setUsername('Rudy');
190+
191+
$unitOfWork->delete($firstUser);
192+
$unitOfWork->delete($firstPost);
193+
$unitOfWork->update($secondUser);
194+
$unitOfWork->update($secondPost);
195+
$unitOfWork->create($thirdUser);
196+
$unitOfWork->create($thirdPost);
197+
198+
$unitOfWork->commit();
199+
177200
if(true){
178201

179202
}
203+
180204
}
181205
}

0 commit comments

Comments
 (0)