Projet

Général

Profil

Paste
Télécharger (4,7 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / panelizer / tests / panelizer.admin_settings.test @ a2bb1a14

1
<?php
2
/**
3
 * @file
4
 * Test the admin functionality for Panelizer.
5
 */
6

    
7
/**
8
 * Test file administration page functionality.
9
 */
10
class PanelizerAdminTest extends PanelizerTestHelper {
11

    
12
  /**
13
   * {@inheritdoc}
14
   */
15
  public static function getInfo() {
16
    return array(
17
      'name' => 'Panelizer administration',
18
      'description' => 'Test panelizer administration page functionality.',
19
      'group' => 'Panelizer',
20
    );
21
  }
22

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

    
29
    $perms = array(
30
      'administer panelizer',
31
    );
32
    $admin_user = $this->drupalCreateUser($perms);
33
    $this->drupalLogin($admin_user);
34
  }
35

    
36
  /**
37
   * Tests panelizer overview with different entities.
38
   */
39
  function testPanelizerAdminPages() {
40
    $this->drupalGet('admin/structure/panelizer');
41
    $edit = array();
42

    
43
    $entity_plugins = panelizer_get_entity_plugins();
44

    
45
    foreach ($entity_plugins as $entity_type => $plugin) {
46
      $entity_info = entity_get_info($entity_type);
47

    
48
      if ($entity_info) {
49
        $bundles = $entity_info['bundles'];
50

    
51
        foreach ($bundles as $bundle => $info) {
52
          $this->assertFieldByXPath('//input[@type="checkbox" and @name="entities[' . $entity_type . '][' . $bundle . '][0][status]"]', FALSE, t('The %bundle bundle of the %entity_type entity type can be panelized.', array('%bundle' => $bundle, '%entity_type' => $entity_type)));
53

    
54
          // Collect a list of all of the available entity types + bundles.
55
          $edit['entities[' . $entity_type . '][' . $bundle . '][0][status]'] = TRUE;
56
        }
57
      }
58
    }
59

    
60
    // Panelize all of the known entity types and their bundles.
61
    $this->drupalPost('admin/structure/panelizer', $edit, t('Save'));
62

    
63
    // Reset the ctools plugins static cache to include the newly panelized
64
    // entity types.
65
    ctools_get_plugins_reset();
66

    
67
    $entity_plugins = panelizer_get_entity_plugins();
68

    
69
    foreach ($entity_plugins as $entity_type => $plugin) {
70
      $entity_info = entity_get_info($entity_type);
71

    
72
      if ($entity_info) {
73
        $bundles = $entity_info['bundles'];
74

    
75
        foreach ($bundles as $bundle => $info) {
76
          if (!empty($plugin['bundles'][$bundle]['status'])) {
77
            if (!empty($info['admin']['real path'])) {
78
              $this->assertLinkByHref($info['admin']['real path'] . '/display', 0, t('A link to manage the display for the %bundle bundle of the %entity_type entity type appears on the page.', array('%bundle' => $bundle, '%entity_type' => $entity_type)));
79
            }
80
            $this->assertLinkByHref('admin/structure/panelizer/' . $entity_type . '/' . $bundle . '/allowed', 0, t('A link to restrict the allowed content for the %bundle bundle of the %entity_type entity type appears on the page.', array('%bundle' => $bundle, '%entity_type' => $entity_type)));
81
          }
82

    
83
          foreach ($plugin['view modes'] as $view_mode => $view_mode_info) {
84
            // Automatically allow view modes that are part of Panels.
85
            if (isset($entity_info['view modes'][$view_mode])) {
86
              // Skip this view mode if it isn't enabled for this bundle.
87
              if (!empty($bundle)) {
88
                if (empty($view_mode_settings[$view_mode]['custom_settings'])) {
89
                  continue;
90
                }
91
              }
92

    
93
              // When configuring a new bundle for an entity, the view modes
94
              // that are by default set to now have custom settings will be
95
              // hidden, to avoid confusion.
96
              else {
97
                if (isset($entity_info['view modes'][$view_mode]['custom settings']) && empty($entity_info['view modes'][$view_mode]['custom settings'])) {
98
                  continue;
99
                }
100
              }
101
            }
102

    
103
            if (isset($plugin['view mode status'][$bundle][$view_mode]) && empty($plugin['view mode status'][$bundle][$view_mode])) {
104
              // continue;
105
            }
106

    
107
            if (!empty($plugin['bundles'][$bundle]['view modes'][$view_mode]) && is_array($plugin['bundles'][$bundle]['view modes'][$view_mode])) {
108
              $settings = $plugin['bundles'][$bundle]['view modes'][$view_mode];
109
            }
110
            else {
111
              $settings = array(
112
                'status' => FALSE,
113
                'default' => FALSE,
114
                'choice' => FALSE
115
              );
116
            }
117

    
118
            $this->assertFieldByXPath('//input[@type="checkbox" and @name="entities[' . $entity_type . '][' . $bundle . '][' . $view_mode . '][status]"]', !empty($settings['status']), t('The %view_mode view mode of the %bundle bundle of the %entity_type entity type can be panelized.', array('%view_mode' => $view_mode, '%bundle' => $bundle, '%entity_type' => $entity_type)));
119
          }
120
        }
121
      }
122
    }
123
  }
124

    
125
}