From bcdc2d0db8646190f64973e24cb83294d0bf592b Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Thu, 8 Jun 2023 13:43:17 +1200 Subject: [PATCH] fix: holder not being used --- .github/workflows/ci.yml | 11 +++++++++++ .gitignore | 1 + readme.md | 3 +-- src/Control/ElementVirtualLinkedController.php | 11 ----------- .../Layout/ElementHolder_VirtualLinked.ss | 5 +++++ templates/ElementalHolder_VirtualLinked.ss | 3 --- tests/php/BaseElementExtensionTest.php | 14 ++++++++++++++ 7 files changed, 32 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 templates/DNADesign/Elemental/Layout/ElementHolder_VirtualLinked.ss delete mode 100644 templates/ElementalHolder_VirtualLinked.ss diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bf02210 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,11 @@ +name: CI + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + ci: + name: CI + uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 diff --git a/.gitignore b/.gitignore index a056789..4cdc44a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.lock /resources/ .phpunit.result.cache +/assets diff --git a/readme.md b/readme.md index 2829197..a4bbc50 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,5 @@ # SilverStripe Elemental Virtual -[![Build Status](http://img.shields.io/travis/dnadesign/silverstripe-elemental-virtual.svg?style=flat)](https://travis-ci.org/dnadesign/silverstripe-elemental-virtual) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/dnadesign/silverstripe-elemental-virtual/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/dnadesign/silverstripe-elemental-virtual/?branch=master) [![codecov](https://codecov.io/gh/dnadesign/silverstripe-elemental-virtual/branch/master/graph/badge.svg)](https://codecov.io/gh/dnadesign/silverstripe-elemental-virtual) [![Version](http://img.shields.io/packagist/v/dnadesign/silverstripe-elemental-virtual.svg?style=flat)](https://packagist.org/packages/dnadesign/silverstripe-elemental-virtual) @@ -14,5 +13,5 @@ linked to multiple pages. ## Installation ``` -composer require dnadesign/silverstripe-elemental-virtual 1.x-dev +composer require dnadesign/silverstripe-elemental-virtual ^1 ``` diff --git a/src/Control/ElementVirtualLinkedController.php b/src/Control/ElementVirtualLinkedController.php index aeb2d1f..b45bab0 100644 --- a/src/Control/ElementVirtualLinkedController.php +++ b/src/Control/ElementVirtualLinkedController.php @@ -7,17 +7,6 @@ class ElementVirtualLinkedController extends ElementController { - - /** - * Returns the current element in scope rendered into its' holder - * - * @return HTML - */ - public function ElementHolder() - { - return $this->renderWith('ElementHolder_VirtualLinked'); - } - /** * @param string $action * diff --git a/templates/DNADesign/Elemental/Layout/ElementHolder_VirtualLinked.ss b/templates/DNADesign/Elemental/Layout/ElementHolder_VirtualLinked.ss new file mode 100644 index 0000000..4339cf3 --- /dev/null +++ b/templates/DNADesign/Elemental/Layout/ElementHolder_VirtualLinked.ss @@ -0,0 +1,5 @@ +<% if $LinkedElement %> +
+ $Element +
+<% end_if %> diff --git a/templates/ElementalHolder_VirtualLinked.ss b/templates/ElementalHolder_VirtualLinked.ss deleted file mode 100644 index f65f7e6..0000000 --- a/templates/ElementalHolder_VirtualLinked.ss +++ /dev/null @@ -1,3 +0,0 @@ -
- $Element -
diff --git a/tests/php/BaseElementExtensionTest.php b/tests/php/BaseElementExtensionTest.php index 18fff73..a60358b 100644 --- a/tests/php/BaseElementExtensionTest.php +++ b/tests/php/BaseElementExtensionTest.php @@ -6,6 +6,7 @@ use DNADesign\Elemental\Models\ElementalArea; use DNADesign\Elemental\Tests\Src\TestElement; use DNADesign\Elemental\Tests\Src\TestPage; +use DNADesign\ElementalVirtual\Control\ElementVirtualLinkedController; use DNADesign\ElementalVirtual\Model\ElementVirtual; use SilverStripe\Core\Config\Config; use SilverStripe\Dev\SapphireTest; @@ -39,6 +40,19 @@ public function testVirtualElementAnchor() $this->assertEquals('e' . $linked->ID, $element->getAnchor()); } + + public function testRendersIntoHolder() + { + $element = $this->objFromFixture(ElementVirtual::class, 'virtual1'); + $linked = $this->objFromFixture(TestElement::class, 'element1'); + + $controller = ElementVirtualLinkedController::create($element); + + $template = $controller->forTemplate(); + + $this->assertStringContainsString('element--test-element', $template); + } + public function testUpdateCmsFields() { $linked = $this->objFromFixture(TestElement::class, 'element1');