Failed Conditions
Push — master ( 89aa7e...49f87d )
by Adrien
09:57
created

LegendTest::testSetInvalidXLPositionReturnsFalse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheetTests\Chart;
4
5
use PhpOffice\PhpSpreadsheet\Chart\Legend;
6
use PHPUnit\Framework\TestCase;
7
8
class LegendTest extends TestCase
9
{
10
    public function testSetPosition(): void
11
    {
12
        $positionValues = [
13
            Legend::POSITION_RIGHT,
14
            Legend::POSITION_LEFT,
15
            Legend::POSITION_TOP,
16
            Legend::POSITION_BOTTOM,
17
            Legend::POSITION_TOPRIGHT,
18
        ];
19
20
        $testInstance = new Legend();
21
22
        foreach ($positionValues as $positionValue) {
23
            $result = $testInstance->setPosition($positionValue);
24
            self::assertTrue($result);
25
        }
26
    }
27
28
    public function testSetInvalidPositionReturnsFalse(): void
29
    {
30
        $testInstance = new Legend();
31
32
        $result = $testInstance->setPosition('BottomLeft');
33
        self::assertFalse($result);
34
        //    Ensure that value is unchanged
35
        $result = $testInstance->getPosition();
36
        self::assertEquals(Legend::POSITION_RIGHT, $result);
37
    }
38
39
    public function testGetPosition(): void
40
    {
41
        $PositionValue = Legend::POSITION_BOTTOM;
42
43
        $testInstance = new Legend();
44
        $testInstance->setPosition($PositionValue);
45
46
        $result = $testInstance->getPosition();
47
        self::assertEquals($PositionValue, $result);
48
    }
49
50
    public function testSetPositionXL(): void
51
    {
52
        $positionValues = [
53
            Legend::XL_LEGEND_POSITION_BOTTOM,
54
            Legend::XL_LEGEND_POSITION_CORNER,
55
            Legend::XL_LEGEND_POSITION_CUSTOM,
56
            Legend::XL_LEGEND_POSITION_LEFT,
57
            Legend::XL_LEGEND_POSITION_RIGHT,
58
            Legend::XL_LEGEND_POSITION_TOP,
59
        ];
60
61
        $testInstance = new Legend();
62
63
        foreach ($positionValues as $positionValue) {
64
            $result = $testInstance->setPositionXL($positionValue);
65
            self::assertTrue($result);
66
        }
67
    }
68
69
    public function testSetInvalidXLPositionReturnsFalse(): void
70
    {
71
        $testInstance = new Legend();
72
73
        $result = $testInstance->setPositionXL(999);
74
        self::assertFalse($result);
75
        //    Ensure that value is unchanged
76
        $result = $testInstance->getPositionXL();
77
        self::assertEquals(Legend::XL_LEGEND_POSITION_RIGHT, $result);
78
    }
79
80
    public function testGetPositionXL(): void
81
    {
82
        $PositionValue = Legend::XL_LEGEND_POSITION_CORNER;
83
84
        $testInstance = new Legend();
85
        $testInstance->setPositionXL($PositionValue);
86
87
        $result = $testInstance->getPositionXL();
88
        self::assertEquals($PositionValue, $result);
89
    }
90
91
    public function testSetOverlay(): void
92
    {
93
        $overlayValues = [
94
            true,
95
            false,
96
        ];
97
98
        $testInstance = new Legend();
99
100
        foreach ($overlayValues as $overlayValue) {
101
            $testInstance->setOverlay($overlayValue);
102
            self::assertSame($overlayValue, $testInstance->getOverlay());
103
        }
104
    }
105
106
    public function testGetOverlay(): void
107
    {
108
        $OverlayValue = true;
109
110
        $testInstance = new Legend();
111
        $testInstance->setOverlay($OverlayValue);
112
113
        $result = $testInstance->getOverlay();
114
        self::assertEquals($OverlayValue, $result);
115
    }
116
}
117