Example #1
0
 /**
  * @param Channel $entity
  * @param mixed $requestValue
  * @param string $expectedType
  *
  * @dataProvider handleRequestDataProvider
  */
 public function testHandleRequestChannelType(Channel $entity, $requestValue, $expectedType)
 {
     $this->request->setMethod('GET');
     $expectedEntity = clone $entity;
     $expectedEntity->setChannelType($expectedType);
     $this->form->expects($this->once())->method('setData')->with($expectedEntity);
     $this->form->expects($this->never())->method('submit');
     $this->dispatcher->expects($this->never())->method('dispatch');
     $this->request->request->set('orocrm_channel_form', ['channelType' => $requestValue]);
     $this->handler->process($entity);
 }
Example #2
0
 /**
  * @dataProvider formViewDataProvider
  *
  * @param bool $isUpdateMode
  */
 public function testGetFormView($isUpdateMode)
 {
     $this->request->query->set(ChannelHandler::UPDATE_MARKER, $isUpdateMode);
     $form = $this->form;
     if ($isUpdateMode) {
         $form = $this->getMock('Symfony\\Component\\Form\\Test\\FormInterface');
         $formConfig = $this->getMock('Symfony\\Component\\Form\\FormConfigInterface');
         $formFactory = $this->getMock('Symfony\\Component\\Form\\FormFactoryInterface');
         $formType = $this->getMock('Symfony\\Component\\Form\\ResolvedFormTypeInterface');
         $formConfig->expects($this->once())->method('getFormFactory')->will($this->returnValue($formFactory));
         $formConfig->expects($this->once())->method('getType')->will($this->returnValue($formType));
         $formType->expects($this->once())->method('getName')->will($this->returnValue('type' . self::TEST_NAME));
         $this->form->expects($this->once())->method('getName')->will($this->returnValue('form' . self::TEST_NAME));
         $this->form->expects($this->once())->method('getConfig')->will($this->returnValue($formConfig));
         $formFactory->expects($this->once())->method('createNamed')->will($this->returnValue($form));
     }
     $form->expects($this->once())->method('createView')->will($this->returnValue($this->getFormView()));
     $this->assertInstanceOf('Symfony\\Component\\Form\\FormView', $this->handler->getFormView());
 }