summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-12-22 23:41:56 (GMT)
committerAlex Pott2015-12-22 23:41:56 (GMT)
commit39457444574e0dd4fff6c433a65fcd2016909cf8 (patch)
treef0d19991d5e3f4a325300c3194887b4edefb159d
parent0eceb0ce3350c1fd80852825b504fa1b3c43587f (diff)
Issue #2400543 by Nitesh Pawar, abhishek.kumar, hugronaphor, jibran, dawehner, PieterJanPut, wuinfo, cilefen, alexpott, ameymudras, lauriii, pec, ashutoshsngh, Truptti, JmOkay: Breadcrumb should be term name instead of term id on term edit and delete page
-rw-r--r--core/modules/taxonomy/src/Tests/TermTest.php34
-rw-r--r--core/modules/views/src/Plugin/views/display/PathPluginBase.php4
-rw-r--r--core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php55
3 files changed, 93 insertions, 0 deletions
diff --git a/core/modules/taxonomy/src/Tests/TermTest.php b/core/modules/taxonomy/src/Tests/TermTest.php
index 4bf221f..7165722 100644
--- a/core/modules/taxonomy/src/Tests/TermTest.php
+++ b/core/modules/taxonomy/src/Tests/TermTest.php
@@ -551,4 +551,38 @@ class TermTest extends TaxonomyTestBase {
$this->assertRaw($term->getName(), 'Term is displayed after saving the node with no changes.');
}
+ /**
+ * Check the breadcrumb on edit and delete a term page.
+ */
+ public function testTermBreadcrumbs() {
+ $edit = [
+ 'name[0][value]' => $this->randomMachineName(14),
+ 'description[0][value]' => $this->randomMachineName(100),
+ 'parent[]' => [0],
+ ];
+
+ // Create the term.
+ $this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
+
+ $terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']);
+ $term = reset($terms);
+ $this->assertNotNull($term, 'Term found in database.');
+
+ // Check the breadcrumb on the term edit page.
+ $this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
+ $breadcrumbs = $this->cssSelect('nav.breadcrumb ol li a');
+ $this->assertIdentical(count($breadcrumbs), 2, 'The breadcrumbs are present on the page.');
+ $this->assertIdentical((string) $breadcrumbs[0], 'Home', 'First breadcrumb text is Home');
+ $this->assertIdentical((string) $breadcrumbs[1], $term->label(), 'Second breadcrumb text is term name on term edit page.');
+ $this->assertEscaped((string) $breadcrumbs[1], 'breadcrumbs displayed and escaped.');
+
+ // Check the breadcrumb on the term delete page.
+ $this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
+ $breadcrumbs = $this->cssSelect('nav.breadcrumb ol li a');
+ $this->assertIdentical(count($breadcrumbs), 2, 'The breadcrumbs are present on the page.');
+ $this->assertIdentical((string) $breadcrumbs[0], 'Home', 'First breadcrumb text is Home');
+ $this->assertIdentical((string) $breadcrumbs[1], $term->label(), 'Second breadcrumb text is term name on term delete page.');
+ $this->assertEscaped((string) $breadcrumbs[1], 'breadcrumbs displayed and escaped.');
+ }
+
}
diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php
index 738fbf4..402e00c 100644
--- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php
@@ -270,6 +270,10 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
// that parameter conversion options is carried over.
$route->setOptions($route->getOptions() + $original_route->getOptions());
+ if ($original_route->hasDefault('_title_callback')) {
+ $route->setDefault('_title_callback', $original_route->getDefault('_title_callback'));
+ }
+
// Set the corrected path and the mapping to the route object.
$route->setOption('_view_argument_map', $argument_map);
$route->setPath($path);
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 bae789a..90d2ae7 100644
--- a/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
+++ b/core/modules/views/tests/src/Unit/Plugin/display/PathPluginBaseTest.php
@@ -261,6 +261,44 @@ class PathPluginBaseTest extends UnitTestCase {
}
/**
+ * Tests the alter route method with preexisting title callback.
+ */
+ public function testAlterRouteWithAlterCallback() {
+ $collection = new RouteCollection();
+ $collection->add('test_route', new Route('test_route', array('_controller' => 'Drupal\Tests\Core\Controller\TestController::content', '_title_callback' => '\Drupal\Tests\views\Unit\Plugin\display\TestController::testTitle')));
+ $route_2 = new Route('test_route/example', array('_controller' => 'Drupal\Tests\Core\Controller\TestController::content'));
+ $collection->add('test_route_2', $route_2);
+
+ 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);
+
+ $view_route_names = $this->pathPlugin->alterRoutes($collection);
+ $this->assertEquals(array('test_id.page_1' => 'test_route'), $view_route_names);
+
+ // Ensure that the test_route is overridden.
+ $route = $collection->get('test_route');
+ $this->assertTrue($route instanceof Route);
+ $this->assertEquals('test_id', $route->getDefault('view_id'));
+ $this->assertEquals('\Drupal\Tests\views\Unit\Plugin\display\TestController::testTitle', $route->getDefault('_title_callback'));
+ $this->assertEquals('page_1', $route->getDefault('display_id'));
+ $this->assertEquals('my views title', $route->getDefault('_title'));
+
+ // Ensure that the test_route_2 is not overridden.
+ $route = $collection->get('test_route_2');
+ $this->assertTrue($route instanceof Route);
+ $this->assertFalse($route->hasDefault('view_id'));
+ $this->assertFalse($route->hasDefault('display_id'));
+ $this->assertSame($collection->get('test_route_2'), $route_2);
+ }
+
+ /**
* Tests the collectRoutes method with a path containing named parameters.
*
* @see \Drupal\views\Plugin\views\display\PathPluginBase::collectRoutes()
@@ -457,3 +495,20 @@ class PathPluginBaseTest extends UnitTestCase {
}
}
+
+/**
+ * A page controller for use by tests in this file.
+ */
+class TestController {
+
+ /**
+ * A page title callback.
+ *
+ * @return string
+ * The page title.
+ */
+ public function testTitle() {
+ return 'Test title';
+ }
+
+}