- <?php
- * @file
- * Tests Views UI Wizard.
- */
-
- * Views UI wizard tests.
- */
- class ViewsUIWizardHelper extends BackdropWebTestCase {
- function setUp() {
-
- parent::setUp('views_ui');
-
-
- $views_admin = $this->backdropCreateUser(array('administer views', 'administer blocks', 'bypass node access', 'access user profiles', 'view revisions', 'synchronize configuration'));
- $this->backdropLogin($views_admin);
- }
- }
-
- * Tests creating views with the wizard and viewing them on the listing page.
- */
- class ViewsUIWizardBasicTestCase extends ViewsUIWizardHelper {
- function testViewsWizardAndListing() {
-
- $this->backdropGet('admin/structure/views');
- $this->assertLinkByHref(url('admin/config/development/configuration/single/export'));
-
- $this->assertText(t('Add view'));
-
-
- $view1 = array();
- $view1['human_name'] = $this->randomName(16);
- $view1['name'] = strtolower($this->randomName(16));
- $view1['description'] = $this->randomName(16);
- $view1['page[create]'] = FALSE;
- $this->backdropPost('admin/structure/views/add', $view1, t('Save view'));
- $this->assertText(t('Your view was saved. You may configure it from the list below.'));
- $this->assertText($view1['human_name']);
- $this->assertText($view1['description']);
- foreach (array('/delete', '/clone', '') as $operation) {
- $this->assertLinkByHref(url('admin/structure/views/view/' . $view1['name'] . $operation));
- }
- $this->assertLinkByHref(url('admin/config/development/configuration/single/export'));
-
-
- $this->backdropGet('admin/structure/block');
- $this->assertNoText('View: ' . $view1['human_name']);
-
-
- $node1 = $this->backdropCreateNode(array('type' => 'page'));
- $node2 = $this->backdropCreateNode(array('type' => 'post'));
-
-
- $view2 = array();
- $view2['human_name'] = $this->randomName(16);
- $view2['name'] = strtolower($this->randomName(16));
- $view2['description'] = $this->randomName(16);
- $view2['page[create]'] = 1;
- $view2['page[title]'] = $this->randomName(16);
- $view2['page[path]'] = $this->randomName(16);
- $view2['page[feed]'] = 1;
- $view2['page[feed_properties][path]'] = $this->randomName(16);
- $this->backdropPost('admin/structure/views/add', $view2, t('Save view'));
-
-
-
- $this->assertUrl($view2['page[path]']);
- $this->assertText($view2['page[title]']);
- $this->assertText($node1->title);
- $this->assertText($node2->title);
-
-
- $link = $this->xpath('/html/head/link[@type="application/rss+xml"][@href=:url]', array(
- ':url' => url($view2['page[feed_properties][path]'], array('absolute' => TRUE)),
- ));
- $this->assertEqual(count($link), 1, 'RSS Feed found in page header.');
- $this->backdropGet($view2['page[feed_properties][path]']);
- $this->assertRaw('<rss version="2.0"');
-
- $this->assertText($view2['page[title]']);
- $this->assertRaw(url('node/' . $node1->nid, array('absolute' => TRUE)));
- $this->assertText($node1->title);
- $this->assertRaw(url('node/' . $node2->nid, array('absolute' => TRUE)));
- $this->assertText($node2->title);
-
-
- $this->backdropGet('admin/structure/views');
- $this->assertText($view2['human_name']);
- $this->assertText($view2['description']);
- $this->assertLinkByHref(url($view2['page[path]']));
-
-
- $this->backdropGet('admin/structure/block');
- $this->assertNoText('View: ' . $view2['human_name']);
-
-
- $view3 = array();
- $view3['human_name'] = $this->randomName(16);
- $view3['name'] = strtolower($this->randomName(16));
- $view3['description'] = $this->randomName(16);
- $view3['show[wizard_key]'] = 'node';
- $view3['show[type]'] = 'page';
- $view3['page[create]'] = 1;
- $view3['page[title]'] = $this->randomName(16);
- $view3['page[path]'] = $this->randomName(16);
- $view3['block[create]'] = 1;
- $view3['block[title]'] = $this->randomName(16);
- $this->backdropPost('admin/structure/views/add', $view3, t('Save view'));
-
-
- $this->assertUrl($view3['page[path]']);
- $this->assertText($view3['page[title]']);
- $this->assertText($node1->title);
- $this->assertNoText($node2->title);
-
-
- $this->backdropGet('admin/structure/views');
- $this->assertText($view3['human_name']);
- $this->assertText($view3['description']);
- $this->assertLinkByHref(url($view3['page[path]']));
-
- views_invalidate_cache();
- $layout = layout_load('default');
- $layout->addBlock('views', $view3['name'] . '-block', 'sidebar');
- $layout->save();
-
-
-
- $this->backdropGet('user');
- $this->assertText($node1->title);
- $this->assertNoText($node2->title);
- }
- }
-
- * Tests enabling, disabling, and reverting default views via the listing page.
- */
- class ViewsUIWizardDefaultViewsTestCase extends ViewsUIWizardHelper {
-
- * Tests default views.
- */
- function testDefaultViews() {
-
- $edit_href = 'admin/structure/views/view/taxonomy_term';
- $this->backdropGet('admin/structure/views');
-
-
-
-
-
-
- $this->backdropGet('admin/structure/views/templates');
- $this->clickViewsOperationLink(t('Enable'), '/taxonomy_term/');
- $this->assertUrl('admin/structure/views');
- $this->assertLinkByHref($edit_href);
-
-
-
- $new_class = $this->randomName(16);
- $edit = array('css_class' => $new_class);
- $this->backdropPost('admin/structure/views/nojs/display/taxonomy_term/page/css_class', $edit, t('Apply'));
- $this->backdropPost('admin/structure/views/view/taxonomy_term/configure/page', array(), t('Save'));
-
-
- $term = entity_create('taxonomy_term', array(
- 'name' => $this->randomName(),
- 'description' => $this->randomName(),
- 'format' => filter_default_format(),
- 'vocabulary' => 'tags',
- 'langcode' => LANGUAGE_NONE,
- ));
- taxonomy_term_save($term);
-
- $this->backdropGet('taxonomy/term/' . $term->tid);
- $this->assertRaw($new_class);
-
-
-
- $this->backdropGet('admin/structure/views');
- $this->assertLink(t('Revert'));
- $revert_href = 'admin/structure/views/view/taxonomy_term/revert';
- $this->assertLinkByHref($revert_href);
- $this->backdropPost($revert_href, array(), t('Revert'));
- $this->backdropGet('taxonomy/term/' . $term->tid);
- $this->assertNoRaw($new_class);
-
-
-
- $this->backdropGet('admin/structure/views/templates');
- $this->clickViewsOperationLink(t('Enable'), '/taxonomy_term/');
- $this->assertUrl('admin/structure/views');
- $this->assertLinkByHref($edit_href);
- }
-
-
- * Click a link to perform an operation on a view.
- *
- * In general, we expect lots of links titled "enable" or "disable" on the
- * various views listing pages, and they might have tokens in them. So we
- * need special code to find the correct one to click.
- *
- * @param $label
- * Text between the anchor tags of the desired link.
- * @param $unique_href_part
- * A unique string that is expected to occur within the href of the desired
- * link. For example, if the link URL is expected to look like
- * "admin/structure/views/view/frontpage/...", then "/frontpage/" could be
- * passed as the expected unique string.
- *
- * @return
- * The page content that results from clicking on the link, or FALSE on
- * failure. Failure also results in a failed assertion.
- */
- function clickViewsOperationLink($label, $unique_href_part) {
- $links = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
- foreach ($links as $link_index => $link) {
- $position = strpos($link['href'], $unique_href_part);
- if ($position !== FALSE) {
- $index = $link_index;
- break;
- }
- }
- $this->assertTrue(isset($index), t('Link to "@label" containing @part found.', array('@label' => $label, '@part' => $unique_href_part)));
- if (isset($index)) {
- return $this->clickLink($label, $index);
- }
- else {
- return FALSE;
- }
- }
- }
-
- * Tests the ability of the views wizard to create views filtered by taxonomy.
- */
- class ViewsUIWizardTaggedWithTestCase extends ViewsUIWizardHelper {
- protected $node_type_with_tags;
- protected $node_type_without_tags;
- protected $tag_vocabulary;
- protected $tag_field;
- protected $tag_instance;
-
- function setUp() {
- parent::setUp();
-
-
-
- $this->node_type_with_tags = $this->backdropCreateContentType();
- $this->node_type_without_tags = $this->backdropCreateContentType();
-
-
- $this->tag_vocabulary = new TaxonomyVocabulary(array(
- 'name' => 'Views testing tags',
- 'machine_name' => 'views_testing_tags',
- ));
- $this->tag_vocabulary->save();
-
-
- $this->tag_field = array(
- 'field_name' => 'field_views_testing_tags',
- 'type' => 'taxonomy_term_reference',
- 'cardinality' => FIELD_CARDINALITY_UNLIMITED,
- 'settings' => array(
- 'allowed_values' => array(
- array(
- 'vocabulary' => $this->tag_vocabulary->machine_name,
- 'parent' => 0,
- ),
- ),
- ),
- );
- field_create_field($this->tag_field);
-
-
-
- $this->tag_instance = array(
- 'field_name' => 'field_views_testing_tags',
- 'entity_type' => 'node',
- 'bundle' => $this->node_type_with_tags->type,
- 'widget' => array(
- 'type' => 'taxonomy_autocomplete',
- ),
- 'display' => array(
- 'default' => array(
- 'type' => 'taxonomy_term_reference_link',
- 'weight' => 10,
- ),
- 'teaser' => array(
- 'type' => 'taxonomy_term_reference_link',
- 'weight' => 10,
- ),
- ),
- );
- field_create_instance($this->tag_instance);
- }
-
-
- * Tests the "tagged with" functionality.
- */
- function testTaggedWith() {
-
-
- $node_add_path = 'node/add/' . $this->node_type_with_tags->type;
-
-
- $tag_field = $this->tag_field['field_name'] . '[' . LANGUAGE_NONE . ']';
- $edit = array();
- $edit['title'] = $node_tag1_title = $this->randomName();
- $edit[$tag_field] = 'tag1';
- $this->backdropPost($node_add_path, $edit, t('Save'));
- $edit = array();
- $edit['title'] = $node_tag1_tag2_title = $this->randomName();
- $edit[$tag_field] = 'tag1, tag2';
- $this->backdropPost($node_add_path, $edit, t('Save'));
- $edit = array();
- $edit['title'] = $node_no_tags_title = $this->randomName();
- $this->backdropPost($node_add_path, $edit, t('Save'));
-
-
-
- $view1 = array();
-
-
- $view1['show[type]'] = $this->node_type_with_tags->type;
- $this->backdropPost('admin/structure/views/add', $view1, t('Update "of type" choice'));
-
- $view1['human_name'] = $this->randomName(16);
- $view1['name'] = strtolower($this->randomName(16));
- $view1['description'] = $this->randomName(16);
- $view1['show[tagged_with]'] = 'tag1';
- $view1['page[create]'] = 1;
- $view1['page[title]'] = $this->randomName(16);
- $view1['page[path]'] = $this->randomName(16);
- $this->backdropPost(NULL, $view1, t('Save view'));
-
-
- $this->backdropGet($view1['page[path]']);
- $this->assertText($node_tag1_title);
- $this->assertText($node_tag1_tag2_title);
- $this->assertNoText($node_no_tags_title);
-
-
-
- $view2 = array();
- $view2['show[type]'] = $this->node_type_with_tags->type;
- $this->backdropPost('admin/structure/views/add', $view2, t('Update "of type" choice'));
- $view2['human_name'] = $this->randomName(16);
- $view2['name'] = strtolower($this->randomName(16));
- $view2['description'] = $this->randomName(16);
- $view2['show[tagged_with]'] = 'tag2';
- $view2['page[create]'] = 1;
- $view2['page[title]'] = $this->randomName(16);
- $view2['page[path]'] = $this->randomName(16);
- $this->backdropPost(NULL, $view2, t('Save view'));
- $this->backdropGet($view2['page[path]']);
- $this->assertNoText($node_tag1_title);
- $this->assertText($node_tag1_tag2_title);
- $this->assertNoText($node_no_tags_title);
- }
-
-
- * Tests that the "tagged with" form element only shows for node types that support it.
- */
- function testTaggedWithByNodeType() {
-
-
-
-
-
- $tags_xpath = '//input[@name="show[tagged_with]"]';
- $this->backdropGet('admin/structure/views/add');
- $this->assertFieldByXpath($tags_xpath);
- $view['show[type]'] = $this->node_type_with_tags->type;
- $this->backdropPost('admin/structure/views/add', $view, t('Update "of type" choice'));
- $this->assertFieldByXpath($tags_xpath);
- $view['show[type]'] = $this->node_type_without_tags->type;
- $this->backdropPost(NULL, $view, t('Update "of type" choice'));
- $this->assertNoFieldByXpath($tags_xpath);
-
-
-
- $instance = $this->tag_instance;
- $instance['bundle'] = $this->node_type_without_tags->type;
- field_create_instance($instance);
- $view['show[type]'] = $this->node_type_with_tags->type;
- $this->backdropPost('admin/structure/views/add', $view, t('Update "of type" choice'));
- $this->assertFieldByXpath($tags_xpath);
- $view['show[type]'] = $this->node_type_without_tags->type;
- $this->backdropPost(NULL, $view, t('Update "of type" choice'));
- $this->assertFieldByXpath($tags_xpath);
- }
- }
-
- * Tests the ability of the views wizard to create views with sorts.
- */
- class ViewsUIWizardSortingTestCase extends ViewsUIWizardHelper {
-
- * Tests the sorting functionality.
- */
- function testSorting() {
-
-
- $node1 = $this->backdropCreateNode(array('created' => REQUEST_TIME));
- $node2 = $this->backdropCreateNode(array('created' => REQUEST_TIME + 1));
- $node3 = $this->backdropCreateNode(array('created' => REQUEST_TIME + 2));
-
-
- $view1 = array();
- $view1['human_name'] = $this->randomName(16);
- $view1['name'] = strtolower($this->randomName(16));
- $view1['description'] = $this->randomName(16);
- $view1['show[sort]'] = 'created:ASC';
- $view1['page[create]'] = 1;
- $view1['page[title]'] = $this->randomName(16);
- $view1['page[path]'] = $this->randomName(16);
- $this->backdropPost('admin/structure/views/add', $view1, t('Save view'));
-
-
- $this->assertUrl($view1['page[path]']);
- $this->assertText($view1['page[title]']);
- $content = $this->backdropGetContent();
- $this->assertText($node1->title);
- $this->assertText($node2->title);
- $this->assertText($node3->title);
- $pos1 = strpos($content, $node1->title);
- $pos2 = strpos($content, $node2->title);
- $pos3 = strpos($content, $node3->title);
- $this->assertTrue($pos1 < $pos2 && $pos2 < $pos3, t('The nodes appear in the expected order in a view that sorts by oldest first.'));
-
-
- $view2 = array();
- $view2['human_name'] = $this->randomName(16);
- $view2['name'] = strtolower($this->randomName(16));
- $view2['description'] = $this->randomName(16);
- $view2['show[sort]'] = 'created:DESC';
- $view2['page[create]'] = 1;
- $view2['page[title]'] = $this->randomName(16);
- $view2['page[path]'] = $this->randomName(16);
- $this->backdropPost('admin/structure/views/add', $view2, t('Save view'));
-
-
- $this->assertUrl($view2['page[path]']);
- $this->assertText($view2['page[title]']);
- $content = $this->backdropGetContent();
- $this->assertText($node3->title);
- $this->assertText($node2->title);
- $this->assertText($node1->title);
- $pos3 = strpos($content, $node3->title);
- $pos2 = strpos($content, $node2->title);
- $pos1 = strpos($content, $node1->title);
- $this->assertTrue($pos3 < $pos2 && $pos2 < $pos1, t('The nodes appear in the expected order in a view that sorts by newest first.'));
- }
- }
-
- * Tests the ability of the views wizard to specify the number of items per page.
- */
- class ViewsUIWizardItemsPerPageTestCase extends ViewsUIWizardHelper {
-
- * Tests the number of items per page.
- */
- function testItemsPerPage() {
-
-
- $node1 = $this->backdropCreateNode(array('type' => 'post', 'created' => REQUEST_TIME));
- $node2 = $this->backdropCreateNode(array('type' => 'post', 'created' => REQUEST_TIME + 1));
- $node3 = $this->backdropCreateNode(array('type' => 'post', 'created' => REQUEST_TIME + 2));
- $node4 = $this->backdropCreateNode(array('type' => 'post', 'created' => REQUEST_TIME + 3));
- $node5 = $this->backdropCreateNode(array('type' => 'post', 'created' => REQUEST_TIME + 4));
-
-
- $page_node = $this->backdropCreateNode(array('type' => 'page', 'created' => REQUEST_TIME + 2));
-
-
-
- $view = array();
- $view['human_name'] = $this->randomName(16);
- $view['name'] = strtolower($this->randomName(16));
- $view['description'] = $this->randomName(16);
- $view['show[wizard_key]'] = 'node';
- $view['show[type]'] = 'post';
- $view['show[sort]'] = 'created:DESC';
- $view['page[create]'] = 1;
- $view['page[title]'] = $this->randomName(16);
- $view['page[path]'] = $this->randomName(16);
- $view['page[items_per_page]'] = 4;
- $view['block[create]'] = 1;
- $view['block[title]'] = $this->randomName(16);
- $view['block[items_per_page]'] = 3;
- $this->backdropPost('admin/structure/views/add', $view, t('Save view'));
-
-
-
- $this->assertUrl($view['page[path]']);
- $this->assertText($view['page[title]']);
- $content = $this->backdropGetContent();
- $this->assertText($node5->title);
- $this->assertText($node4->title);
- $this->assertText($node3->title);
- $this->assertText($node2->title);
- $this->assertNoText($node1->title);
- $this->assertNoText($page_node->title);
- $pos5 = strpos($content, $node5->title);
- $pos4 = strpos($content, $node4->title);
- $pos3 = strpos($content, $node3->title);
- $pos2 = strpos($content, $node2->title);
- $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3 && $pos3 < $pos2, t('The nodes appear in the expected order in the page display.'));
-
-
-
-
- views_invalidate_cache();
- $layout = layout_load('default');
- $layout->addBlock('views', $view['name'] . '-block', 'sidebar');
- $layout->save();
-
- $this->backdropGet('user');
- $content = $this->backdropGetContent();
- $this->assertText($node5->title);
- $this->assertText($node4->title);
- $this->assertText($node3->title);
- $this->assertNoText($node2->title);
- $this->assertNoText($node1->title);
- $this->assertNoText($page_node->title);
- $pos5 = strpos($content, $node5->title);
- $pos4 = strpos($content, $node4->title);
- $pos3 = strpos($content, $node3->title);
- $this->assertTrue($pos5 < $pos4 && $pos4 < $pos3, t('The nodes appear in the expected order in the block display.'));
- }
- }
-
- * Tests the ability of the views wizard to put views in a menu.
- */
- class ViewsUIWizardMenuTestCase extends ViewsUIWizardHelper {
-
- * Tests the menu functionality.
- */
- function testMenus() {
-
- $view = array();
- $view['human_name'] = $this->randomName(16);
- $view['name'] = strtolower($this->randomName(16));
- $view['description'] = $this->randomName(16);
- $view['page[create]'] = 1;
- $view['page[title]'] = $this->randomName(16);
- $view['page[path]'] = $this->randomName(16);
- $view['page[link]'] = 1;
- $view['page[link_properties][menu_name]'] = 'main-menu';
- $view['page[link_properties][title]'] = $this->randomName(16);
- $this->backdropPost('admin/structure/views/add', $view, t('Save view'));
-
-
-
- $this->backdropGet('');
- $this->assertLink($view['page[link_properties][title]']);
- $this->assertLinkByHref(url($view['page[path]']));
-
-
- $links = menu_load_links('main-menu');
- $found = FALSE;
- foreach ($links as $link) {
- if ($link['link_path'] == $view['page[path]']) {
- $found = TRUE;
- break;
- }
- }
- $this->assertTrue($found, t('Found a link to %path in the primary navigation', array('%path' => $view['page[path]'])));
- }
- }
-
- * Tests the ability of the views wizard to create views with a jump menu style plugin.
- */
- class ViewsUIWizardJumpMenuTestCase extends ViewsUIWizardHelper {
-
- function setup() {
- parent::setup();
-
-
- date_default_timezone_set('UTC');
- }
-
-
- * Tests the jump menu style plugin.
- */
- function testJumpMenus() {
-
-
- $base_table_methods = array(
- 'node' => 'createNodeAndGetPath',
- 'users' => 'createUserAndGetPath',
- 'comment' => 'createCommentAndGetPath',
- 'taxonomy_term' => 'createTaxonomyTermAndGetPath',
- 'file_managed' => 'createFileAndGetPath',
- 'node_revision' => 'createNodeRevisionAndGetPath',
- );
-
- foreach ($base_table_methods as $base_table => $method) {
-
-
- $path_info = $this->{$method}();
- if (is_array($path_info)) {
- $path = $path_info['path'];
- $options = isset($path_info['options']) ? $path_info['options'] : array();
- }
- else {
- $path = $path_info;
- $options = array();
- }
-
-
-
- $view = array();
- $view['human_name'] = $this->randomName(16);
- $view['name'] = strtolower($this->randomName(16));
- $view['description'] = $this->randomName(16);
- $view['show[wizard_key]'] = $base_table;
- $view['page[create]'] = 1;
- $view['page[title]'] = $this->randomName(16);
- $view['page[path]'] = $this->randomName(16);
- $view['page[style][style_plugin]'] = 'jump_menu';
- $view['page[style][row_plugin]'] = 'fields';
- $this->backdropPost('admin/structure/views/add', $view, t('Save view'));
- $this->backdropGet($view['page[path]']);
-
-
-
-
- $edit = array();
- $edit['jump'] = url($path, $options);
-
-
-
- $view_object = views_get_view($view['name']);
- $view_object->preview('page');
- $form = $view_object->style_plugin->render();
- $jump_options = $form['jump']['#options'];
- foreach ($jump_options as $key => $title) {
- if (strpos($key, $edit['jump']) !== FALSE) {
- $edit['jump'] = $key;
- }
- }
-
- $this->backdropPost($view['page[path]'], $edit, t('Go'));
- $this->assertResponse(200);
- $this->assertUrl($path, $options);
- }
- }
-
-
- * Helper function to create a node and return its expected path.
- */
- function createNodeAndGetPath() {
- $node = $this->backdropCreateNode();
- return entity_uri('node', $node);
- }
-
-
- * Helper function to create a user and return its expected path.
- */
- function createUserAndGetPath() {
- $account = $this->backdropCreateUser();
- return entity_uri('user', $account);
- }
-
-
- * Helper function to create a comment and return its expected path.
- */
- function createCommentAndGetPath() {
- $node = $this->backdropCreateNode();
- $comment = entity_create('comment', array(
- 'cid' => NULL,
- 'nid' => $node->nid,
- 'pid' => 0,
- 'uid' => 0,
- 'status' => COMMENT_PUBLISHED,
- 'subject' => $this->randomName(),
- 'langcode' => LANGUAGE_NONE,
- 'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
- ));
- comment_save($comment);
- return entity_uri('comment', $comment);
- }
-
-
- * Helper function to create a taxonomy term and return its expected path.
- */
- function createTaxonomyTermAndGetPath() {
- $vocabulary = new TaxonomyVocabulary(array(
- 'name' => $this->randomName(),
- 'machine_name' => backdrop_strtolower($this->randomName()),
- ));
- taxonomy_vocabulary_save($vocabulary);
-
- $term = entity_create('taxonomy_term', array(
- 'name' => $this->randomName(),
- 'vocabulary' => $vocabulary->machine_name,
- ));
- taxonomy_term_save($term);
-
- return entity_uri('taxonomy_term', $term);
- }
-
-
- * Helper function to create a file and return its expected path.
- */
- function createFileAndGetPath() {
- $file = entity_create('file', array(
- 'uid' => 1,
- 'filename' => 'views-ui-jump-menu-test.txt',
- 'uri' => 'public://views-ui-jump-menu-test.txt',
- 'filemime' => 'text/plain',
- 'timestamp' => 1,
- 'status' => FILE_STATUS_PERMANENT,
- ));
- file_put_contents($file->uri, 'test content');
- $file->save();
- return file_create_url($file->uri);
- }
-
-
- * Helper function to create a node revision and return its expected path.
- */
- function createNodeRevisionAndGetPath() {
-
-
- $settings = array('revision' => TRUE);
- $node = $this->backdropCreateNode($settings);
- $node->vid = NULL;
- node_save($node);
- return 'node/' . $node->nid . '/revisions/' . $node->vid . '/view';
- }
- }
-
- * Tests that displays can be correctly overridden via the user interface.
- */
- class ViewsUIWizardDisplaysTestCase extends ViewsUIWizardHelper {
-
- * Tests that displays can be overridden via the UI.
- */
- function testOverrideDisplays() {
-
-
- $view['human_name'] = $this->randomName(16);
- $view['name'] = strtolower($this->randomName(16));
- $view['page[create]'] = 1;
- $view['page[path]'] = $this->randomName(16);
- $view['block[create]'] = 1;
- $view_path = $view['page[path]'];
- $this->backdropPost('admin/structure/views/add', $view, t('Save view'));
-
-
-
-
-
- $edit = array();
- $edit['title'] = $original_title = $this->randomName(16);
- $edit['override[dropdown]'] = 'default';
- $this->backdropPost("admin/structure/views/nojs/display/{$view['name']}/page/title", $edit, t('Apply'));
- $this->backdropPost("admin/structure/views/view/{$view['name']}/configure/page", array(), t('Save'));
-
-
-
-
- views_invalidate_cache();
- $layout = layout_load('default');
- $block = $layout->addBlock('views', $view['name'] . '-block', 'sidebar');
- $block->conditions[] = layout_create_access('path', array(
- 'settings' => array(
- 'visibility_setting' => 0,
- 'paths' => $view_path,
- )
- ));
- $layout->save();
-
-
-
- $this->backdropCreateNode();
-
-
- $this->backdropGet($view_path);
- $this->assertText($original_title);
- $this->backdropGet('user');
- $this->assertText($original_title);
-
-
-
- $edit = array();
- $edit['title'] = $new_title = $this->randomName(16);
- $edit['override[dropdown]'] = 'page';
- $this->backdropPost("admin/structure/views/nojs/display/{$view['name']}/page/title", $edit, t('Apply'));
- $this->backdropPost("admin/structure/views/view/{$view['name']}/configure/page", array(), t('Save'));
- $this->backdropGet($view_path);
- $this->assertText($new_title);
- $this->assertNoText($original_title);
- $this->backdropGet('user');
- $this->assertText($original_title);
- $this->assertNoText($new_title);
- }
-
-
- * Tests that the wizard correctly sets up default and overridden displays.
- */
- function testWizardMixedDefaultOverriddenDisplays() {
-
-
-
-
- $view['human_name'] = $this->randomName(16);
- $view['name'] = strtolower($this->randomName(16));
- $view['page[create]'] = 1;
- $view['page[title]'] = $this->randomName(16);
- $view['page[path]'] = $this->randomName(16);
- $view['page[feed]'] = 1;
- $view['page[feed_properties][path]'] = $this->randomName(16);
- $view['block[create]'] = 1;
- $view['block[title]'] = $this->randomName(16);
- $this->backdropPost('admin/structure/views/add', $view, t('Save view'));
-
-
-
-
- views_invalidate_cache();
- $layout = layout_load('default');
- $block = $layout->addBlock('views', $view['name'] . '-block', 'sidebar');
- $block->conditions[] = layout_create_access('path', array(
- 'settings' => array(
- 'visibility_setting' => 0,
- 'paths' => $view['page[path]'],
- )
- ));
- $layout->save();
-
-
-
- $this->backdropCreateNode();
-
-
-
- $this->backdropGet($view['page[path]']);
- $this->assertText($view['page[title]']);
- $this->assertNoText($view['block[title]']);
- $this->backdropGet($view['page[feed_properties][path]']);
- $this->assertText($view['page[title]']);
- $this->assertNoText($view['block[title]']);
- $this->backdropGet('user');
- $this->assertText($view['block[title]']);
- $this->assertNoText($view['page[title]']);
-
-
-
- $edit = array();
- $edit['title'] = $new_default_title = $this->randomName(16);
- $this->backdropPost("admin/structure/views/nojs/display/{$view['name']}/page/title", $edit, t('Apply'));
- $this->backdropPost("admin/structure/views/view/{$view['name']}/configure/page", array(), t('Save'));
- $this->backdropGet($view['page[path]']);
- $this->assertText($new_default_title);
- $this->assertNoText($view['page[title]']);
- $this->assertNoText($view['block[title]']);
- $this->backdropGet($view['page[feed_properties][path]']);
- $this->assertText($new_default_title);
- $this->assertNoText($view['page[title]']);
- $this->assertNoText($view['block[title]']);
- $this->backdropGet('user');
- $this->assertText($view['block[title]']);
- $this->assertNoText($new_default_title);
- $this->assertNoText($view['page[title]']);
-
-
-
- $edit = array();
- $edit['title'] = $new_block_title = $this->randomName(16);
- $this->backdropPost("admin/structure/views/nojs/display/{$view['name']}/block/title", $edit, t('Apply'));
- $this->backdropPost("admin/structure/views/view/{$view['name']}/configure/block", array(), t('Save'));
- $this->backdropGet($view['page[path]']);
- $this->assertText($new_default_title);
- $this->assertNoText($new_block_title);
- $this->backdropGet($view['page[feed_properties][path]']);
- $this->assertText($new_default_title);
- $this->assertNoText($new_block_title);
- $this->backdropGet('user');
- $this->assertText($new_block_title);
- $this->assertNoText($view['block[title]']);
- }
-
-
- * Tests that the revert to all displays select-option works as expected.
- */
- function testRevertAllDisplays() {
-
-
-
- $view['human_name'] = $this->randomName(16);
- $view['name'] = strtolower($this->randomName(16));
- $view['page[create]'] = 1;
- $view['page[title]'] = $this->randomName(16);
- $view['page[path]'] = $this->randomName(16);
- $view['block[create]'] = 1;
- $view['block[title]'] = $this->randomName(16);
- $this->backdropPost('admin/structure/views/add', $view, t('Continue and configure'));
-
-
-
- $edit = array();
- $edit['title'] = $new_block_title = $this->randomName();
- $edit['override[dropdown]'] = 'default_revert';
-
- $this->backdropPost("admin/structure/views/nojs/display/{$view['name']}/block/title", $edit, t('Apply'));
- $this->backdropPost("admin/structure/views/view/{$view['name']}/configure/block", array(), t('Save'));
- $this->assertText($view['page[title]']);
- }
-
-
- * Test reordering of displays.
- */
- function testReorderDisplays() {
-
- $view['human_name'] = $this->randomName(16);
- $view['name'] = strtolower($this->randomName(16));
- $view['page[create]'] = 1;
- $view['page[title]'] = $this->randomName(16);
- $view['page[path]'] = $this->randomName(16);
- $view['block[create]'] = 1;
- $view['block[title]'] = $this->randomName(16);
- $this->backdropPost('admin/structure/views/add', $view, t('Continue and configure'));
-
-
- $display_links = $this->xpath('//*[@id="views-display-menu-tabs"]//a');
- $this->assertEqual((string) $display_links[0], t('Page'));
- $this->assertEqual((string) $display_links[1], t('Block'));
-
- $this->clickLink('reorder displays');
-
- $edit = array(
- 'page[weight]' => 1,
- 'block[weight]' => 0,
- );
-
- $this->backdropPost(NULL, $edit, t('Apply'));
-
-
- $display_links = $this->xpath('//*[@id="views-display-menu-tabs"]//a');
- $this->assertEqual((string) $display_links[0], t('Block'));
- $this->assertEqual((string) $display_links[1], t('Page'));
-
- $this->backdropPost(NULL, array(), t('Save'));
- }
- }