public function testCreateUserWithDisabledValidationWillProceedImmediatelyToSave() { $user = $this->createExampleUser(); $this->validatorMock->expects($this->never())->method('validate'); $this->repositoryMock->expects($this->once())->method('save')->with($user); $this->useCase->createUser($user, false); }
public function testListUsers() { $user1 = new User(); $user1->setFirstName('Wincenty')->setLastName('Kwiatek'); $user2 = new User(); $user2->setFirstName('Zenon')->setLastName('Majkowski'); $expectedUsers = [$user1, $user2]; $this->repositoryMock->expects($this->any())->method('search')->will($this->returnValue($expectedUsers)); $this->assertSame($expectedUsers, $this->useCase->listUsers()); }
public function testAddNumberToUserValidationPassesWillProceedToSaveUser() { $user = $this->createExampleUser(); $number = $this->createExamplePhoneNumber(); $this->userRepositoryMock->expects($this->once())->method('findById')->with(100)->will($this->returnValue($user)); $this->validatorMock->expects($this->once())->method('validate')->with($number)->will($this->returnValue(new ConstraintViolationList())); $this->numberRepositoryMock->expects($this->once())->method('save')->with($number); $this->useCase->addNumberToUser($number, $user); $this->assertSame($number, $user->getPhoneNumbers()->get(0)); $this->assertSame($user, $number->getOwner()); }
public function testGetUser() { $user = new User(); $this->repositoryMock->expects($this->once())->method('findById')->will($this->returnValue($user)); $this->assertSame($user, $this->useCase->getUser(1)); }
public function testRemoveExistingUserWillProceedWithRemovingFromRepository() { $this->repositoryMock->expects($this->once())->method('findById')->will($this->returnValue($this->createExampleUser())); $this->repositoryMock->expects($this->once())->method('remove'); $this->useCase->removeUser($this->createExampleUser()); }