Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/simpletest/tests/src/FunctionalJavascript/JavascriptGetDrupalSettingsTest.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\Tests\simpletest\FunctionalJavascript; | |
4 | |
5 use Drupal\FunctionalJavascriptTests\JavascriptTestBase; | |
6 | |
7 /** | |
8 * Tests Drupal settings retrieval in JavascriptTestBase tests. | |
9 * | |
10 * @group javascript | |
11 */ | |
12 class JavascriptGetDrupalSettingsTest extends JavascriptTestBase { | |
13 | |
14 /** | |
15 * {@inheritdoc} | |
16 */ | |
17 protected static $modules = ['test_page_test']; | |
18 | |
19 /** | |
20 * Tests retrieval of Drupal settings. | |
21 * | |
22 * @see \Drupal\FunctionalJavascriptTests\JavascriptTestBase::getDrupalSettings() | |
23 */ | |
24 public function testGetDrupalSettings() { | |
25 $this->drupalLogin($this->drupalCreateUser()); | |
26 $this->drupalGet('test-page'); | |
27 | |
28 // Check that we can read the JS settings. | |
29 $js_settings = $this->getDrupalSettings(); | |
30 $this->assertSame('azAZ09();.,\\\/-_{}', $js_settings['test-setting']); | |
31 | |
32 // Dynamically change the setting using Javascript. | |
33 $script = <<<EndOfScript | |
34 (function () { | |
35 drupalSettings['test-setting'] = 'foo'; | |
36 })(); | |
37 EndOfScript; | |
38 | |
39 $this->getSession()->evaluateScript($script); | |
40 | |
41 // Check that the setting has been changed. | |
42 $js_settings = $this->getDrupalSettings(); | |
43 $this->assertSame('foo', $js_settings['test-setting']); | |
44 } | |
45 | |
46 } |