Backup of db before drupal security update
[yaffs-website] / web / core / modules / config_translation / tests / src / Functional / ConfigTranslationDateFormatUiTest.php
1 <?php
2
3 namespace Drupal\Tests\config_translation\Functional;
4
5 use Drupal\language\Entity\ConfigurableLanguage;
6 use Drupal\Tests\BrowserTestBase;
7
8 /**
9  * Tests the content translation behaviours on date formats.
10  *
11  * @group config_translation
12  */
13 class ConfigTranslationDateFormatUiTest extends BrowserTestBase {
14
15   public static $modules = [
16     'language',
17     'config_translation',
18     'system'
19   ];
20
21   protected function setUp() {
22     parent::setUp();
23
24     // Enable additional languages.
25     $langcodes = ['de', 'es'];
26     foreach ($langcodes as $langcode) {
27       ConfigurableLanguage::createFromLangcode($langcode)->save();
28     }
29
30     $user = $this->drupalCreateUser([
31       'administer site configuration',
32       'translate configuration',
33     ]);
34     $this->drupalLogin($user);
35   }
36
37   /**
38    * Tests date format translation behaviour.
39    */
40   public function testDateFormatUI() {
41     $this->drupalGet('admin/config/regional/date-time');
42
43     // Assert translation link unlocked date format.
44     $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/medium/translate');
45
46     // Assert translation link locked date format.
47     $this->assertLinkByHref('admin/config/regional/date-time/formats/manage/html_datetime/translate');
48
49     // Date pattern is visible on unlocked date formats.
50     $this->drupalGet('admin/config/regional/date-time/formats/manage/medium/translate/de/add');
51     $this->assertField('translation[config_names][core.date_format.medium][pattern]');
52
53     // Date pattern is not visible on locked date formats.
54     $this->drupalGet('admin/config/regional/date-time/formats/manage/html_datetime/translate/es/add');
55     $this->assertNoField('translation[config_names][core.date_format.html_datetime][pattern]');
56   }
57
58 }