From cbc19e5c75e01562153df30406d176a3cb82c416 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Mon, 18 Aug 2014 12:56:24 +0100 Subject: [PATCH] Test header-footer overriding --- src/Dispatcher/PageDispatcher.php | 8 ++++-- .../HeaderFooter/src/Page/View/_footer.html | 6 ++++ .../HeaderFooter/src/Page/View/_header.html | 10 +++++++ .../src/Page/View/another-page.html | 4 +++ .../directory-with-own-header/_header.html | 10 +++++++ .../View/directory-with-own-header/index.html | 4 +++ .../index.html | 4 +++ .../HeaderFooter/src/Page/View/index.html | 4 +++ .../test/Acceptance/Behat/FeatureContext.php | 5 ++++ .../test/Acceptance/Features/render.feature | 28 +++++++++++++++++++ .../HeaderFooter/test/Acceptance/behat.yml | 22 +++++++++++++++ 11 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 test/Acceptance/HeaderFooter/src/Page/View/_footer.html create mode 100644 test/Acceptance/HeaderFooter/src/Page/View/_header.html create mode 100644 test/Acceptance/HeaderFooter/src/Page/View/another-page.html create mode 100644 test/Acceptance/HeaderFooter/src/Page/View/directory-with-own-header/_header.html create mode 100644 test/Acceptance/HeaderFooter/src/Page/View/directory-with-own-header/index.html create mode 100644 test/Acceptance/HeaderFooter/src/Page/View/directory-with-shared-header-footer/index.html create mode 100644 test/Acceptance/HeaderFooter/src/Page/View/index.html create mode 100644 test/Acceptance/HeaderFooter/test/Acceptance/Behat/FeatureContext.php create mode 100644 test/Acceptance/HeaderFooter/test/Acceptance/Features/render.feature create mode 100644 test/Acceptance/HeaderFooter/test/Acceptance/behat.yml diff --git a/src/Dispatcher/PageDispatcher.php b/src/Dispatcher/PageDispatcher.php index f7774e6b..7802e2e5 100644 --- a/src/Dispatcher/PageDispatcher.php +++ b/src/Dispatcher/PageDispatcher.php @@ -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; } } diff --git a/test/Acceptance/HeaderFooter/src/Page/View/_footer.html b/test/Acceptance/HeaderFooter/src/Page/View/_footer.html new file mode 100644 index 00000000..cfa90e50 --- /dev/null +++ b/test/Acceptance/HeaderFooter/src/Page/View/_footer.html @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/test/Acceptance/HeaderFooter/src/Page/View/_header.html b/test/Acceptance/HeaderFooter/src/Page/View/_header.html new file mode 100644 index 00000000..d5ffab6f --- /dev/null +++ b/test/Acceptance/HeaderFooter/src/Page/View/_header.html @@ -0,0 +1,10 @@ + + + + + Test Website + + +
+

Test Website (base header)

+
\ No newline at end of file diff --git a/test/Acceptance/HeaderFooter/src/Page/View/another-page.html b/test/Acceptance/HeaderFooter/src/Page/View/another-page.html new file mode 100644 index 00000000..5b0697ef --- /dev/null +++ b/test/Acceptance/HeaderFooter/src/Page/View/another-page.html @@ -0,0 +1,4 @@ +
+

Another page

+

Look. Another page!

+
\ No newline at end of file diff --git a/test/Acceptance/HeaderFooter/src/Page/View/directory-with-own-header/_header.html b/test/Acceptance/HeaderFooter/src/Page/View/directory-with-own-header/_header.html new file mode 100644 index 00000000..87afa386 --- /dev/null +++ b/test/Acceptance/HeaderFooter/src/Page/View/directory-with-own-header/_header.html @@ -0,0 +1,10 @@ + + + + + Test Website + + +
+

Test Website (overridden header)

+
\ No newline at end of file diff --git a/test/Acceptance/HeaderFooter/src/Page/View/directory-with-own-header/index.html b/test/Acceptance/HeaderFooter/src/Page/View/directory-with-own-header/index.html new file mode 100644 index 00000000..257efe9a --- /dev/null +++ b/test/Acceptance/HeaderFooter/src/Page/View/directory-with-own-header/index.html @@ -0,0 +1,4 @@ +
+

Non-shared nested page

+

This page should have its own header.

+
\ No newline at end of file diff --git a/test/Acceptance/HeaderFooter/src/Page/View/directory-with-shared-header-footer/index.html b/test/Acceptance/HeaderFooter/src/Page/View/directory-with-shared-header-footer/index.html new file mode 100644 index 00000000..1cf961ae --- /dev/null +++ b/test/Acceptance/HeaderFooter/src/Page/View/directory-with-shared-header-footer/index.html @@ -0,0 +1,4 @@ +
+

Nested page

+

Look. A nested page!

+
\ No newline at end of file diff --git a/test/Acceptance/HeaderFooter/src/Page/View/index.html b/test/Acceptance/HeaderFooter/src/Page/View/index.html new file mode 100644 index 00000000..ebbcdc6e --- /dev/null +++ b/test/Acceptance/HeaderFooter/src/Page/View/index.html @@ -0,0 +1,4 @@ +
+

Homepage

+

Look. The homepage!

+
\ No newline at end of file diff --git a/test/Acceptance/HeaderFooter/test/Acceptance/Behat/FeatureContext.php b/test/Acceptance/HeaderFooter/test/Acceptance/Behat/FeatureContext.php new file mode 100644 index 00000000..e104abdc --- /dev/null +++ b/test/Acceptance/HeaderFooter/test/Acceptance/Behat/FeatureContext.php @@ -0,0 +1,5 @@ +