Merge branch '4.2' into 4

This commit is contained in:
Aaron Carlino 2018-10-15 13:42:55 +13:00
commit 7d201309ad
2 changed files with 60 additions and 0 deletions

View File

@ -49,6 +49,11 @@ class ViewableData_Customised extends ViewableData
$this->customised->$property = $this->original->$property = $value;
}
public function __isset($property)
{
return isset($this->customised->$property) || isset($this->original->$property) || parent::__isset($property);
}
public function hasMethod($method)
{
return $this->customised->hasMethod($method) || $this->original->hasMethod($method);

View File

@ -0,0 +1,55 @@
<?php
namespace SilverStripe\View\Tests;
use SilverStripe\Dev\Constraint\ViewableDataContains;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\View\ArrayData;
use SilverStripe\View\ViewableData_Customised;
/**
* Test for ViewableData_Customised.
*/
class ViewableDataCustomisedTest extends SapphireTest
{
public function testNestedViewableDataCustomisedAsCustomised()
{
$outerCustomised = ViewableData_Customised::create($this->makeOuterOriginal(), $this->makeInnerViewableDataCustomised());
$this->assertThat($outerCustomised, $this->makeTestConstraint());
}
public function testNestedViewableDataCustomisedAsOriginal()
{
$outerCustomised = ViewableData_Customised::create($this->makeInnerViewableDataCustomised(), $this->makeOuterOriginal());
$this->assertThat($outerCustomised, $this->makeTestConstraint());
}
private function makeTestConstraint()
{
return new ViewableDataContains([
'outerOriginal' => 'foobar',
'innerOriginal' => 'hello',
'innerCustomised' => 'world',
]);
}
private function makeOuterOriginal()
{
return ArrayData::create([
'outerOriginal' => 'foobar',
]);
}
private function makeInnerViewableDataCustomised()
{
$original = ArrayData::create([
'innerOriginal' => 'hello',
]);
$customised = ArrayData::create([
'innerCustomised' => 'world',
]);
return ViewableData_Customised::create($original, $customised);
}
}