Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions behat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
66 changes: 66 additions & 0 deletions features/bootstrap/ResponseHeader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?php

namespace PantheonSystems\PantheonWordPressUpstreamTests\Behat;

use Behat\MinkExtension\Context\RawMinkContext;

class ResponseHeader extends RawMinkContext {

/**
* Checks, that current page response header is equal to specified.
*
* @Then /^the response header "(?P<name>(?:[^"]|\\")*)" should be "(?P<value>(?:[^"]|\\")*)"$/
*/
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<name>(?:[^"]|\\")*)" should not be "(?P<value>(?:[^"]|\\")*)"$/
*/
public function assertResponseHeaderIsNot($name, $value)
{
$this->assertSession()->responseHeaderNotEquals($name, $value);
}

/**
* Checks that the current page response header is set
*
* @Then /^the response header "(?P<name>(?:[^"]|\\")*)" 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<name>(?:[^"]|\\")*)" 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<name>(?:[^"]|\\")*)" should contain "(?P<value>(?:[^"]|\\")*)"$/
*/
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<name>(?:[^"]|\\")*)" should not contain "(?P<value>(?:[^"]|\\")*)"$/
*/
public function assertResponseHeaderNotContains($name, $value)
{
$this->assertSession()->responseHeaderNotContains($name, $value);
}

}
13 changes: 13 additions & 0 deletions features/pantheon-logged-out.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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 "Cache-Control" should contain "max-age=600"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason to test only max-age and not

And the response header "Cache-Control" should be "public, max-age=600"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessarily. I've made it more precise in d4009cc


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 "Cache-Control" should contain "no-cache"
And the response header "Cache-Control" should not contain "max-age=600"