summaryrefslogtreecommitdiffstats
path: root/core/modules/system/lib/Drupal/system/Tests/Batch/PageTest.php
blob: 69dee9c4e36673b90ede94e0fe45faa5f3a32f35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php

/**
 * @file
 * Definition of Drupal\system\Tests\Batch\PageTest.
 */

namespace Drupal\system\Tests\Batch;

use Drupal\simpletest\WebTestBase;

/**
 * Tests for the Batch API Progress page.
 */
class PageTest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var array
   */
  public static $modules = array('batch_test');

  public static function getInfo() {
    return array(
      'name' => 'Batch progress page',
      'description' => 'Test the content of the progress page.',
      'group' => 'Batch API',
    );
  }

  /**
   * Tests that the batch API progress page uses the correct theme.
   */
  function testBatchProgressPageTheme() {
    // Make sure that the page which starts the batch (an administrative page)
    // is using a different theme than would normally be used by the batch API.
    variable_set('theme_default', 'bartik');
    theme_enable(array('seven'));
    variable_set('admin_theme', 'seven');
    // Log in as an administrator who can see the administrative theme.
    $admin_user = $this->drupalCreateUser(array('view the administration theme'));
    $this->drupalLogin($admin_user);
    // Visit an administrative page that runs a test batch, and check that the
    // theme that was used during batch execution (which the batch callback
    // function saved as a variable) matches the theme used on the
    // administrative page.
    $this->drupalGet('admin/batch-test/test-theme');
    // The stack should contain the name of the theme used on the progress
    // page.
    $this->assertEqual(batch_test_stack(), array('seven'), 'A progressive batch correctly uses the theme of the page that started the batch.');
  }
}