mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
parent
f01473f1b3
commit
60dd5f288b
@ -49,6 +49,11 @@ class ViewableData_Customised extends ViewableData
|
|||||||
$this->customised->$property = $this->original->$property = $value;
|
$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)
|
public function hasMethod($method)
|
||||||
{
|
{
|
||||||
return $this->customised->hasMethod($method) || $this->original->hasMethod($method);
|
return $this->customised->hasMethod($method) || $this->original->hasMethod($method);
|
||||||
|
55
tests/php/View/ViewableDataCustomisedTest.php
Normal file
55
tests/php/View/ViewableDataCustomisedTest.php
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user