function ConfigEntityBaseUnitTest::testCalculateDependencies

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testCalculateDependencies()
  2. 8.9.x core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testCalculateDependencies()
  3. 10 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 173

Class

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

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testCalculateDependencies() : void {
    // 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']);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.