From ce5a34315ba567c924122f9740514b3b3715fc11 Mon Sep 17 00:00:00 2001 From: Cristopher Matos Date: Mon, 11 Oct 2021 11:43:42 -0400 Subject: [PATCH] Add test checking that a redirect link is contained in metadata --- tests/BrokenRedirectedLinkTest.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/BrokenRedirectedLinkTest.php b/tests/BrokenRedirectedLinkTest.php index fcf5c20..36c1da2 100644 --- a/tests/BrokenRedirectedLinkTest.php +++ b/tests/BrokenRedirectedLinkTest.php @@ -32,4 +32,21 @@ public function testCheckRedirected() $this->assertEquals(1, $rule->check(), 'Broken or Redirected Link should have one issue.'); } + + public function testCheckRedirectedAndMetadata() + { + $html = '
I am a link.
'; + $dom = new \DOMDocument('1.0', 'utf-8'); + $dom->loadHTML($html); + $rule = new BrokenRedirectedLink($dom); + + // Check if metadata is present with a new link + $result = $rule->check(); + if ($rule->getIssues() && count($rule->getIssues()) == 1) { + $meta = $rule->getIssues()[0]->getMetadata(); + $result = 1 + $result; + } + + $this->assertEquals(2, $result, 'Broken or Redirected Link should have one issue.'); + } }