function ConfigEntityBaseUnitTest::testCalculateDependenciesWithThirdPartySettings

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

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

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