public function LinkcheckerRedirectTest::testLinkcheckerRedirect in Link checker 8
Test the linkchecker module with redirect integration.
File
- tests/
src/ Kernel/ LinkcheckerRedirectTest.php, line 81
Class
- LinkcheckerRedirectTest
- Test linkchecker with the redirect module.
Namespace
Drupal\Tests\linkchecker\KernelCode
public function testLinkcheckerRedirect() {
$node = $this
->createNode([
'type' => 'links',
]);
$this->linkCheckerLinkStorage
->create([
'url' => '/unexisting-url',
'entity_id' => [
'target_id' => $node
->id(),
'target_type' => $node
->getEntityTypeId(),
],
'entity_field' => 'body',
'entity_langcode' => $node
->language()
->getId(),
'last_check' => 680356800,
'fail_count' => 3,
'status' => 1,
])
->save();
$redirect = $this->redirectStorage
->create();
$redirect
->setSource('unexisting-url');
$redirect
->setRedirect('<front>');
$redirect
->setStatusCode(301);
$redirect
->save();
$links = $this->linkCheckerLinkStorage
->loadByProperties([
'url' => '/unexisting-url',
]);
$this
->assertNotEmpty($links);
$link = current($links);
// Make sure the last_check value is reset when a redirect is created.
$this
->assertEquals(0, $link
->get('last_check')->value);
}