/**
  * @dataProvider exclusionProvider
  *
  * @param bool  $expected
  * @param bool  $isChannelEntity
  * @param array $dependentDataMap
  * @param array $enabledEntityMap
  */
 public function testIsRelationExcluded($expected, $isChannelEntity, $dependentDataMap = [], $enabledEntityMap = [])
 {
     $this->settingsProvider->expects($this->any())->method('isChannelEntity')->will($this->returnValueMap([[self::TEST_MAIN_ENTITY_NAME, true], [self::TEST_ENTITY_NAME, $isChannelEntity]]));
     $this->settingsProvider->expects($this->any())->method('getDependentEntityData')->will($this->returnValueMap($dependentDataMap));
     $this->stateProvider->expects($this->any())->method('isEntityEnabled')->will($this->returnValueMap($enabledEntityMap));
     $classMetadataMock = $this->getMockBuilder('Doctrine\\ORM\\Mapping\\ClassMetadata')->disableOriginalConstructor()->getMock();
     $classMetadataMock->expects($this->once())->method('getName')->will($this->returnValue(self::TEST_MAIN_ENTITY_NAME));
     $classMetadataMock->expects($this->once())->method('getAssociationTargetClass')->with($this->equalTo(self::TEST_ASSOC_NAME))->will($this->returnValue(self::TEST_ENTITY_NAME));
     $this->assertSame($expected, $this->exclusionProvider->isIgnoredRelation($classMetadataMock, self::TEST_ASSOC_NAME));
 }
Example #2
0
 /**
  * @dataProvider navigationConfigureDataProvider
  *
  * @param array $settings
  * @param bool  $isEnabled
  * @param bool  $expectedResult
  */
 public function testOnNavigationConfigure($settings, $isEnabled, $expectedResult)
 {
     $factory = new MenuFactory();
     $this->resolver->expects($this->any())->method('resolve')->will($this->returnArgument(0));
     $this->state->expects($this->once())->method('isEntityEnabled')->will($this->returnValue($isEnabled));
     $settingsProvider = new SettingsProvider($settings, $this->resolver);
     $listener = new NavigationListener($settingsProvider, $this->state);
     $menu = new MenuItem('test_menu', $factory);
     $salesTab = new MenuItem('sales_tab', $factory);
     $salesTab->addChild('test_item')->setDisplay(false);
     $menu->addChild($salesTab);
     $this->assertFalse($salesTab->getChild('test_item')->isDisplayed());
     $eventData = new ConfigureMenuEvent($factory, $menu);
     $listener->onNavigationConfigure($eventData);
     $this->assertEquals($expectedResult, $salesTab->getChild('test_item')->isDisplayed());
 }