You are here

public function AdsTxtBasicTestCase::testAdsTxtPath in AdsTxt 7

Test that the ads.txt route delivers content with an appropriate header.

File

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

Class

AdsTxtBasicTestCase
Tests basic functionality of configured ads.txt files.

Code

public function testAdsTxtPath() {
  $this
    ->drupalGet('ads.txt');
  $this
    ->assertResponse(200, 'An anonymous user is delivered content at the /ads.txt path.');
  $this
    ->assertText('greenadexchange.com, 12345, DIRECT, AEC242');
  $this
    ->assertText('blueadexchange.com, 4536, DIRECT');
  $this
    ->assertText('silverssp.com, 9675, RESELLER');

  // Note: the header may have charset appended.
  $header = $this
    ->drupalGetHeader('Content-Type');
  $this
    ->assertIdentical(strpos($header, 'text/plain'), 0, 'The ads.txt file was served with header Content-Type: text/plain');
}