From 7f4abc7c81eed475a5a1e8c4332d877eedde53df Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Sat, 14 Mar 2015 10:08:30 +0000 Subject: [PATCH] Issue #2443119 by geertvd: Views preview not working for REST display --- .../src/Tests/Views/StyleSerializerTest.php | 13 +++++++++++++ .../Plugin/views/display/PathPluginBase.php | 2 +- .../Unit/Plugin/display/PathPluginBaseTest.php | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php index 3ab6f79a44ef..bfff89ef9065 100644 --- a/core/modules/rest/src/Tests/Views/StyleSerializerTest.php +++ b/core/modules/rest/src/Tests/Views/StyleSerializerTest.php @@ -292,6 +292,19 @@ public function testLivePreview() { $this->assertEqual($rendered_json, $expected, 'Ensure the previewed json is escaped.'); } + /** + * Tests the views interface for rest export displays. + */ + public function testSerializerViewsUI() { + $this->drupalLogin($this->adminUser); + // Click the "Update preview button". + $this->drupalPostForm('admin/structure/views/view/test_serializer_display_field/edit/rest_export_1', $edit = array(), t('Update preview')); + $this->assertResponse(200); + // Check if we receive the expected result. + $result = $this->xpath('//div[@id="views-live-preview"]/pre'); + $this->assertIdentical($this->drupalGet('test/serialize/field'), (string) $result[0], 'The expected JSON preview output was found.'); + } + /** * Tests the field row style using fieldapi fields. */ diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php index c4cc43fb249b..415b704a1cae 100644 --- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php +++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php @@ -502,7 +502,7 @@ public function getRouteName() { // Check for overridden route names. $view_route_names = $this->getAlteredRouteNames(); - return (isset($view_route_names[$view_route_key]) ? $view_route_names[$view_route_key] : "views.$view_route_key"); + return (isset($view_route_names[$view_route_key]) ? $view_route_names[$view_route_key] : "view.$view_route_key"); } /** diff --git a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php index 56ec973e47fd..0cc643ada8dc 100644 --- a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php @@ -311,6 +311,24 @@ public function testAlterRoutesWithOptionalParameters() { $this->assertEquals(array('arg_0' => 'parameter'), $route->getOption('_view_argument_map')); } + /** + * Tests the getRouteName method. + */ + public function testGetRouteName() { + list($view) = $this->setupViewExecutableAccessPlugin(); + + $display = array(); + $display['display_plugin'] = 'page'; + $display['id'] = 'page_1'; + $display['display_options'] = array( + 'path' => 'test_route', + ); + $this->pathPlugin->initDisplay($view, $display); + $route_name = $this->pathPlugin->getRouteName(); + // Ensure that the expected routename is returned. + $this->assertEquals('view.test_id.page_1', $route_name); + } + /** * Returns some mocked view entity, view executable, and access plugin. */ -- GitLab