Example #1
0
 /**
  * {@inheritdoc}
  */
 public function isAllowed($context, Collection $errors = null)
 {
     if (!$this->condition) {
         $this->condition = $this->assembler->assemble($this->configuration);
     }
     return $this->condition->isAllowed($context, $errors);
 }
 /**
  * @dataProvider configurationDataProvider
  * @param $configuration
  * @param $expected
  */
 public function testAssemble($configuration, $expected)
 {
     $factory = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\Condition\\ConditionFactory')->disableOriginalConstructor()->getMock();
     $factory->expects($this->any())->method('create')->will($this->returnCallback(function ($type, $options) {
         return array('_' . $type => $options);
     }));
     $configurationPass = $this->getMockBuilder('Oro\\Bundle\\WorkflowBundle\\Model\\ConfigurationPass\\ConfigurationPassInterface')->getMockForAbstractClass();
     $configurationPass->expects($this->any())->method('passConfiguration')->will($this->returnCallback(function ($options) {
         return array('passed' => $options);
     }));
     $assembler = new ConditionAssembler($factory);
     $assembler->addConfigurationPass($configurationPass);
     $actual = $assembler->assemble($configuration);
     $this->assertEquals($expected, $actual);
 }