You are here

public function ContentTranslationEntityBundleInfoTest::testHookInvocationOrder in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_translation/tests/src/Kernel/ContentTranslationEntityBundleInfoTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationEntityBundleInfoTest::testHookInvocationOrder()

Tests that modules can know whether bundles are translatable.

File

core/modules/content_translation/tests/src/Kernel/ContentTranslationEntityBundleInfoTest.php, line 62

Class

ContentTranslationEntityBundleInfoTest
Tests the Content Translation bundle info logic.

Namespace

Drupal\Tests\content_translation\Kernel

Code

public function testHookInvocationOrder() {
  $this->contentTranslationManager
    ->setEnabled('entity_test_mul', 'entity_test_mul', TRUE);
  $this->bundleInfo
    ->clearCachedBundles();
  $this->bundleInfo
    ->getAllBundleInfo();

  // Verify that the test module comes first in the module list, which would
  // normally make its hook implementation to be invoked first.

  /** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
  $module_handler = $this->container
    ->get('module_handler');
  $module_list = $module_handler
    ->getModuleList();
  $expected_modules = [
    'content_translation_test',
    'content_translation',
  ];
  $actual_modules = array_keys(array_intersect_key($module_list, array_flip($expected_modules)));
  $this
    ->assertEquals($expected_modules, $actual_modules);

  // Check that the "content_translation_test" hook implementation has access
  // to the "translatable" bundle info property.

  /** @var \Drupal\Core\State\StateInterface $state */
  $state = $this->container
    ->get('state');
  $this
    ->assertTrue($state
    ->get('content_translation_test.translatable'));
}