Projet

Général

Profil

Révision fc3d89c3

Ajouté par Assos Assos il y a plus de 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/i18n/i18n_select/i18n_select.test
84 84
    }
85 85
  }
86 86
}
87

  
88
/**
89
 * Test case for AJAX queries on "views/ajax" when view on admin page.
90
 */
91
class I18NSelectAdminViewsAjax extends Drupali18nTestCase {
92

  
93
  /**
94
   * {@inheritdoc}
95
   */
96
  public static function getInfo() {
97
    return array(
98
      'name' => t('I18N select Admin Views (AJAX)'),
99
      'group' => 'Internationalization',
100
      'description' => t('Test AJAX requests to the "views/ajax" when view located on "admin/*" and list of skipping tags is empty.'),
101
      // Skip this test when "admin_views" module does not exists.
102
      'dependencies' => array('admin_views'),
103
    );
104
  }
105

  
106
  /**
107
   * {@inheritdoc}
108
   */
109
  protected function setUp() {
110
    parent::setUp('translation', 'i18n_variable', 'i18n_select', 'admin_views');
111
    parent::setUpLanguages(array('access content overview'));
112
    parent::setUpContentTranslation();
113
  }
114

  
115
  /**
116
   * Test AJAX of a view without skipping tags for selection.
117
   *
118
   * @see i18n_select_page()
119
   */
120
  public function testViewsAjaxWithoutSkippingTags() {
121
    // If this variable will have the "views" value then this test will not
122
    // have sense. For instance, we want apply language selection filter
123
    // for views and remove "views" from "i18n_select_skip_tags" variable.
124
    // In this case all AJAX for views, on administration part of the site,
125
    // will be broken because the "i18n_select_page()" function will work
126
    // with "views/ajax" path instead of, for example, "admin/content".
127
    variable_set('i18n_select_skip_tags', '');
128

  
129
    // Create one hundred of nodes.
130
    for ($i = 1; $i <= 100; $i++) {
131
      // Create every second node on Spanish language and
132
      // every first - on English.
133
      $node = $this->createNode('page', "Node $i", '', $i % 2 ? $this->default_language : $this->secondary_language);
134

  
135
      // Update "changed" in order to sort the content by updating date. In
136
      // other case all nodes will be with the same date and not arranged in
137
      // order.
138
      db_update('node')
139
        ->fields(array('changed' => strtotime("+ $i minute")))
140
        ->condition('nid', $node->nid)
141
        ->execute();
142
    }
143

  
144
    $this->drupalGet('admin/content');
145

  
146
    // Check that latest node exists at the top.
147
    $this->assertText('Node 100');
148
    // Check that our page contains fifty nodes (the latest must be 51).
149
    $this->assertNoText('Node 50');
150

  
151
    // Test $_REQUEST['view_path']. There's no form to submit to, so
152
    // drupalPost() won't work here. This just tests a direct $_POST
153
    // request instead.
154
    $this->curlExec(array(
155
      CURLOPT_URL => $this->getAbsoluteUrl('views/ajax'),
156
      CURLOPT_POST => TRUE,
157
      CURLOPT_POSTFIELDS => http_build_query(array(
158
        'page' => 1,
159
        'view_path' => 'admin/content',
160
        'view_name' => 'admin_views_node',
161
        'view_display_id' => 'system_1',
162
      )),
163
    ));
164

  
165
    // Check that we are successfully switched to a new page of content.
166
    $this->assertText('Node 50');
167
    $this->assertNoText('Node 100');
168
  }
169

  
170
}

Formats disponibles : Unified diff