You are here

public function ConfigEntityBaseUnitTest::testCalculateDependenciesWithThirdPartySettings in Drupal 9

Same name and namespace in other branches
  1. 8 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 334
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', [
    [],
    $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([
    '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([
    'test_provider',
  ], $this->entity
    ->calculateDependencies()
    ->getDependencies()['module']);
}