1
0
mirror of https://github.com/DesignPatternsPHP/DesignPatternsPHP.git synced 2025-05-19 21:10:45 +02:00

bugfix in UserMapper::findAll

This commit is contained in:
Florent 2013-07-08 09:38:42 +02:00
parent ff0159e21c
commit 89f1e64ad0
2 changed files with 19 additions and 5 deletions
DataMapper
Tests/DataMapper

@ -96,9 +96,9 @@ class UserMapper
foreach ($resultSet as $row) {
$entry = new User();
$user->setUserID($row['userid']);
$user->setUsername($row['username']);
$user->setEmail($row['email']);
$entry->setUserID($row['userid']);
$entry->setUsername($row['username']);
$entry->setEmail($row['email']);
$entries[] = $entry;
}

@ -61,7 +61,7 @@ class UserMapperTest extends \PHPUnit_Framework_TestCase
/**
* @dataProvider getExistingUser
*/
public function testRestoreOne()
public function testRestoreOne(User $existing)
{
$rows = new \ArrayIterator([['userid' => 1, 'username' => 'Odysseus', 'email' => 'Odysseus@ithaca.gr']]);
$this->dbal->expects($this->once())
@ -70,7 +70,21 @@ class UserMapperTest extends \PHPUnit_Framework_TestCase
->will($this->returnValue($rows));
$user = $this->mapper->findById(1);
echo "Hello " . $user->getUsername() . ". Your email is " . $user->getEmail();
$this->assertEquals($existing, $user);
}
/**
* @dataProvider getExistingUser
*/
public function testRestoreMulti(User $existing)
{
$rows = [['userid' => 1, 'username' => 'Odysseus', 'email' => 'Odysseus@ithaca.gr']];
$this->dbal->expects($this->once())
->method('findAll')
->will($this->returnValue($rows));
$user = $this->mapper->findAll();
$this->assertEquals([$existing], $user);
}
}