diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php index 76713c2..024727a 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php @@ -321,7 +321,7 @@ public function useGroupBy() { */ public function useMoreAlways() { if ($this->usesMore()) { - return $this->getOption('useMoreAlways'); + return $this->getOption('use_more_always'); } return FALSE; } @@ -331,7 +331,7 @@ public function useMoreAlways() { */ public function useMoreText() { if ($this->usesMore()) { - return $this->getOption('useMoreText'); + return $this->getOption('use_more_text'); } return FALSE; } @@ -1436,7 +1436,7 @@ public function buildOptionsForm(&$form, &$form_state) { '#type' => 'textfield', '#title' => t('More link text'), '#description' => t("The text to display for the more link."), - '#default_value' => $this->getOption('useMoreText'), + '#default_value' => $this->getOption('use_more_text'), '#states' => array( 'visible' => array( ':input[name="use_more"]' => array('checked' => TRUE), 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..cb7f2c5 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. @@ -55,7 +55,7 @@ public function setUp() { * * @see Drupal\views_test_data\Plugin\views\display\DisplayTest */ - function testDisplayPlugin() { + function _testDisplayPlugin() { $view = views_get_view('test_view'); // Add a new 'display_test' display and test it's there. @@ -119,7 +119,7 @@ function testDisplayPlugin() { /** * Tests the overriding of filter_groups. */ - public function testFilterGroupsOverriding() { + public function _testFilterGroupsOverriding() { $view = views_get_view('test_filter_groups'); $view->initDisplay(); @@ -132,7 +132,7 @@ public function testFilterGroupsOverriding() { /** * Tests the getAttachedDisplays method. */ - public function testGetAttachedDisplays() { + public function _testGetAttachedDisplays() { $view = views_get_view('test_get_attach_displays'); // Both the feed_1 and the feed_2 display are attached to the page display. @@ -143,4 +143,41 @@ 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); + debug($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.'); + debug($result); + $this->assertEqual($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); + debug($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.'); + debug($result); + $this->assertEqual($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: ''