You are here

public function ConfigEntityBaseUnitTest::testCalculateDependencies in Drupal 8

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

@covers ::calculateDependencies @covers ::getDependencies

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php, line 169
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 testCalculateDependencies() {

  // Calculating dependencies will reset the dependencies array.
  $this->entity
    ->set('dependencies', [
    'module' => [
      'node',
    ],
  ]);
  $this
    ->assertEmpty($this->entity
    ->calculateDependencies()
    ->getDependencies());

  // Calculating dependencies will reset the dependencies array using enforced
  // dependencies.
  $this->entity
    ->set('dependencies', [
    'module' => [
      'node',
    ],
    'enforced' => [
      'module' => 'views',
    ],
  ]);
  $dependencies = $this->entity
    ->calculateDependencies()
    ->getDependencies();
  $this
    ->assertStringContainsString('views', $dependencies['module']);
  $this
    ->assertStringNotContainsString('node', $dependencies['module']);
}