mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-05-20 13:30:57 +02:00
bugfix in UserMapper::findAll
This commit is contained in:
parent
ff0159e21c
commit
89f1e64ad0
@ -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);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user