public function XmlSitemapEntityFunctionalTest::testEntityLinkBundleSettingsForm in XML sitemap 8
Same name and namespace in other branches
- 2.x tests/src/Functional/XmlSitemapEntityFunctionalTest.php \Drupal\Tests\xmlsitemap\Functional\XmlSitemapEntityFunctionalTest::testEntityLinkBundleSettingsForm()
Test Entity Link Bundle Settings Form.
Test the form at admin/config/search/xmlsitemap/settings/{entity_type_id}/{bundle_id}.
File
- tests/
src/ Functional/ XmlSitemapEntityFunctionalTest.php, line 66
Class
- XmlSitemapEntityFunctionalTest
- Tests the generation of a random content entity links.
Namespace
Drupal\Tests\xmlsitemap\FunctionalCode
public function testEntityLinkBundleSettingsForm() {
xmlsitemap_link_bundle_enable('entity_test_mul', 'entity_test_mul');
$this
->drupalLogin($this->admin_user);
// Set priority and inclusion for entity_test_mul - entity_test_mul.
$this
->drupalGet('admin/config/search/xmlsitemap/settings/entity_test_mul/entity_test_mul');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->fieldExists('xmlsitemap[status]');
$this
->assertSession()
->fieldExists('xmlsitemap[priority]');
$this
->assertSession()
->fieldExists('xmlsitemap[changefreq]');
$edit = [
'xmlsitemap[status]' => 0,
'xmlsitemap[priority]' => 0.3,
'xmlsitemap[changefreq]' => XMLSITEMAP_FREQUENCY_WEEKLY,
];
$this
->drupalPostForm(NULL, $edit, t('Save configuration'));
$entity = EntityTestMul::create();
$entity
->save();
$this
->assertSitemapLinkValues('entity_test_mul', $entity
->id(), [
'status' => 0,
'priority' => 0.3,
'changefreq' => XMLSITEMAP_FREQUENCY_WEEKLY,
'access' => 1,
]);
$this
->regenerateSitemap();
$this
->drupalGetSitemap();
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseNotContains($entity
->toUrl()
->getInternalPath());
$entity
->delete();
$this
->assertNoSitemapLink('entity_test_mul');
$edit = [
'xmlsitemap[status]' => 1,
'xmlsitemap[priority]' => 0.6,
'xmlsitemap[changefreq]' => XMLSITEMAP_FREQUENCY_YEARLY,
];
$this
->drupalPostForm('admin/config/search/xmlsitemap/settings/entity_test_mul/entity_test_mul', $edit, t('Save configuration'));
$entity = EntityTestMul::create();
$entity
->save();
$this
->assertSitemapLinkValues('entity_test_mul', $entity
->id(), [
'status' => 1,
'priority' => 0.6,
'changefreq' => XMLSITEMAP_FREQUENCY_YEARLY,
'access' => 1,
]);
$this
->regenerateSitemap();
$this
->drupalGetSitemap();
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseContains($entity
->toUrl()
->getInternalPath());
$id = $entity
->id();
$entity
->delete();
$this
->assertNoSitemapLink('entity_test_mul', $id);
}