diff --git a/Tests/DataMapper/UserMapperTest.php b/Tests/DataMapper/UserMapperTest.php new file mode 100644 index 0000000..0107280 --- /dev/null +++ b/Tests/DataMapper/UserMapperTest.php @@ -0,0 +1,61 @@ +dbal = $this->getMockBuilder('DesignPatterns\DataMapper\DBAL') + ->disableAutoload() + ->setMethods(array('insert', 'update', 'find', 'findAll')) + ->getMock(); + + $this->mapper = new UserMapper($this->dbal); + } + + public function getNewUser() + { + return array(array(new User(null, 'Odysseus', 'Odysseus@ithaca.gr'))); + } + + public function getExistingUser() + { + return array(array(new User(1, 'Odysseus', 'Odysseus@ithaca.gr'))); + } + + /** + * @dataProvider getNewUser + */ + public function testPersistNew(User $user) + { + $this->dbal->expects($this->once()) + ->method('insert'); + $this->mapper->save($user); + } + + /** + * @dataProvider getExistingUser + */ + public function testPersistExisting(User $user) + { + $this->dbal->expects($this->once()) + ->method('update'); + $this->mapper->save($user); + } + +} \ No newline at end of file