예제 #1
0
 public function testProcessValidData()
 {
     $this->request->setMethod('POST');
     $this->form->expects($this->once())->method('setData')->with($this->entity);
     $this->form->expects($this->once())->method('submit')->with($this->request);
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->registry->expects($this->any())->method('getManager')->will($this->returnValue($this->em));
     $this->em->expects($this->once())->method('persist')->with($this->entity);
     $this->em->expects($this->once())->method('flush');
     $this->dispatcher->expects($this->once())->method('dispatch')->with($this->equalTo(ChannelSaveEvent::EVENT_NAME), $this->isInstanceOf('OroCRM\\Bundle\\ChannelBundle\\Event\\ChannelSaveEvent'));
     $this->assertTrue($this->handler->process($this->entity));
 }
예제 #2
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);
 }