|
@@ -84,3 +84,87 @@ class i18nSelectTestCase extends Drupali18nTestCase {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Test case for AJAX queries on "views/ajax" when view on admin page.
|
|
|
+ */
|
|
|
+class I18NSelectAdminViewsAjax extends Drupali18nTestCase {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * {@inheritdoc}
|
|
|
+ */
|
|
|
+ public static function getInfo() {
|
|
|
+ return array(
|
|
|
+ 'name' => t('I18N select Admin Views (AJAX)'),
|
|
|
+ 'group' => 'Internationalization',
|
|
|
+ 'description' => t('Test AJAX requests to the "views/ajax" when view located on "admin/*" and list of skipping tags is empty.'),
|
|
|
+ // Skip this test when "admin_views" module does not exists.
|
|
|
+ 'dependencies' => array('admin_views'),
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * {@inheritdoc}
|
|
|
+ */
|
|
|
+ protected function setUp() {
|
|
|
+ parent::setUp('translation', 'i18n_variable', 'i18n_select', 'admin_views');
|
|
|
+ parent::setUpLanguages(array('access content overview'));
|
|
|
+ parent::setUpContentTranslation();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Test AJAX of a view without skipping tags for selection.
|
|
|
+ *
|
|
|
+ * @see i18n_select_page()
|
|
|
+ */
|
|
|
+ public function testViewsAjaxWithoutSkippingTags() {
|
|
|
+ // If this variable will have the "views" value then this test will not
|
|
|
+ // have sense. For instance, we want apply language selection filter
|
|
|
+ // for views and remove "views" from "i18n_select_skip_tags" variable.
|
|
|
+ // In this case all AJAX for views, on administration part of the site,
|
|
|
+ // will be broken because the "i18n_select_page()" function will work
|
|
|
+ // with "views/ajax" path instead of, for example, "admin/content".
|
|
|
+ variable_set('i18n_select_skip_tags', '');
|
|
|
+
|
|
|
+ // Create one hundred of nodes.
|
|
|
+ for ($i = 1; $i <= 100; $i++) {
|
|
|
+ // Create every second node on Spanish language and
|
|
|
+ // every first - on English.
|
|
|
+ $node = $this->createNode('page', "Node $i", '', $i % 2 ? $this->default_language : $this->secondary_language);
|
|
|
+
|
|
|
+ // Update "changed" in order to sort the content by updating date. In
|
|
|
+ // other case all nodes will be with the same date and not arranged in
|
|
|
+ // order.
|
|
|
+ db_update('node')
|
|
|
+ ->fields(array('changed' => strtotime("+ $i minute")))
|
|
|
+ ->condition('nid', $node->nid)
|
|
|
+ ->execute();
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->drupalGet('admin/content');
|
|
|
+
|
|
|
+ // Check that latest node exists at the top.
|
|
|
+ $this->assertText('Node 100');
|
|
|
+ // Check that our page contains fifty nodes (the latest must be 51).
|
|
|
+ $this->assertNoText('Node 50');
|
|
|
+
|
|
|
+ // Test $_REQUEST['view_path']. There's no form to submit to, so
|
|
|
+ // drupalPost() won't work here. This just tests a direct $_POST
|
|
|
+ // request instead.
|
|
|
+ $this->curlExec(array(
|
|
|
+ CURLOPT_URL => $this->getAbsoluteUrl('views/ajax'),
|
|
|
+ CURLOPT_POST => TRUE,
|
|
|
+ CURLOPT_POSTFIELDS => http_build_query(array(
|
|
|
+ 'page' => 1,
|
|
|
+ 'view_path' => 'admin/content',
|
|
|
+ 'view_name' => 'admin_views_node',
|
|
|
+ 'view_display_id' => 'system_1',
|
|
|
+ )),
|
|
|
+ ));
|
|
|
+
|
|
|
+ // Check that we are successfully switched to a new page of content.
|
|
|
+ $this->assertText('Node 50');
|
|
|
+ $this->assertNoText('Node 100');
|
|
|
+ }
|
|
|
+
|
|
|
+}
|