XmlSitemapUserFunctionalTest.php in XML sitemap 2.x
File
tests/src/Functional/XmlSitemapUserFunctionalTest.php
View source
<?php
namespace Drupal\Tests\xmlsitemap\Functional;
use Drupal\Core\Session\AccountInterface;
use Drupal\user\Entity\Role;
class XmlSitemapUserFunctionalTest extends XmlSitemapTestBase {
protected $accounts = [];
protected function setUp() {
parent::setUp();
$user_role = Role::load(AccountInterface::ANONYMOUS_ROLE);
$user_role
->grantPermission('access user profiles');
$user_role
->save();
xmlsitemap_link_bundle_enable('user', 'user');
xmlsitemap_link_bundle_settings_save('user', 'user', [
'status' => 1,
'priority' => XMLSITEMAP_PRIORITY_DEFAULT,
]);
$this->admin_user = $this
->drupalCreateUser([
'administer users',
'administer permissions',
'administer xmlsitemap',
]);
$this->normal_user = $this
->drupalCreateUser([
'access content',
]);
}
public function testBlockedUser() {
$this
->assertSitemapLinkVisible('user', $this->normal_user
->id());
$this->container
->get('entity_type.manager')
->getAccessControlHandler('user')
->resetCache();
$this->normal_user
->block();
$this->normal_user
->save();
$this
->assertSitemapLinkNotVisible('user', $this->normal_user
->id());
}
public function testUserForm() {
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('admin/people/create');
$this
->assertSession()
->fieldExists('xmlsitemap[status]');
$this
->assertSession()
->fieldExists('xmlsitemap[priority]');
$this
->assertSession()
->fieldExists('xmlsitemap[changefreq]');
$this
->drupalGet('user/' . $this->normal_user
->id() . '/edit');
$this
->assertSession()
->fieldExists('xmlsitemap[status]');
$this
->assertSession()
->fieldExists('xmlsitemap[priority]');
$this
->assertSession()
->fieldExists('xmlsitemap[changefreq]');
}
}