You are here

public function ConfigEntityBaseUnitTest::testCalculateDependenciesWithThirdPartySettings in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testCalculateDependenciesWithThirdPartySettings()

@covers ::calculateDependencies @covers ::getDependencies @covers ::onDependencyRemoval

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php, line 296
Contains \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest.

Class

ConfigEntityBaseUnitTest
@coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

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']);
}