comparison core/modules/locale/tests/src/Kernel/LocaleTranslationProjectsTest.php @ 0:4c8ae668cc8c

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