Projet

Général

Profil

Paste
Télécharger (6,23 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / panelizer / tests / panelizer.term.test @ 651307cd

1
<?php
2
/**
3
 * @file
4
 * Panelizer tests.
5
 */
6

    
7
/**
8
 * Verifies Panelizer configuration options for taxonomy terms.
9
 */
10
class PanelizerTermTest extends PanelizerTestHelper {
11

    
12
  protected $vocabulary;
13

    
14
  /**
15
   * {@inheritdoc}
16
   */
17
  public static function getInfo() {
18
    return array(
19
      'name' => 'Panelizer term workflow (excluding IPE)',
20
      'description' => 'Test the typical workflow of working with terms, excluding IPE.',
21
      'group' => 'Panelizer',
22
    );
23
  }
24

    
25
  /**
26
   * {@inheritdoc}
27
   */
28
  function setUp(array $modules = array()) {
29
    parent::setUp();
30

    
31
    // Create a user with the necessary permissions.
32
    $perms = array(
33
      // Master permission for all Panelizer operations.
34
      'administer panelizer',
35

    
36
      // Full control over this entity.
37
      'administer taxonomy',
38
    );
39
    $admin = $this->drupalCreateUser($perms);
40
    $this->drupalLogin($admin);
41

    
42
    $edit = array(
43
      'name' => 'Panelizer Vocabulary',
44
      'machine_name' => 'panelizer_vocabulary',
45
      'description' => 'Panelizer worflow test vocabulary',
46
      'hierarchy' => 1,
47
      'module' => 'panelizer',
48
      'weight' => -10,
49
    );
50
    $vocabulary = (object) $edit;
51
    taxonomy_vocabulary_save($vocabulary);
52
    $this->vocabulary = $vocabulary;
53
  }
54

    
55
  /**
56
   * Helper function to create a taxonomy term.
57
   *
58
   * @return object
59
   *   A taxonomy term object.
60
   */
61
  protected function createTestTerm() {
62
    $edit = array(
63
      'name' => t('Test Panelizer Term'),
64
      'description' => "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book",
65
      'parent' => array(0),
66
      'vid' => $this->vocabulary->vid,
67
    );
68
    $term = (object) $edit;
69
    taxonomy_term_save($term);
70
    return $term;
71
  }
72

    
73
  /**
74
   * Test the vocabulary configuration functionality.
75
   */
76
  function testVocabularyConfiguration() {
77
    // Load the vocabulary's settings page.
78
    $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/edit');
79
    $this->assertResponse(200);
80

    
81
    // Confirm that the appropriate fields are present.
82
    $this->assertFieldByName('panelizer[status]');
83
    $this->assertFieldByName('panelizer[help]');
84
    foreach (array('page_manager', 'default') as $view_mode) {
85
      $this->assertFieldByName('panelizer[view modes][' . $view_mode . '][status]');
86
      $this->assertFieldByName('panelizer[view modes][' . $view_mode . '][default]');
87
      $this->assertFieldByName('panelizer[view modes][' . $view_mode . '][choice]');
88
    }
89

    
90
    // Panelize the test vocabulary.
91
    $edit = array(
92
      'panelizer[status]' => TRUE,
93
    );
94
    $this->drupalPost(NULL, $edit, t('Save'));
95
    $this->assertResponse(200);
96

    
97
    $term = $this->createTestTerm();
98

    
99
    // Verify the term can be panelized.
100
    $this->drupalGet('taxonomy/term/' . $term->tid);
101
    $this->assertResponse(200);
102
    $this->assertLink('Customize display', 0, 'The customize display link appears on the page');
103
    $this->assertLinkByHref('taxonomy/term/' . $term->tid . '/panelizer', 0, 'A link to customize the node appears on the page');
104

    
105
    // Allow panelization of the "Default" view mode.
106
    $edit = array(
107
      'panelizer[view modes][default][status]' => TRUE,
108
      'panelizer[view modes][default][default]' => TRUE,
109
    );
110
    $this->drupalPost('admin/structure/taxonomy/panelizer_vocabulary/edit', $edit, t('Save'));
111
    $this->assertResponse(200);
112

    
113
    // Check that the view mode has been panelized.
114
    $this->drupalGet('taxonomy/term/' . $term->tid);
115
    $this->assertResponse(200);
116
    $elements = $this->xpath('//div[contains(@class,:class)]', array(':class' => 'panelizer-view-mode'));
117
    $this->assertEqual(count($elements), 1, 'The term is panelized.');
118
  }
119

    
120
  /**
121
   *
122
   */
123
  function testTermPanelizeIt() {
124
    $view_mode = 'default';
125
    $view_mode_label = t('Default');
126
    $this->togglePanelizer('taxonomy_term', $this->vocabulary->machine_name, $view_mode, 1, 0, 0);
127
    $term = $this->createTestTerm();
128

    
129
    // Check that the view mode can be panelized.
130
    $this->drupalGet('taxonomy/term/' . $term->tid . '/panelizer');
131
    $this->assertResponse(200);
132
    $this->assertText($view_mode_label);
133
    $this->assertLink('panelize', 0, "The panelize link for the {$view_mode} view mode appears on the page.");
134
    $this->assertLinkByHref('taxonomy/term/' . $term->tid . '/panelizer/' . $view_mode, 0, "A link to panelize the {$view_mode} view mode appears on the page.");
135

    
136
    // Verify that the view mode is not currently panelized.
137
    $this->drupalGet('taxonomy/term/' . $term->tid . '/panelizer/' . $view_mode);
138
    $this->assertResponse(200);
139
    $this->assertRaw(t('This %entity is not currently panelized.', array('%entity' => 'Taxonomy term')));
140

    
141
    // Panelize the view mode.
142
    $this->drupalPost(NULL, array(), t('Panelize it!'));
143
    $this->assertResponse(200);
144

    
145
    // Check that the view mode has been panelized.
146
    $this->drupalGet('taxonomy/term/' . $term->tid);
147
    $this->assertResponse(200);
148
    $elements = $this->xpath('//div[contains(@class,:class)]', array(':class' => 'panelizer-view-mode'));
149
    $this->assertEqual(count($elements), 1, 'The term is panelized.');
150
  }
151

    
152
  /**
153
   *
154
   */
155
  function testTermPanelsDefault() {
156
    $view_mode = 'default';
157
    $this->togglePanelizer('taxonomy_term', $this->vocabulary->machine_name, $view_mode, 1, 1, 0);
158
    $term = $this->createTestTerm();
159

    
160
    // Verify that the view mode has a default panel.
161
    $this->drupalGet('admin/structure/taxonomy/panelizer_vocabulary/panelizer');
162
    $this->assertResponse(200);
163
    $this->assertLinkByHref('admin/structure/taxonomy/panelizer_vocabulary/panelizer/' . $view_mode, 0, 'User is able to provide default panel for ' . $view_mode);
164

    
165
    $edit = array(
166
      'layout' => 'twocol_bricks',
167
    );
168
    $this->drupalPost('admin/structure/taxonomy/panelizer_vocabulary/panelizer/' . $view_mode . '/layout', $edit, t('Save'));
169

    
170
    // Check that the layout has been set.
171
    $this->drupalGet('taxonomy/term/' . $term->tid);
172
    $this->assertResponse(200);
173
    $elements = $this->xpath('//div[contains(@class,:class)]', array(':class' => 'panel-2col-bricks'));
174
    $this->assertEqual(count($elements), 1, 'The default term layout has been set.');
175
  }
176

    
177
}