public function testCreateUserFormDataValidWillReturn201Response()
 {
     $this->formMock->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->useCaseMock->expects($this->once())->method('editPhoneNumber')->with($this->number, false);
     $view = $this->controller->editPhoneNumberAction($this->number, $this->createExampleRequest());
     $this->assertEquals(new View($this->number, 200), $view);
 }
 public function testAddNumberToUserValidationPassesWillProceedToSaveUser()
 {
     $number = $this->createExamplePhoneNumber();
     $this->repositoryMock->expects($this->once())->method('findById')->with(100)->will($this->returnValue($number));
     $this->validatorMock->expects($this->once())->method('validate')->with($number)->will($this->returnValue(new ConstraintViolationList()));
     $this->repositoryMock->expects($this->once())->method('save')->with($number);
     $this->useCase->editPhoneNumber($number);
 }
 /**
  * @param PhoneNumber $phoneNumber
  * @param Request $request
  * @return View
  */
 private function processForm(PhoneNumber $phoneNumber, Request $request)
 {
     $form = $this->formFactory->createNamed('', 'phone_number_edit', $phoneNumber);
     $form->handleRequest($request);
     if (!$form->isValid()) {
         return new View($form, 400);
     }
     $this->useCase->editPhoneNumber($phoneNumber, false);
     return new View($phoneNumber, 200);
 }