public function XmlSitemapUnitTest::testLinkDelete in XML sitemap 2.x
Same name and namespace in other branches
- 8 tests/src/Functional/XmlSitemapUnitTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapUnitTest::testLinkDelete()
Tests for XmlSitemapLinkStorage::delete().
File
- tests/
src/ Functional/ XmlSitemapUnitTest.php, line 213
Class
- XmlSitemapUnitTest
- Unit tests for the XML sitemap module.
Namespace
Drupal\Tests\xmlsitemap\FunctionalCode
public function testLinkDelete() {
// Add our testing data.
$link1 = $this
->addSitemapLink([
'loc' => '/testing1',
'status' => 0,
]);
$link2 = $this
->addSitemapLink([
'loc' => '/testing1',
'status' => 1,
]);
$link3 = $this
->addSitemapLink([
'status' => 0,
]);
$this->state
->set('xmlsitemap_regenerate_needed', FALSE);
// Test delete multiple links.
// Test that the regenerate flag is set when visible links are deleted.
$deleted = $this->linkStorage
->deleteMultiple([
'loc' => '/testing1',
]);
$this
->assertEquals(2, $deleted);
$this
->assertEmpty($this->linkStorage
->load($link1['type'], $link1['id']));
$this
->assertEmpty($this->linkStorage
->load($link2['type'], $link2['id']));
$this
->assertNotEmpty($this->linkStorage
->load($link3['type'], $link3['id']));
$this
->assertFlag('xmlsitemap_regenerate_needed', TRUE);
$deleted = $this->linkStorage
->delete($link3['type'], $link3['id']);
$this
->assertEquals(1, $deleted);
$this
->assertEmpty($this->linkStorage
->load($link3['type'], $link3['id']));
$this
->assertFlag('xmlsitemap_regenerate_needed', FALSE);
}