/**
  * {@inheritDoc}
  */
 public function build(ItemInterface $menu, array $options = array(), $alias = null)
 {
     if (!$this->componentRegistry->hasAllowedProcessor()) {
         return;
     }
     $menu->addChild('orob2b.product.frontend.quick_add.title', ['route' => 'orob2b_product_frontend_quick_add', 'extras' => ['position' => 500, 'description' => 'orob2b.product.frontend.quick_add.description']]);
 }
 /**
  * @param bool $hasAllowedProcessor
  *
  * @dataProvider getBuildDataProvider
  */
 public function testBuild($hasAllowedProcessor)
 {
     $this->componentRegistry->expects($this->once())->method('hasAllowedProcessor')->willReturn($hasAllowedProcessor);
     /** @var \PHPUnit_Framework_MockObject_MockObject|\Knp\Menu\ItemInterface $menu */
     $menu = $this->getMock('Knp\\Menu\\ItemInterface');
     if ($hasAllowedProcessor) {
         $menu->expects($this->once())->method('addChild')->with('orob2b.product.frontend.quick_add.title', ['route' => 'orob2b_product_frontend_quick_add', 'extras' => ['position' => 500, 'description' => 'orob2b.product.frontend.quick_add.description']]);
     }
     $this->builder->build($menu);
 }
 public function testHasAllowedProcessor()
 {
     $processorAllowed = $this->getProcessorMock('allowed');
     $processorDisallowed = $this->getProcessorMock('disallowed');
     $registry = new ComponentProcessorRegistry();
     $registry->addProcessor($processorAllowed);
     $registry->addProcessor($processorDisallowed);
     $this->assertFalse($registry->hasAllowedProcessor());
     $processorAllowed->expects($this->once())->method('isAllowed')->willReturn(true);
     $this->assertTrue($registry->hasAllowedProcessor());
 }
 /**
  * @param bool $isValidationRequired
  * @param bool $isAllowed
  * @return \PHPUnit_Framework_MockObject_MockObject|ComponentProcessorInterface
  */
 protected function getProcessor($isValidationRequired = true, $isAllowed = true)
 {
     $processor = $this->getMock('OroB2B\\Bundle\\ProductBundle\\Model\\ComponentProcessorInterface');
     $processor->expects($this->any())->method('isValidationRequired')->willReturn($isValidationRequired);
     $processor->expects($this->any())->method('isAllowed')->willReturn($isAllowed);
     $this->componentRegistry->expects($this->once())->method('getProcessorByName')->with(self::COMPONENT_NAME)->willReturn($processor);
     return $processor;
 }
Ejemplo n.º 5
0
 /**
  * @param string $name
  * @return null|ComponentProcessorInterface
  */
 protected function getProcessor($name)
 {
     return $this->componentRegistry->getProcessorByName($name);
 }