You are here

public function ContentLanguageSettingsUnitTest::testCalculateDependencies in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php \Drupal\Tests\language\Unit\ContentLanguageSettingsUnitTest::testCalculateDependencies()
  2. 9 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 86

Class

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

Namespace

Drupal\Tests\language\Unit

Code

public function testCalculateDependencies() {

  // 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')
    ->will($this
    ->returnValue([
    'type' => 'config',
    'name' => 'test.test_entity_type.id',
  ]));
  $this->entityTypeManager
    ->expects($this
    ->any())
    ->method('getDefinition')
    ->with('test_entity_type')
    ->will($this
    ->returnValue($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']);
}