.../ActiveLinkResponseFilterTest.php | 36 ++++++++-------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php b/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php index b79428d..82b3c2e 100644 --- a/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php +++ b/core/tests/Drupal/Tests/Core/EventSubscriber/ActiveLinkResponseFilterTest.php @@ -243,14 +243,6 @@ public function providerTestSetLinkActiveClass() { $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => "")); $situations[] = array('context' => $context, 'is active' => FALSE, 'attributes' => $attributes + array('hreflang' => 'en', 'data-drupal-link-query' => TRUE)); - // Helper function to generate a stubbed renderable array. - $create_element = function ($markup) { - return array( - '#markup' => $markup, - '#attached' => array(), - ); - }; - // Loop over the surrounding HTML variations. $data = array(); for ($h = 0; $h < count($html); $h++) { @@ -291,7 +283,7 @@ public function providerTestSetLinkActiveClass() { $target_markup = $create_markup(new Attribute($active_attributes)); } - $data[] = array($create_element($source_markup), $situation['context'], $create_element($target_markup)); + $data[] = array($source_markup, $situation['context'], $target_markup); } } } @@ -300,9 +292,9 @@ public function providerTestSetLinkActiveClass() { // Test case to verify that the 'is-active' class is not added multiple // times. $data[] = [ - 0 => ['#markup' => 'Once Twice'], + 0 => 'Once Twice', 1 => ['path' => '', 'front' => TRUE, 'language' => 'en', 'query' => []], - 2 => ['#markup' => 'Once Twice'], + 2 => 'Once Twice', ]; // Test cases to verify that the 'is-active' class is added when on the @@ -315,14 +307,14 @@ public function providerTestSetLinkActiveClass() { $front_path_link = 'Front Path'; $front_path_link_active = 'Front Path'; $data[] = [ - 0 => ['#markup' => $front_path_link . ' ' . $front_special_link], + 0 => $front_path_link . ' ' . $front_special_link, 1 => ['path' => 'myfrontpage', 'front' => TRUE, 'language' => 'en', 'query' => []], - 2 => ['#markup' => $front_path_link_active . ' ' . $front_special_link_active], + 2 => $front_path_link_active . ' ' . $front_special_link_active, ]; $data[] = [ - 0 => ['#markup' => $front_special_link . ' ' . $front_path_link], + 0 => $front_special_link . ' ' . $front_path_link, 1 => ['path' => 'myfrontpage', 'front' => TRUE, 'language' => 'en', 'query' => []], - 2 => ['#markup' => $front_special_link_active . ' ' . $front_path_link_active], + 2 => $front_special_link_active . ' ' . $front_path_link_active, ]; return $data; @@ -331,10 +323,8 @@ public function providerTestSetLinkActiveClass() { /** * Tests setLinkActiveClass(). * - * @param array $element - * A renderable array with the following keys: - * - #markup - * - #attached + * @param string $html_markup + * The original HTML markup. * @param array $context * The page context to simulate. An array with the following keys: * - path: the system path of the currently active page @@ -342,14 +332,14 @@ public function providerTestSetLinkActiveClass() { * current path might also be ) * - language: the language code of the currently active page * - query: the query string for the currently active page - * @param array $expected_element - * The returned renderable array. + * @param string $expected_html_markup + * The expected updated HTML markup. * * @dataProvider providerTestSetLinkActiveClass * @covers ::setLinkActiveClass */ - public function testSetLinkActiveClass(array $element, array $context, $expected_element) { - $this->assertSame($expected_element['#markup'], ActiveLinkResponseFilter::setLinkActiveClass($element['#markup'], $context['path'], $context['front'], $context['language'], $context['query'])); + public function testSetLinkActiveClass($html_markup, array $context, $expected_html_markup) { + $this->assertSame($expected_html_markup, ActiveLinkResponseFilter::setLinkActiveClass($html_markup, $context['path'], $context['front'], $context['language'], $context['query'])); } }