MNT Fix unit tests

This commit is contained in:
Guy Sartorelli 2022-09-09 13:38:55 +12:00
parent 47337782a2
commit 5b2820e8ac
No known key found for this signature in database
GPG Key ID: F313E3B9504D496A
2 changed files with 4 additions and 5 deletions

View File

@ -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 // Check if the method to-be-called exists on the target object - if so, don't check any further
// injection locations // injection locations
$on = $this->itemIterator ? $this->itemIterator->current() : $this->item; $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 []; return [];
} }

View File

@ -4,6 +4,7 @@ namespace SilverStripe\View\Tests;
use Exception; use Exception;
use InvalidArgumentException; use InvalidArgumentException;
use LogicException;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Silverstripe\Assets\Dev\TestAssetStore; use Silverstripe\Assets\Dev\TestAssetStore;
use SilverStripe\Control\ContentNegotiator; 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() public function testTooManyUps()
{ {
$this->expectException(LogicException::class);
$this->expectExceptionMessage("Up called when we're already at the top of the scope");
$data = new ArrayData([ $data = new ArrayData([
'Foo' => new ArrayData([ 'Foo' => new ArrayData([
'Name' => 'Foo', 'Name' => 'Foo',