function ContentLanguageSettingsUnitTest::testCalculateDependencies

Same name in other branches
  1. 9 core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php \Drupal\Tests\language\Unit\ContentLanguageSettingsUnitTest::testCalculateDependencies()
  2. 8.9.x core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php \Drupal\Tests\language\Unit\ContentLanguageSettingsUnitTest::testCalculateDependencies()
  3. 11.x core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php \Drupal\Tests\language\Unit\ContentLanguageSettingsUnitTest::testCalculateDependencies()

@covers ::calculateDependencies

File

core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php, line 91

Class

ContentLanguageSettingsUnitTest
@coversDefaultClass \Drupal\language\Entity\ContentLanguageSettings @group language

Namespace

Drupal\Tests\language\Unit

Code

public function testCalculateDependencies() : void {
    // Mock the interfaces necessary to create a dependency on a bundle entity.
    $target_entity_type = $this->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
    $target_entity_type->expects($this->any())
        ->method('getBundleConfigDependency')
        ->willReturn([
        'type' => 'config',
        'name' => 'test.test_entity_type.id',
    ]);
    $this->entityTypeManager
        ->expects($this->any())
        ->method('getDefinition')
        ->with('test_entity_type')
        ->willReturn($target_entity_type);
    $config = new ContentLanguageSettings([
        'target_entity_type_id' => 'test_entity_type',
        'target_bundle' => 'test_bundle',
    ], 'language_content_settings');
    $dependencies = $config->calculateDependencies()
        ->getDependencies();
    $this->assertContains('test.test_entity_type.id', $dependencies['config']);
}

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