1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SilverStripe\View\Tests; |
4
|
|
|
|
5
|
|
|
use SilverStripe\Dev\Constraint\ViewableDataContains; |
6
|
|
|
use SilverStripe\Dev\SapphireTest; |
7
|
|
|
use SilverStripe\View\ArrayData; |
8
|
|
|
use SilverStripe\View\ViewableData_Customised; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Test for ViewableData_Customised. |
12
|
|
|
*/ |
13
|
|
|
class ViewableDataCustomisedTest extends SapphireTest |
14
|
|
|
{ |
15
|
|
|
public function testNestedViewableDataCustomisedAsCustomised() |
16
|
|
|
{ |
17
|
|
|
$outerCustomised = ViewableData_Customised::create($this->makeOuterOriginal(), $this->makeInnerViewableDataCustomised()); |
18
|
|
|
$this->assertThat($outerCustomised, $this->makeTestConstraint()); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testNestedViewableDataCustomisedAsOriginal() |
22
|
|
|
{ |
23
|
|
|
$outerCustomised = ViewableData_Customised::create($this->makeInnerViewableDataCustomised(), $this->makeOuterOriginal()); |
24
|
|
|
$this->assertThat($outerCustomised, $this->makeTestConstraint()); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
private function makeTestConstraint() |
28
|
|
|
{ |
29
|
|
|
return new ViewableDataContains([ |
30
|
|
|
'outerOriginal' => 'foobar', |
31
|
|
|
'innerOriginal' => 'hello', |
32
|
|
|
'innerCustomised' => 'world', |
33
|
|
|
]); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
private function makeOuterOriginal() |
37
|
|
|
{ |
38
|
|
|
return ArrayData::create([ |
39
|
|
|
'outerOriginal' => 'foobar', |
40
|
|
|
]); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
private function makeInnerViewableDataCustomised() |
44
|
|
|
{ |
45
|
|
|
$original = ArrayData::create([ |
46
|
|
|
'innerOriginal' => 'hello', |
47
|
|
|
]); |
48
|
|
|
|
49
|
|
|
$customised = ArrayData::create([ |
50
|
|
|
'innerCustomised' => 'world', |
51
|
|
|
]); |
52
|
|
|
|
53
|
|
|
return ViewableData_Customised::create($original, $customised); |
54
|
|
|
} |
55
|
|
|
} |
56
|
|
|
|