public function XmlSitemapUnitTest::testUpdateLinks in XML sitemap 8
Same name and namespace in other branches
- 2.x tests/src/Functional/XmlSitemapUnitTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapUnitTest::testUpdateLinks()
TestUpdateLinks.
Tests for \Drupal\xmlsitemap\XmlSitemapLinkStorageInterface::updateMultiple().
File
- tests/
src/ Functional/ XmlSitemapUnitTest.php, line 241
Class
- XmlSitemapUnitTest
- Unit tests for the XML sitemap module.
Namespace
Drupal\Tests\xmlsitemap\FunctionalCode
public function testUpdateLinks() {
// Add our testing data.
// @codingStandardsIgnoreLine
$links = [];
$links[1] = $this
->addSitemapLink([
'subtype' => 'group1',
]);
$links[2] = $this
->addSitemapLink([
'subtype' => 'group1',
]);
$links[3] = $this
->addSitemapLink([
'subtype' => 'group2',
]);
$this->state
->set('xmlsitemap_regenerate_needed', FALSE);
// Id | type | subtype | language | access | status | priority
// 1 | testing | group1 | '' | 1 | 1 | 0.5
// 2 | testing | group1 | '' | 1 | 1 | 0.5
// 3 | testing | group2 | '' | 1 | 1 | 0.5.
$updated = $this->linkStorage
->updateMultiple([
'status' => 0,
], [
'type' => 'testing',
'subtype' => 'group1',
'status_override' => 0,
]);
$this
->assertEquals(2, $updated);
$this
->assertFlag('xmlsitemap_regenerate_needed', TRUE);
// Id | type | subtype | language | status | priority
// 1 | testing | group1 | '' | 0 | 0.5
// 2 | testing | group1 | '' | 0 | 0.5
// 3 | testing | group2 | '' | 1 | 0.5.
$updated = $this->linkStorage
->updateMultiple([
'priority' => 0.0,
], [
'type' => 'testing',
'subtype' => 'group1',
'priority_override' => 0,
]);
$this
->assertEquals(2, $updated);
$this
->assertFlag('xmlsitemap_regenerate_needed', FALSE);
// Id | type | subtype | language | status | priority
// 1 | testing | group1 | '' | 0 | 0.0
// 2 | testing | group1 | '' | 0 | 0.0
// 3 | testing | group2 | '' | 1 | 0.5.
$updated = $this->linkStorage
->updateMultiple([
'subtype' => 'group2',
], [
'type' => 'testing',
'subtype' => 'group1',
]);
$this
->assertEquals(2, $updated);
$this
->assertFlag('xmlsitemap_regenerate_needed', FALSE);
// Id | type | subtype | language | status | priority
// 1 | testing | group2 | '' | 0 | 0.0
// 2 | testing | group2 | '' | 0 | 0.0
// 3 | testing | group2 | '' | 1 | 0.5.
$updated = $this->linkStorage
->updateMultiple([
'status' => 1,
], [
'type' => 'testing',
'subtype' => 'group2',
'status_override' => 0,
'status' => 0,
]);
$this
->assertEquals(2, $updated);
$this
->assertFlag('xmlsitemap_regenerate_needed', TRUE);
// Id | type | subtype | language | status | priority
// 1 | testing | group2 | '' | 1 | 0.0
// 2 | testing | group2 | '' | 1 | 0.0
// 3 | testing | group2 | '' | 1 | 0.5.
}