Exemplo n.º 1
0
 /**
  * @dataProvider getDataProvider
  */
 public function testOnBuildMetadata($keys, $calls)
 {
     $config = $this->getMock('Oro\\Bundle\\EntityConfigBundle\\Config\\ConfigInterface');
     $this->configProvider->expects($this->any())->method('getConfig')->willReturn($config);
     $config->expects($this->exactly($calls))->method('get')->willReturn('label');
     $i = 0;
     $k = array_keys($keys);
     foreach ($k as $key) {
         $i++;
         $fieldMetadataOptions = ['display' => true, 'activity' => true, 'type' => $key, 'field_name' => $key, 'is_collection' => true, 'template' => 'OroActivityListBundle:Merge:value.html.twig', 'label' => 'Items', 'merge_modes' => [MergeModes::ACTIVITY_UNITE, MergeModes::ACTIVITY_REPLACE]];
         $fieldMetadata = new FieldMetadata($fieldMetadataOptions);
         $this->entityMetadata->expects($this->at($i))->method('addFieldMetadata')->with($this->equalTo($fieldMetadata));
     }
     $this->activityManager->expects($this->once())->method('getActivities')->willReturn($keys);
     $event = new EntityMetadataEvent($this->entityMetadata);
     $this->listener->onBuildMetadata($event);
 }
Exemplo n.º 2
0
 /**
  * @dataProvider supportedMethods
  *
  * @param string $method
  */
 public function testProcessValidDataWithTargetEntityActivity($method)
 {
     $targetEntity = new TestTarget(123);
     $action = 'activity';
     $this->request->setMethod($method);
     $this->form->expects($this->once())->method('setData')->with($this->identicalTo($this->entity));
     $this->form->expects($this->once())->method('submit')->with($this->identicalTo($this->request));
     $this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $this->entityRoutingHelper->expects($this->once())->method('getAction')->with($this->identicalTo($this->request))->will($this->returnValue($action));
     $this->entityRoutingHelper->expects($this->once())->method('getEntityClassName')->with($this->identicalTo($this->request))->will($this->returnValue(get_class($targetEntity)));
     $this->entityRoutingHelper->expects($this->once())->method('getEntityId')->with($this->identicalTo($this->request))->will($this->returnValue($targetEntity->getId()));
     $this->entityRoutingHelper->expects($this->once())->method('getEntityReference')->with(get_class($targetEntity), $targetEntity->getId())->will($this->returnValue($targetEntity));
     $this->activityManager->expects($this->once())->method('addActivityTarget')->with($this->identicalTo($this->entity), $this->identicalTo($targetEntity));
     $this->om->expects($this->once())->method('persist')->with($this->identicalTo($this->entity));
     $this->om->expects($this->once())->method('flush');
     $this->assertTrue($this->handler->process($this->entity));
 }