Projet

Général

Profil

Paste
Télécharger (3,36 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / panels / tests / PanelsEntityViewWebTestCase.test @ 08475715

1
<?php
2

    
3
/**
4
 * @file
5
 * Some rudimentary tests for entity handling, will be overridden by others.
6
 */
7

    
8
abstract class PanelsEntityViewWebTestCase extends DrupalWebTestCase {
9

    
10
  /**
11
   * Admin user.
12
   *
13
   * @var \StdClass
14
   */
15
  protected $adminUser;
16

    
17
  /**
18
   * The task handler used for managing a specific entity type.
19
   *
20
   * @var \StdClass
21
   */
22
  protected $view_name = 'node_view';
23

    
24
  /**
25
   * The label used for this entity's task handler.
26
   *
27
   * @var \StdClass
28
   */
29
  protected $view_label = 'Node template';
30

    
31
  /**
32
   * {@inheritdoc}
33
   */
34
  function setUp(array $modules = array()) {
35
    $modules[] = 'panels';
36
    $modules[] = 'page_manager';
37

    
38
    parent::setUp($modules);
39

    
40
    $permissions = array(
41
      // Allow the user to access the Page Manager admin page.
42
      'use page manager',
43

    
44
      // Basic permissions for the module.
45
      'use panels dashboard',
46

    
47
      // General admin access.
48
      'access administration pages',
49
    );
50

    
51
    // Reset the static variable used to identify permissions, otherwise it's
52
    // possible the permissions check in drupalCreateUser will fail.
53
    $this->checkPermissions(array(), TRUE);
54
    cache_clear_all();
55

    
56
    // Create the admin user.
57
    $this->adminUser = $this->drupalCreateUser($permissions);
58
  }
59

    
60
  /**
61
   * Ensure that the {ENTITY}_view toggle works correctly.
62
   */
63
  function testToggle() {
64
    // Log in as the admin user.
65
    $this->drupalLogin($this->adminUser);
66

    
67
    // Load the Panels dashboard.
68
    $this->drupalGet('admin/structure/panels');
69
    $this->assertResponse(200, 'Loaded the main Panels admin page.');
70

    
71
    // Confirm that the Node View task handler is disabled.
72
    $this->assertText(t($this->view_label));
73
    $this->assertLinkByHref(url('admin/structure/pages/edit/' . $this->view_name, array('absolute' => FALSE)));
74
    $xpath = $this->xpath("//tr[contains(@class,:tr)]/td/div/div/ul/li[contains(@class,:li)]/a", array(':tr' => 'page-task-' . $this->view_name, ':li' => 'first'));
75
    $this->assertEqual($xpath[0][0], t('Enable'));
76

    
77
    // Set the Node View handler to "off".
78
    variable_set('page_manager_' . $this->view_name . '_disabled', TRUE);
79

    
80
    // Load the Panels dashboard again.
81
    $this->drupalGet('admin/structure/panels');
82
    $this->assertResponse(200, 'Loaded the main Panels admin page.');
83

    
84
    // Confirm that the Node View task handler is still disabled.
85
    $this->assertText(t($this->view_label));
86
    $this->assertNoLinkByHref(url('admin/structure/pages/nojs/disable/' . $this->view_name, array('absolute' => FALSE)));
87
    $xpath = $this->xpath("//tr[contains(@class,:tr)]/td/div/div/ul/li[contains(@class,:li)]/a", array(':tr' => 'page-task-' . $this->view_name, ':li' => 'first'));
88
    $this->assertEqual($xpath[0][0], t('Enable'));
89

    
90
    // Set the Node View handler to "on".
91
    variable_set('page_manager_' . $this->view_name . '_disabled', FALSE);
92

    
93
    // Load the Panels dashboard again.
94
    $this->drupalGet('admin/structure/panels');
95
    $this->assertResponse(200, 'Loaded the main Panels admin page.');
96

    
97
    // Confirm that the Node View task handler is now enabled.
98
    $this->assertLinkByHref(url('admin/structure/pages/nojs/disable/' . $this->view_name, array('absolute' => FALSE)));
99
    $xpath = $this->xpath("//tr[contains(@class,:tr)]/td/div/div/ul/li[contains(@class,:li)]/a", array(':tr' => 'page-task-' . $this->view_name, ':li' => 'last'));
100
    $this->assertEqual($xpath[0][0], t('Disable'));
101
  }
102

    
103
}