You are here

class LocaleTranslationProjectsTest in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/locale/tests/src/Kernel/LocaleTranslationProjectsTest.php \Drupal\Tests\locale\Kernel\LocaleTranslationProjectsTest
  2. 9 core/modules/locale/tests/src/Kernel/LocaleTranslationProjectsTest.php \Drupal\Tests\locale\Kernel\LocaleTranslationProjectsTest

Tests locale translation project handling.

@group locale

Hierarchy

Expanded class hierarchy of LocaleTranslationProjectsTest

File

core/modules/locale/tests/src/Kernel/LocaleTranslationProjectsTest.php, line 12

Namespace

Drupal\Tests\locale\Kernel
View source
class LocaleTranslationProjectsTest extends KernelTestBase {

  /**
   * {@inheritdoc}
   */
  protected static $modules = [
    'locale',
    'locale_test',
    'system',
  ];

  /**
   * The module handler used in this test.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * The locale project storage used in this test.
   *
   * @var \Drupal\locale\LocaleProjectStorageInterface
   */
  protected $projectStorage;

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->moduleHandler = $this->container
      ->get('module_handler');
    $this->projectStorage = $this->container
      ->get('locale.project');
    \Drupal::state()
      ->set('locale.remove_core_project', TRUE);
  }

  /**
   * Tests locale_translation_clear_cache_projects().
   */
  public function testLocaleTranslationClearCacheProjects() {
    $this->moduleHandler
      ->loadInclude('locale', 'inc', 'locale.translation');
    $expected = [];
    $this
      ->assertSame($expected, locale_translation_get_projects());
    $this->projectStorage
      ->set('foo', []);
    $expected['foo'] = new \stdClass();
    $this
      ->assertEquals($expected, locale_translation_get_projects());
    $this->projectStorage
      ->set('bar', []);
    locale_translation_clear_cache_projects();
    $expected['bar'] = new \stdClass();
    $this
      ->assertEquals($expected, locale_translation_get_projects());
  }

}

Members