Skip to content

Commit

Permalink
Test header-footer overriding
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Aug 18, 2014
1 parent e833f30 commit cbc19e5
Show file tree
Hide file tree
Showing 11 changed files with 103 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Dispatcher/PageDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ public function loadSource($path, $pathFile) {

switch($specialName) {
case "header":
$headerSource = file_get_contents($fullPath);
if(empty($headerSource)) {
$headerSource = file_get_contents($fullPath);
}
break;

case "footer":
$footerSource = file_get_contents($fullPath);
if(empty($footerSource)) {
$footerSource = file_get_contents($fullPath);
}
break;
}
}
Expand Down
6 changes: 6 additions & 0 deletions test/Acceptance/HeaderFooter/src/Page/View/_footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<footer>
<p>This is the footer</p>
</footer>

</body>
</html>
10 changes: 10 additions & 0 deletions test/Acceptance/HeaderFooter/src/Page/View/_header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Test Website</title>
</head>
<body>
<header>
<h1>Test Website (base header)</h1>
</header>
4 changes: 4 additions & 0 deletions test/Acceptance/HeaderFooter/src/Page/View/another-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<main>
<h1>Another page</h1>
<p>Look. Another page!</p>
</main>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>Test Website</title>
</head>
<body>
<header>
<h1>Test Website (overridden header)</h1>
</header>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<main>
<h1>Non-shared nested page</h1>
<p>This page should have its own header.</p>
</main>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<main>
<h1>Nested page</h1>
<p>Look. A nested page!</p>
</main>
4 changes: 4 additions & 0 deletions test/Acceptance/HeaderFooter/src/Page/View/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<main>
<h1>Homepage</h1>
<p>Look. The homepage!</p>
</main>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?php
use Behat\MinkExtension\Context\MinkContext;

class FeatureContext extends MinkContext {
}#
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Feature: Test that HTML headers and footers are included
In order to re-use common HTML
As a developer
I should be able to share HTML prefix and suffix files

Scenario: Open homepage
Given I go to the homepage
Then I should see "Look. The homepage!"
And I should see "Test Website (base header)"
And I should see "This is the footer"

Scenario: Open another page
Given I go to "another-page"
Then I should see "Look. Another page!"
And I should see "Test Website (base header)"
And I should see "This is the footer"

Scenario: Open nested page with shared header footer
Given I go to "/directory-with-shared-header-footer"
Then I should see "Look. A nested page!"
And I should see "Test Website (base header)"
And I should see "This is the footer"

Scenario: Open nested page with own footer
Given I go to "/directory-with-own-header"
Then I should see "This page should have its own header"
And I should see "Test Website (overridden header)"
And I should see "This is the footer"
22 changes: 22 additions & 0 deletions test/Acceptance/HeaderFooter/test/Acceptance/behat.yml
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

0 comments on commit cbc19e5

Please sign in to comment.