diff --git a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php index 4ccd11d..077949a 100644 --- a/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/DisplayTest.php @@ -19,7 +19,7 @@ class DisplayTest extends PluginTestBase { * * @var array */ - public static $testViews = array('test_filter_groups', 'test_get_attach_displays', 'test_view'); + public static $testViews = array('test_filter_groups', 'test_get_attach_displays', 'test_view', 'test_display_more'); /** * Modules to enable. @@ -143,4 +143,35 @@ public function testGetAttachedDisplays() { $this->assertEqual($view->display_handler->getAttachedDisplays(), array()); } + /** + * Tests the readmore functionality. + */ + public function testReadMore() { + $expected_more_text = 'custom more text'; + + $view = views_get_view('test_display_more'); + $this->executeView($view); + + $output = $view->preview(); + $output = drupal_render($output); + + $this->drupalSetContent($output); + $result = $this->xpath('//div[@class=:class]/a', array(':class' => 'more-link')); + $this->assertEqual($result[0]->attributes()->href, url('test_display_more'), 'The right more link is shown.'); + $this->assertEqual(trim($result[0][0]), $expected_more_text, 'The right link text is shown.'); + + // Test the renderMoreLink method directly. This could be directly unit + // tested. + $more_link = $view->display_handler->renderMoreLink(); + $this->drupalSetContent($more_link); + $result = $this->xpath('//div[@class=:class]/a', array(':class' => 'more-link')); + $this->assertEqual($result[0]->attributes()->href, url('test_display_more'), 'The right more link is shown.'); + $this->assertEqual(trim($result[0][0]), $expected_more_text, 'The right link text is shown.'); + + // Test the useMoreText method directly. This could be directly unit + // tested. + $more_text = $view->display_handler->useMoreText(); + $this->assertEqual($more_text, $expected_more_text, 'The right more text is chosen.'); + } + } diff --git a/core/modules/views/tests/views_test_config/test_views/views.view.test_display_more.yml b/core/modules/views/tests/views_test_config/test_views/views.view.test_display_more.yml new file mode 100644 index 0000000..479d7a4 --- /dev/null +++ b/core/modules/views/tests/views_test_config/test_views/views.view.test_display_more.yml @@ -0,0 +1,50 @@ +base_table: views_test_data +core: '8' +description: '' +status: '1' +display: + default: + display_options: + defaults: + fields: '0' + pager: '0' + pager_options: '0' + sorts: '0' + fields: + id: + field: id + id: id + relationship: none + table: views_test_data + plugin_id: numeric + pager: + options: + offset: '0' + type: none + pager_options: { } + sorts: + id: + field: id + id: id + order: ASC + relationship: none + table: views_test_data + plugin_id: numeric + use_more: '1' + use_more_always: '1' + use_more_text: 'custom more text' + link_display: page_1 + display_plugin: default + display_title: Master + id: default + position: '0' + page_1: + display_plugin: page + id: page_1 + display_title: Page + position: '1' + display_options: + path: test_display_more +label: 'Test display more' +id: test_display_more +tag: ''