You are here

public function AdsTxtBasicTestCase::testAdsTxtConfigureAdsTxt in AdsTxt 7

Checks that a configured ads.txt file is delivered as configured.

File

./adstxt.test, line 77
Tests for adstxt.module.

Class

AdsTxtBasicTestCase
Tests basic functionality of configured ads.txt files.

Code

public function testAdsTxtConfigureAdsTxt() {

  // Create an admin user, log in and access settings form.
  $admin_user = $this
    ->drupalCreateUser(array(
    'administer ads.txt',
  ));
  $this
    ->drupalLogin($admin_user);

  // Modify and save the ads.txt content.
  $edit = array();
  $test_string = "# SimpleTest {$this->testId}";
  $edit['adstxt'] = "#PHP_EOL{$test_string}PHP_EOL#PHP_EOL" . variable_get('adstxt', '');
  $this
    ->drupalPost('admin/config/system/adstxt', $edit, t('Save configuration'));

  // Confirm that output contains changes.
  $this
    ->drupalLogout();
  $this
    ->drupalGet('ads.txt');
  $this
    ->assertResponse(200, 'An anonymous user is delivered content at the /ads.txt path.');
  $this
    ->assertText("# SimpleTest {$this->testId}", sprintf('Test string [%s] is displayed in the configured ads.txt file.', $test_string));
}