Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertSitemapSubmissionToRobotsTxt.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Constraint\AbstractConstraint;
10 use Magento\Mtf\Client\BrowserInterface;
11 
15 class AssertSitemapSubmissionToRobotsTxt extends AbstractConstraint
16 {
20  const HTTP_NOT_FOUND = '404 Not Found';
21 
27  private $filename = 'robots.txt';
28 
35  public function processAssert(BrowserInterface $browser)
36  {
37  $browser->open($_ENV['app_frontend_url'] . $this->filename);
38  \PHPUnit\Framework\Assert::assertNotEquals(
39  self::HTTP_NOT_FOUND,
40  $browser->getTitle(),
41  'File ' . $this->filename . ' is not readable or not exists.'
42  );
43 
44  $expectedRobotsContent = 'Sitemap: ' . $_ENV['app_frontend_url'] . 'sitemap.xml';
45  \PHPUnit\Framework\Assert::assertTrue(
46  strpos($browser->getHtmlSource(), $expectedRobotsContent) !== false,
47  'File ' . $this->filename . ' contains incorrect data.'
48  );
49  }
50 
56  public function toString()
57  {
58  return 'File ' . $this->filename . ' contains correct content.';
59  }
60 }