class LocaleTranslationProjectsTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/locale/tests/src/Kernel/LocaleTranslationProjectsTest.php \Drupal\Tests\locale\Kernel\LocaleTranslationProjectsTest
- 9 core/modules/locale/tests/src/Kernel/LocaleTranslationProjectsTest.php \Drupal\Tests\locale\Kernel\LocaleTranslationProjectsTest
Tests locale translation project handling.
@group locale
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\Tests\locale\Kernel\LocaleTranslationProjectsTest
Expanded class hierarchy of LocaleTranslationProjectsTest
File
- core/
modules/ locale/ tests/ src/ Kernel/ LocaleTranslationProjectsTest.php, line 12
Namespace
Drupal\Tests\locale\KernelView 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());
}
}