/** * @covers ::calculateDependencies */ public function testCalculateDependencies() { $target_entity_type_id = $this->randomMachineName(16); $target_entity_type = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface'); $target_entity_type->expects($this->any())->method('getProvider')->will($this->returnValue('test_module')); $values = array('targetEntityType' => $target_entity_type_id); $this->entityManager->expects($this->at(0))->method('getDefinition')->with($target_entity_type_id)->will($this->returnValue($target_entity_type)); $this->entityManager->expects($this->at(1))->method('getDefinition')->with($this->entityType)->will($this->returnValue($this->entityInfo)); $this->entity = $this->getMockBuilder('\\Drupal\\Core\\Entity\\EntityDisplayModeBase')->setConstructorArgs(array($values, $this->entityType))->setMethods(array('getFilterFormat'))->getMock(); $dependencies = $this->entity->calculateDependencies()->getDependencies(); $this->assertContains('test_module', $dependencies['module']); }
/** * @covers ::calculateDependencies */ public function testCalculateDependenciesWithThirdPartySettings() { $this->entity = $this->getMockForAbstractClass('\\Drupal\\Tests\\Core\\Config\\Entity\\Fixtures\\ConfigEntityBaseWithThirdPartySettings', array(array(), $this->entityTypeId)); $this->entity->setThirdPartySetting('test_provider', 'test', 'test'); $this->entity->setThirdPartySetting('test_provider2', 'test', 'test'); $this->entity->setThirdPartySetting($this->provider, 'test', 'test'); $this->assertEquals(array('test_provider', 'test_provider2'), $this->entity->calculateDependencies()['module']); }
/** * @covers ::calculateDependencies */ public function testCalculateDependenciesTheme() { $this->setUpEntity(array('name' => 'test', 'source' => 'test_theme', 'sourceType' => Breakpoint::SOURCE_TYPE_THEME)); $breakpoint = $this->getMockBuilder('\\Drupal\\breakpoint\\Entity\\Breakpoint')->disableOriginalConstructor()->getMock(); $breakpoint->expects($this->once())->method('getConfigDependencyName')->will($this->returnValue('breakpoint.breakpoint.test')); $this->entity->expects($this->once())->method('getBreakpoints')->will($this->returnValue(array($breakpoint))); $dependencies = $this->entity->calculateDependencies(); $this->assertArrayNotHasKey('module', $dependencies); $this->assertContains('test_theme', $dependencies['theme']); $this->assertContains('breakpoint.breakpoint.test', $dependencies['entity']); }
/** * @covers ::calculateDependencies * @covers ::getDependencies * @covers ::onDependencyRemoval */ public function testCalculateDependenciesWithThirdPartySettings() { $this->entity = $this->getMockForAbstractClass('\\Drupal\\Core\\Config\\Entity\\ConfigEntityBase', array(array(), $this->entityTypeId)); $this->entity->setThirdPartySetting('test_provider', 'test', 'test'); $this->entity->setThirdPartySetting('test_provider2', 'test', 'test'); $this->entity->setThirdPartySetting($this->provider, 'test', 'test'); $this->assertEquals(array('test_provider', 'test_provider2'), $this->entity->calculateDependencies()->getDependencies()['module']); $changed = $this->entity->onDependencyRemoval(['module' => ['test_provider2']]); $this->assertTrue($changed, 'Calling onDependencyRemoval with an existing third party dependency provider returns TRUE.'); $changed = $this->entity->onDependencyRemoval(['module' => ['test_provider3']]); $this->assertFalse($changed, 'Calling onDependencyRemoval with a non-existing third party dependency provider returns FALSE.'); $this->assertEquals(array('test_provider'), $this->entity->calculateDependencies()->getDependencies()['module']); }
/** * @covers ::calculateDependencies * * @dataProvider providerCalculateDependenciesWithPluginBags */ public function testCalculateDependenciesWithPluginBags($definition, $expected_dependencies) { $values = array(); $this->entity = $this->getMockBuilder('\\Drupal\\Tests\\Core\\Config\\Entity\\Fixtures\\ConfigEntityBaseWithPluginBags')->setConstructorArgs(array($values, $this->entityTypeId))->setMethods(array('getPluginBags'))->getMock(); // Create a configurable plugin that would add a dependency. $instance_id = $this->randomName(); $instance = new TestConfigurablePlugin(array(), $instance_id, $definition); // Create a plugin bag to contain the instance. $pluginBag = $this->getMockBuilder('\\Drupal\\Core\\Plugin\\DefaultPluginBag')->disableOriginalConstructor()->setMethods(array('get'))->getMock(); $pluginBag->expects($this->atLeastOnce())->method('get')->with($instance_id)->will($this->returnValue($instance)); $pluginBag->addInstanceId($instance_id); // Return the mocked plugin bag. $this->entity->expects($this->once())->method('getPluginBags')->will($this->returnValue(array($pluginBag))); $this->assertEquals($expected_dependencies, $this->entity->calculateDependencies()); }
/** * @covers ::calculateDependencies */ public function testCalculateDependencies() { $this->assertSame([], $this->sut->calculateDependencies()); }