mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-07-26 17:50:11 +02:00
test restore with find
This commit is contained in:
@@ -14,7 +14,7 @@ class User
|
|||||||
protected $username;
|
protected $username;
|
||||||
protected $email;
|
protected $email;
|
||||||
|
|
||||||
public function __construct($id, $username, $email)
|
public function __construct($id = null, $username = null, $email = null)
|
||||||
{
|
{
|
||||||
$this->userId = $id;
|
$this->userId = $id;
|
||||||
$this->username = $username;
|
$this->username = $username;
|
||||||
|
@@ -61,12 +61,13 @@ class UserMapperTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @dataProvider getExistingUser
|
* @dataProvider getExistingUser
|
||||||
*/
|
*/
|
||||||
public function testRestoreOne(User $stored)
|
public function testRestoreOne()
|
||||||
{
|
{
|
||||||
|
$rows = new \ArrayIterator([['userid' => 1, 'username' => 'Odysseus', 'email' => 'Odysseus@ithaca.gr']]);
|
||||||
$this->dbal->expects($this->once())
|
$this->dbal->expects($this->once())
|
||||||
->method('find')
|
->method('find')
|
||||||
->with(1)
|
->with(1)
|
||||||
->will($this->returnValue(new \ArrayIterator(array($stored))));
|
->will($this->returnValue($rows));
|
||||||
|
|
||||||
$user = $this->mapper->findById(1);
|
$user = $this->mapper->findById(1);
|
||||||
echo "Hello " . $user->getUsername() . ". Your email is " . $user->getEmail();
|
echo "Hello " . $user->getUsername() . ". Your email is " . $user->getEmail();
|
||||||
|
Reference in New Issue
Block a user