-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Acceptance test for response header testing
- Loading branch information
Showing
9 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!doctype html> | ||
<script src="/Script/my-script.js"></script> | ||
<p>This is the homepage</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This is a static JavaScript file. | ||
console.log("Hello!"); |
26 changes: 26 additions & 0 deletions
26
test/Acceptance/HTTPHeaders/test/Acceptance/Behat/FeatureContext.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
use Behat\MinkExtension\Context\MinkContext; | ||
use Behat\Gherkin\Node\TableNode; | ||
use PHPUnit_Framework_Assert as PHPUnit; | ||
|
||
class FeatureContext extends MinkContext { | ||
|
||
/** | ||
* @Then /^the response headers should include:$/ | ||
*/ | ||
public function theResponseHeadersShouldInclude(TableNode $table) { | ||
$actualHeaders = $this->getSession()->getResponseHeaders(); | ||
$expectedHeaders = $table->getRowsHash(); | ||
$actualHeaders = array_change_key_case($actualHeaders, CASE_LOWER); | ||
$expectedHeaders = array_change_key_case($expectedHeaders, CASE_LOWER); | ||
|
||
array_shift($expectedHeaders); | ||
|
||
foreach ($expectedHeaders as $key => $value) { | ||
PHPUnit::assertArrayHasKey($key, $actualHeaders); | ||
PHPUnit::assertContains($value, $actualHeaders[$key][0]); | ||
} | ||
} | ||
|
||
|
||
}# |
20 changes: 20 additions & 0 deletions
20
test/Acceptance/HTTPHeaders/test/Acceptance/Features/render.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Feature: Test that HTTP response headers are sent | ||
In order to view static files | ||
As a web browser | ||
I should see the correct headers in the HTTP response | ||
|
||
Scenario: Open homepage | ||
Given I go to the homepage | ||
Then I should see "This is the homepage" | ||
And the response status code should be 200 | ||
And the response headers should include: | ||
| Header name | Header value | | ||
| Content-type | text/html | | ||
|
||
Scenario: View file placed in www | ||
Given I go to "/readme.txt" | ||
Then the response should contain "Read Me" | ||
And the response status code should be 200 | ||
And the response headers should include: | ||
| Header name | Header value | | ||
| Content-type | text/plain | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
default: | ||
paths: | ||
features: Features | ||
bootstrap: %behat.paths.base%/Behat | ||
extensions: | ||
Behat\MinkExtension\Extension: | ||
base_url: http://localhost:8089 | ||
goutte: | ||
guzzle_parameters: | ||
ssl.certificate_authority: false | ||
curl.options: | ||
CURLOPT_PORT: 8089 | ||
SensioLabs\Behat\PageObjectExtension\Extension: ~ | ||
context: | ||
parameters: | ||
screenshot_dir: %behat.paths.base%/Report | ||
filters: | ||
tags: ~@disabled | ||
formatter: | ||
name: pretty | ||
parameters: | ||
output_path: null,%behat.paths.base%/Report/index.html |
2 changes: 2 additions & 0 deletions
2
test/Acceptance/HTTPHeaders/www/Script-174946ee3a5884e83d0eabc1a8e208b5/my-script.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// This is a static JavaScript file. | ||
console.log("Hello!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Read Me | ||
------- | ||
|
||
This is a static file, saved directly in the www directory. |