Passed
Push — 4.2 ( 598e93...7915fe )
by Sam
06:52
created

ViewableDataCustomisedTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A makeInnerViewableDataCustomised() 0 11 1
A makeTestConstraint() 0 6 1
A makeOuterOriginal() 0 4 1
A testNestedViewableDataCustomisedAsCustomised() 0 4 1
A testNestedViewableDataCustomisedAsOriginal() 0 4 1
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