mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-05-21 22:09:43 +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) {
|
foreach ($resultSet as $row) {
|
||||||
|
|
||||||
$entry = new User();
|
$entry = new User();
|
||||||
$user->setUserID($row['userid']);
|
$entry->setUserID($row['userid']);
|
||||||
$user->setUsername($row['username']);
|
$entry->setUsername($row['username']);
|
||||||
$user->setEmail($row['email']);
|
$entry->setEmail($row['email']);
|
||||||
|
|
||||||
$entries[] = $entry;
|
$entries[] = $entry;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ class UserMapperTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider getExistingUser
|
* @dataProvider getExistingUser
|
||||||
*/
|
*/
|
||||||
public function testRestoreOne()
|
public function testRestoreOne(User $existing)
|
||||||
{
|
{
|
||||||
$rows = new \ArrayIterator([['userid' => 1, 'username' => 'Odysseus', 'email' => 'Odysseus@ithaca.gr']]);
|
$rows = new \ArrayIterator([['userid' => 1, 'username' => 'Odysseus', 'email' => 'Odysseus@ithaca.gr']]);
|
||||||
$this->dbal->expects($this->once())
|
$this->dbal->expects($this->once())
|
||||||
@ -70,7 +70,21 @@ class UserMapperTest extends \PHPUnit_Framework_TestCase
|
|||||||
->will($this->returnValue($rows));
|
->will($this->returnValue($rows));
|
||||||
|
|
||||||
$user = $this->mapper->findById(1);
|
$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