diff --git a/tests/fixtures/views/inheritance_child.html b/tests/fixtures/views/inheritance_child.html new file mode 100644 index 0000000..eb5a3db --- /dev/null +++ b/tests/fixtures/views/inheritance_child.html @@ -0,0 +1,3 @@ +extend('inheritance_parent.html') ?> +sectionStart('head') ?>DocumentsectionEnd() ?> +sectionStart('body') ?>
sectionEnd() ?> diff --git a/tests/fixtures/views/inheritance_parent.html b/tests/fixtures/views/inheritance_parent.html new file mode 100644 index 0000000..d921f8f --- /dev/null +++ b/tests/fixtures/views/inheritance_parent.html @@ -0,0 +1,13 @@ + + +sectionStart('head') ?> +sectionEnd() ?> + + +sectionStart('body') ?> +sectionEnd() ?> + + +sectionStart('extra') ?> + +sectionEnd() ?> diff --git a/tests/unit/ViewTest.php b/tests/unit/ViewTest.php index 97c038c..2b87d76 100644 --- a/tests/unit/ViewTest.php +++ b/tests/unit/ViewTest.php @@ -27,4 +27,12 @@ public function prettyName($name) $this->assertEquals("Hello, Mr Alex.\n", $view->get('hello2.html', [ 'name' => 'Alex' ])); } + + public function testInheritance(): void + { + $view = new \Aurora\System\View(dirname(__DIR__) . '/fixtures/views'); + + $this->assertEquals("\n\nDocument\n\n
Lorem ipsum
\n\n\n", + $view->get('inheritance_child.html', [ 'message' => 'Lorem ipsum' ])); + } }