diff --git a/DataMapper/User.php b/DataMapper/User.php index 6733ade..f8aa770 100644 --- a/DataMapper/User.php +++ b/DataMapper/User.php @@ -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; diff --git a/Tests/DataMapper/UserMapperTest.php b/Tests/DataMapper/UserMapperTest.php index a1c2adb..0544b54 100644 --- a/Tests/DataMapper/UserMapperTest.php +++ b/Tests/DataMapper/UserMapperTest.php @@ -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();