test restore with find

This commit is contained in:
Florent
2013-07-08 09:28:57 +02:00
parent 6cedf6656c
commit ff0159e21c
2 changed files with 4 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ class User
protected $username;
protected $email;
public function __construct($id, $username, $email)
public function __construct($id = null, $username = null, $email = null)
{
$this->userId = $id;
$this->username = $username;

View File

@@ -61,12 +61,13 @@ class UserMapperTest extends \PHPUnit_Framework_TestCase
/**
* @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())
->method('find')
->with(1)
->will($this->returnValue(new \ArrayIterator(array($stored))));
->will($this->returnValue($rows));
$user = $this->mapper->findById(1);
echo "Hello " . $user->getUsername() . ". Your email is " . $user->getEmail();