public function AccessTest::testAccessModifiedHeader in Access unpublished 8
Checks entity access before and after token creation.
File
- tests/
src/ Functional/ AccessTest.php, line 122
Class
- AccessTest
- Tests the article creation.
Namespace
Drupal\Tests\access_unpublished\FunctionalCode
public function testAccessModifiedHeader() {
$assert_session = $this
->assertSession();
// Create a token for the entity.
$validToken = AccessToken::create([
'entity_type' => 'node',
'entity_id' => $this->entity
->id(),
'value' => 'iAmValid',
'expire' => -1,
]);
$validToken
->save();
$this
->drupalGet($this->entity
->toUrl(), [
'query' => [
'auHash' => 'iAmValid',
],
]);
$assert_session
->statusCodeEquals(200);
$assert_session
->responseHeaderNotContains('X-Robots-Tag', 'noindex');
\Drupal::configFactory()
->getEditable('access_unpublished.settings')
->set('modify_http_headers', [
'X-Robots-Tag' => 'noindex',
])
->save();
$this
->drupalGet($this->entity
->toUrl(), [
'query' => [
'auHash' => 'iAmValid',
],
]);
$assert_session
->statusCodeEquals(200);
$assert_session
->responseHeaderContains('X-Robots-Tag', 'noindex');
}