diff --git a/behat.yml b/behat.yml index e30c46a..af09c08 100644 --- a/behat.yml +++ b/behat.yml @@ -7,6 +7,7 @@ default: contexts: - Behat\MinkExtension\Context\MinkContext - PantheonSystems\PantheonWordPressUpstreamTests\Behat\AdminLogIn + - PantheonSystems\PantheonWordPressUpstreamTests\Behat\ResponseHeader extensions: Behat\MinkExtension: # base_url set by ENV diff --git a/features/bootstrap/ResponseHeader.php b/features/bootstrap/ResponseHeader.php new file mode 100644 index 0000000..fc41107 --- /dev/null +++ b/features/bootstrap/ResponseHeader.php @@ -0,0 +1,66 @@ +(?:[^"]|\\")*)" should be "(?P(?:[^"]|\\")*)"$/ + */ + public function assertResponseHeader($name, $value) + { + $this->assertSession()->responseHeaderEquals($name, $value); + } + + /** + * Checks, that current page response header is not equal to specified. + * + * @Then /^the response header "(?P(?:[^"]|\\")*)" should not be "(?P(?:[^"]|\\")*)"$/ + */ + public function assertResponseHeaderIsNot($name, $value) + { + $this->assertSession()->responseHeaderNotEquals($name, $value); + } + + /** + * Checks that the current page response header is set + * + * @Then /^the response header "(?P(?:[^"]|\\")*)" should exist$/ + */ + public function assertResponseHeaderExists($name) { + $this->assertSession()->responseHeaderMatches($name,'/^.{1,}$/'); + } + + /** + * Checks that the current page response header is not set + * + * @Then /^the response header "(?P(?:[^"]|\\")*)" should not exist$/ + */ + public function assertResponseHeaderNotExists($name) { + $this->assertSession()->responseHeaderMatches($name,'/^.{0}$/'); + } + + /** + * Checks, that current page response header contains specified value. + * + * @Then /^the response header "(?P(?:[^"]|\\")*)" should contain "(?P(?:[^"]|\\")*)"$/ + */ + public function assertResponseHeaderContains($name, $value) + { + $this->assertSession()->responseHeaderContains($name, $value); + } + /** + * Checks, that current page response header does not contain specified value. + * + * @Then /^the response header "(?P(?:[^"]|\\")*)" should not contain "(?P(?:[^"]|\\")*)"$/ + */ + public function assertResponseHeaderNotContains($name, $value) + { + $this->assertSession()->responseHeaderNotContains($name, $value); + } + +} diff --git a/features/pantheon-logged-out.feature b/features/pantheon-logged-out.feature new file mode 100644 index 0000000..76d72f1 --- /dev/null +++ b/features/pantheon-logged-out.feature @@ -0,0 +1,14 @@ +Feature: Verify various Pantheon features as a logged-out user + + Scenario: Cache-Control should default to TTL=600 + When I go to "/" + Then the response header "Cache-Control" should exist + And the response header "Pragma" should not exist + And the response header "Cache-Control" should be "public, max-age=600" + + Scenario: Cache-Control should have "nocache" for logged-in users + Given I log in as an admin + + When I go to "/" + And the response header "Pragma" should exist + And the response header "Pragma" should contain "no-cache"