public function AdsTxtTest::testAdsTxtConfigureAdsTxt in AdsTxt 8
Checks that a configured ads.txt file is delivered as configured.
File
- tests/
src/ Functional/ AdsTxtTest.php, line 81
Class
- AdsTxtTest
- Tests functionality of configured ads.txt files.
Namespace
Drupal\Tests\adstxt\FunctionalCode
public function testAdsTxtConfigureAdsTxt() {
// Create an admin user, log in and access settings form.
$this->admin_user = $this
->drupalCreateUser([
'administer ads.txt',
]);
$this
->drupalLogin($this->admin_user);
$this
->drupalGet('admin/config/system/adstxt');
$test_string = "# SimpleTest {$this->randomMachineName()}";
$this
->submitForm([
'adstxt_content' => $test_string,
], t('Save configuration'));
$this
->drupalLogout();
$this
->drupalGet('ads.txt');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseHeaderEquals('Content-Type', 'text/plain; charset=UTF-8');
$content = $this
->getSession()
->getPage()
->getContent();
$this
->assertTrue($content == $test_string, sprintf('Test string [%s] is displayed in the configured ads.txt file [%s].', $test_string, $content));
}