Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / system / tests / src / Functional / Batch / PageTest.php
1 <?php
2
3 namespace Drupal\Tests\system\Functional\Batch;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8  * Tests the content of the progress page.
9  *
10  * @group Batch
11  */
12 class PageTest extends BrowserTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['batch_test'];
20
21   /**
22    * Tests that the batch API progress page uses the correct theme.
23    */
24   public function testBatchProgressPageTheme() {
25     // Make sure that the page which starts the batch (an administrative page)
26     // is using a different theme than would normally be used by the batch API.
27     $this->container->get('theme_handler')->install(['seven', 'bartik']);
28     $this->config('system.theme')
29       ->set('default', 'bartik')
30       ->set('admin', 'seven')
31       ->save();
32
33     // Log in as an administrator who can see the administrative theme.
34     $admin_user = $this->drupalCreateUser(['view the administration theme']);
35     $this->drupalLogin($admin_user);
36     // Visit an administrative page that runs a test batch, and check that the
37     // theme that was used during batch execution (which the batch callback
38     // function saved as a variable) matches the theme used on the
39     // administrative page.
40     $this->drupalGet('admin/batch-test/test-theme');
41     // The stack should contain the name of the theme used on the progress
42     // page.
43     $this->assertEqual(batch_test_stack(), ['seven'], 'A progressive batch correctly uses the theme of the page that started the batch.');
44   }
45
46   /**
47    * Tests that the batch API progress page shows the title correctly.
48    */
49   public function testBatchProgressPageTitle() {
50     // Visit an administrative page that runs a test batch, and check that the
51     // title shown during batch execution (which the batch callback function
52     // saved as a variable) matches the theme used on the administrative page.
53     $this->drupalGet('batch-test/test-title');
54     // The stack should contain the title shown on the progress page.
55     $this->assertEqual(batch_test_stack(), ['Batch Test'], 'The batch title is shown on the batch page.');
56     $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
57   }
58
59   /**
60    * Tests that the progress messages are correct.
61    */
62   public function testBatchProgressMessages() {
63     // Go to the initial step only.
64     $this->maximumMetaRefreshCount = 0;
65     $this->drupalGet('batch-test/test-title');
66     $this->assertRaw('<div class="progress__description">Initializing.<br />&nbsp;</div>', 'Initial progress message appears correctly.');
67     $this->assertNoRaw('&amp;nbsp;', 'Initial progress message is not double escaped.');
68     // Now also go to the next step.
69     $this->maximumMetaRefreshCount = 1;
70     $this->drupalGet('batch-test/test-title');
71     $this->assertRaw('<div class="progress__description">Completed 1 of 1.</div>', 'Progress message for second step appears correctly.');
72   }
73
74 }