From 5b2820e8ace6376a935173d243ed7823504a4eef Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Fri, 9 Sep 2022 13:38:55 +1200 Subject: [PATCH] MNT Fix unit tests --- src/View/SSViewer_DataPresenter.php | 2 +- tests/php/View/SSViewerTest.php | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/View/SSViewer_DataPresenter.php b/src/View/SSViewer_DataPresenter.php index 6cbb4fbb1..b808773a3 100644 --- a/src/View/SSViewer_DataPresenter.php +++ b/src/View/SSViewer_DataPresenter.php @@ -377,7 +377,7 @@ class SSViewer_DataPresenter extends SSViewer_Scope // Check if the method to-be-called exists on the target object - if so, don't check any further // injection locations $on = $this->itemIterator ? $this->itemIterator->current() : $this->item; - if (isset($on->$property) || method_exists($on, $property ?? '')) { + if ($on !== null && (isset($on->$property) || method_exists($on, $property ?? ''))) { return []; } diff --git a/tests/php/View/SSViewerTest.php b/tests/php/View/SSViewerTest.php index b3e701bd7..f30fee6da 100644 --- a/tests/php/View/SSViewerTest.php +++ b/tests/php/View/SSViewerTest.php @@ -4,6 +4,7 @@ namespace SilverStripe\View\Tests; use Exception; use InvalidArgumentException; +use LogicException; use PHPUnit\Framework\MockObject\MockObject; use Silverstripe\Assets\Dev\TestAssetStore; use SilverStripe\Control\ContentNegotiator; @@ -1557,12 +1558,10 @@ after' ); } - /** - * @expectedException \LogicException - * @expectedExceptionMessage Up called when we're already at the top of the scope - */ public function testTooManyUps() { + $this->expectException(LogicException::class); + $this->expectExceptionMessage("Up called when we're already at the top of the scope"); $data = new ArrayData([ 'Foo' => new ArrayData([ 'Name' => 'Foo',