Esempio n. 1
0
 /**
  * Updates default values
  *
  * @param FormEvent $event
  */
 public function setDefaultValues(FormEvent $event)
 {
     /** @var WorkflowData $workflowData */
     $workflowData = $event->getData();
     foreach ($this->defaultValues as $attributeName => $value) {
         $workflowData->set($attributeName, $this->contextAccessor->getValue($this->workflowItem, $value));
     }
 }
Esempio n. 2
0
 public function testExecuteAction()
 {
     $options = ['html' => '$.html', 'attribute' => '$.attribute'];
     $fakeContext = ['fake', 'things', 'are', 'here'];
     $this->contextAccessor->expects($this->once())->method('getValue')->with($this->equalTo($fakeContext), $this->equalTo('$.html'))->will($this->returnValue($html = '<html></html>'));
     $this->contextAccessor->expects($this->once())->method('setValue')->with($this->equalTo($fakeContext), $this->equalTo('$.attribute'), $this->equalTo($stripped = 'stripped'));
     $this->helper->expects($this->once())->method('purify')->with($this->equalTo($html))->will($this->returnValue($purified = 'purified'));
     $this->helper->expects($this->once())->method('stripTags')->with($this->equalTo($purified))->will($this->returnValue($stripped));
     $this->action->initialize($options);
     $this->action->execute($fakeContext);
 }
 public function testGetValueNoSuchProperty()
 {
     $context = $this->createObject(array());
     $value = new PropertyPath('test');
     $propertyAccessor = $this->getMockBuilder('Symfony\\Component\\PropertyAccess\\PropertyAccessor')->disableOriginalConstructor()->setMethods(array('getValue'))->getMock();
     $propertyAccessor->expects($this->once())->method('getValue')->with($context, $value)->will($this->throwException(new NoSuchPropertyException('No such property')));
     $propertyAccessorReflection = new \ReflectionProperty('Oro\\Bundle\\WorkflowBundle\\Model\\ContextAccessor', 'propertyAccessor');
     $propertyAccessorReflection->setAccessible(true);
     $propertyAccessorReflection->setValue($this->contextAccessor, $propertyAccessor);
     $this->assertNull($this->contextAccessor->getValue($context, $value));
 }
Esempio n. 4
0
 /**
  * {@inheritDoc}
  */
 public function isAllowed($context, Collection $errors = null)
 {
     if (null !== $this->channel) {
         /** @var Channel $dataChannel */
         $dataChannel = $this->contextAccessor->getValue($context, $this->channel);
         $entities = $dataChannel->getEntities();
         $allowed = count(array_intersect($this->entities, $entities)) === count($this->entities);
     } else {
         $allowed = $this->stateProvider->isEntitiesEnabledInSomeChannel($this->entities);
     }
     return $allowed;
 }
Esempio n. 5
0
 /**
  * Check ACL for resource.
  *
  * @param mixed $context
  * @return boolean
  */
 protected function isConditionAllowed($context)
 {
     $attributes = $this->contextAccessor->getValue($context, $this->attributes);
     $objectOrClass = $this->contextAccessor->getValue($context, $this->objectOrClass);
     if (is_object($objectOrClass)) {
         $unitOfWork = $this->doctrineHelper->getEntityManager($objectOrClass)->getUnitOfWork();
         if (!$unitOfWork->isInIdentityMap($objectOrClass) || $unitOfWork->isScheduledForInsert($objectOrClass)) {
             $objectOrClass = 'Entity:' . $this->doctrineHelper->getEntityClass($objectOrClass);
         }
     }
     return $this->securityFacade->isGranted($attributes, $objectOrClass);
 }
Esempio n. 6
0
 public function testExecuteAction()
 {
     $email = new Email();
     $options = ['process_type' => 'demo', 'email' => '$.email', 'attribute' => '$.attribute'];
     $fakeContext = ['fake', 'things', 'are', 'here'];
     $mailboxes = [new Mailbox()];
     $this->contextAccessor->expects($this->at(0))->method('getValue')->with($this->equalTo($fakeContext), $this->equalTo('demo'))->will($this->returnValue('demo'));
     $this->contextAccessor->expects($this->at(1))->method('getValue')->with($this->equalTo($fakeContext), $this->equalTo('$.email'))->will($this->returnValue($email));
     $this->contextAccessor->expects($this->once())->method('setValue')->with($this->equalTo($fakeContext), $this->equalTo('$.attribute'), $this->equalTo($mailboxes));
     $this->repository->expects($this->once())->method('findBySettingsClassAndEmail')->with($this->equalTo('DemoProcessSettings'), $this->equalTo($email))->will($this->returnValue($mailboxes));
     $this->action->initialize($options);
     $this->action->execute($fakeContext);
 }
 /**
  * @param array $options
  * @param mixed $context
  *
  * @dataProvider executeOptionsDataProvider
  */
 public function testExecute(array $options, $context)
 {
     $matched = new \stdClass();
     $this->automaticDiscovery->expects($this->once())->method('discoverSimilar')->willReturn($matched);
     $this->action->initialize($options);
     $this->action->execute($context);
     $this->assertSame($matched, $this->contextAccessor->getValue($context, new PropertyPath('attribute')));
 }
Esempio n. 8
0
 /**
  * @param mixed $context
  * @param mixed $identifier
  * @return mixed
  */
 protected function convertIdentifier($context, $identifier)
 {
     if (is_array($identifier)) {
         foreach ($identifier as $key => $value) {
             $identifier[$key] = $this->contextAccessor->getValue($context, $value);
         }
     } else {
         $identifier = $this->contextAccessor->getValue($context, $identifier);
     }
     return $identifier;
 }
Esempio n. 9
0
 public function testExecuteActionWithoutAttribute()
 {
     $options = ['email' => '$.email', 'target_entity' => '$.target_entity'];
     $fakeContext = ['fake', 'things', 'are', 'here'];
     $this->contextAccessor->expects($this->at(0))->method('getValue')->with($this->equalTo($fakeContext), $this->equalTo('$.email'))->will($this->returnValue($email = new Email()));
     $this->contextAccessor->expects($this->at(1))->method('getValue')->with($this->equalTo($fakeContext), $this->equalTo('$.target_entity'))->will($this->returnValue($target = new User()));
     $this->contextAccessor->expects($this->never())->method('setValue');
     $this->activityListChainProvider->expects($this->any())->method('getActivityListEntitiesByActivityEntity')->with($this->equalTo($email))->will($this->returnValue($list = new ActivityList()));
     $this->entityManager->expects($this->once())->method('persist')->with($this->equalTo($list));
     $this->emailActivityManager->expects($this->once())->method('addAssociation')->with($this->equalTo($email), $this->equalTo($target))->will($this->returnValue(true));
     $this->action->initialize($options);
     $this->action->execute($fakeContext);
 }
Esempio n. 10
0
 /**
  * Returns TRUE is target is empty in context
  *
  * @param mixed $context
  * @return boolean
  */
 protected function isConditionAllowed($context)
 {
     $value = $this->contextAccessor->getValue($context, $this->target);
     return '' === $value || null === $value;
 }
Esempio n. 11
0
 /**
  * {@inheritdoc}
  */
 protected function isConditionAllowed($context)
 {
     $type = $this->contextAccessor->getValue($context, $this->type);
     return (bool) $this->getActiveIntegration($type);
 }
 /**
  * Gets value of Workflow Item by path
  *
  * @param WorkflowItem $workflowItem
  * @param \Symfony\Component\PropertyAccess\PropertyPath $path
  * @return mixed
  */
 public function getValueByPropertyPath(WorkflowItem $workflowItem, $path)
 {
     return $this->contextAccessor->getValue($workflowItem, $path);
 }
Esempio n. 13
0
 /**
  * Check if values equals.
  *
  * @param mixed $context
  * @return boolean
  */
 protected function isConditionAllowed($context)
 {
     return $this->contextAccessor->hasValue($context, $this->target);
 }
Esempio n. 14
0
 /**
  * Check if values equals.
  *
  * @param mixed $context
  * @return boolean
  */
 protected function isConditionAllowed($context)
 {
     return $this->doCompare($this->contextAccessor->getValue($context, $this->left), $this->contextAccessor->getValue($context, $this->right));
 }