annotate core/modules/locale/tests/src/Kernel/LocaleTranslationProjectsTest.php @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 129ea1e6d783
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\Tests\locale\Kernel;
Chris@0 4
Chris@0 5 use Drupal\KernelTests\KernelTestBase;
Chris@0 6
Chris@0 7 /**
Chris@0 8 * Tests locale translation project handling.
Chris@0 9 *
Chris@0 10 * @group locale
Chris@0 11 */
Chris@0 12 class LocaleTranslationProjectsTest extends KernelTestBase {
Chris@0 13
Chris@0 14 /**
Chris@0 15 * {@inheritdoc}
Chris@0 16 */
Chris@0 17 public static $modules = ['locale', 'locale_test', 'system'];
Chris@0 18
Chris@0 19 /**
Chris@0 20 * The module handler used in this test.
Chris@0 21 *
Chris@0 22 * @var \Drupal\Core\Extension\ModuleHandlerInterface
Chris@0 23 */
Chris@0 24 protected $moduleHandler;
Chris@0 25
Chris@0 26 /**
Chris@0 27 * The locale project storage used in this test.
Chris@0 28 *
Chris@0 29 * @var \Drupal\locale\LocaleProjectStorageInterface
Chris@0 30 */
Chris@0 31 protected $projectStorage;
Chris@0 32
Chris@0 33 /**
Chris@0 34 * {@inheritdoc}
Chris@0 35 */
Chris@0 36 protected function setUp() {
Chris@0 37 parent::setUp();
Chris@0 38
Chris@0 39 $this->moduleHandler = $this->container->get('module_handler');
Chris@0 40 $this->projectStorage = $this->container->get('locale.project');
Chris@0 41 \Drupal::state()->set('locale.remove_core_project', TRUE);
Chris@0 42 }
Chris@0 43
Chris@0 44 /**
Chris@0 45 * Tests locale_translation_clear_cache_projects().
Chris@0 46 */
Chris@0 47 public function testLocaleTranslationClearCacheProjects() {
Chris@0 48 $this->moduleHandler->loadInclude('locale', 'inc', 'locale.translation');
Chris@0 49
Chris@0 50 $expected = [];
Chris@0 51 $this->assertIdentical($expected, locale_translation_get_projects());
Chris@0 52
Chris@0 53 $this->projectStorage->set('foo', []);
Chris@0 54 $expected['foo'] = new \stdClass();
Chris@0 55 $this->assertEqual($expected, locale_translation_get_projects());
Chris@0 56
Chris@0 57 $this->projectStorage->set('bar', []);
Chris@0 58 locale_translation_clear_cache_projects();
Chris@0 59 $expected['bar'] = new \stdClass();
Chris@0 60 $this->assertEqual($expected, locale_translation_get_projects());
Chris@0 61 }
Chris@0 62
Chris@0 63 }