mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
e2e32317d6
Also rename ViewableData to ModelData ahead of the template layer lift-and-shift
56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\Model\Tests;
|
|
|
|
use SilverStripe\Dev\Constraint\ModelDataContains;
|
|
use SilverStripe\Dev\SapphireTest;
|
|
use SilverStripe\Model\ArrayData;
|
|
use SilverStripe\Model\ModelDataCustomised;
|
|
|
|
/**
|
|
* Test for ModelDataCustomised.
|
|
*/
|
|
class ModelDataCustomisedTest extends SapphireTest
|
|
{
|
|
public function testNestedModelDataCustomisedAsCustomised()
|
|
{
|
|
$outerCustomised = ModelDataCustomised::create($this->makeOuterOriginal(), $this->makeInnerModelDataCustomised());
|
|
$this->assertThat($outerCustomised, $this->makeTestConstraint());
|
|
}
|
|
|
|
public function testNestedModelDataCustomisedAsOriginal()
|
|
{
|
|
$outerCustomised = ModelDataCustomised::create($this->makeInnerModelDataCustomised(), $this->makeOuterOriginal());
|
|
$this->assertThat($outerCustomised, $this->makeTestConstraint());
|
|
}
|
|
|
|
private function makeTestConstraint()
|
|
{
|
|
return new ModelDataContains([
|
|
'outerOriginal' => 'foobar',
|
|
'innerOriginal' => 'hello',
|
|
'innerCustomised' => 'world',
|
|
]);
|
|
}
|
|
|
|
private function makeOuterOriginal()
|
|
{
|
|
return ArrayData::create([
|
|
'outerOriginal' => 'foobar',
|
|
]);
|
|
}
|
|
|
|
private function makeInnerModelDataCustomised()
|
|
{
|
|
$original = ArrayData::create([
|
|
'innerOriginal' => 'hello',
|
|
]);
|
|
|
|
$customised = ArrayData::create([
|
|
'innerCustomised' => 'world',
|
|
]);
|
|
|
|
return ModelDataCustomised::create($original, $customised);
|
|
}
|
|
}
|