-
Notifications
You must be signed in to change notification settings - Fork 2.7k
/
Copy pathChartTest.php
192 lines (149 loc) · 4.97 KB
/
ChartTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
/**
* This file is part of PHPWord - A pure PHP library for reading and writing
* word processing documents.
*
* PHPWord is free software distributed under the terms of the GNU Lesser
* General Public License version 3 as published by the Free Software Foundation.
*
* For the full copyright and license information, please read the LICENSE
* file that was distributed with this source code. For the full list of
* contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
*
* @see https://github.com/PHPOffice/PHPWord
*
* @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
*/
namespace PhpOffice\PhpWordTests\Style;
use PhpOffice\PhpWord\Style\Chart;
/**
* Test class for PhpOffice\PhpWord\Style\Chart.
*
* @coversDefaultClass \PhpOffice\PhpWord\Style\Chart
*
* @runTestsInSeparateProcesses
*/
class ChartTest extends \PHPUnit\Framework\TestCase
{
/**
* Testing getter and setter for chart width.
*/
public function testSetGetWidth(): void
{
$chart = new Chart();
self::assertEquals($chart->getWidth(), 1000000);
$chart->setWidth(200);
self::assertEquals($chart->getWidth(), 200);
}
/**
* Testing getter and setter for chart height.
*/
public function testSetGetHeight(): void
{
$chart = new Chart();
self::assertEquals($chart->getHeight(), 1000000);
$chart->setHeight(200);
self::assertEquals($chart->getHeight(), 200);
}
/**
* Testing getter and setter for is3d.
*/
public function testSetIs3d(): void
{
$chart = new Chart();
self::assertEquals($chart->is3d(), false);
$chart->set3d(true);
self::assertEquals($chart->is3d(), true);
}
/**
* Testing getter and setter for chart colors.
*/
public function testSetGetColors(): void
{
$chart = new Chart();
self::assertIsArray($chart->getColors());
self::assertEquals(count($chart->getColors()), 0);
$chart->setColors(['FFFFFFFF', 'FF000000', 'FFFF0000']);
self::assertEquals($chart->getColors(), ['FFFFFFFF', 'FF000000', 'FFFF0000']);
}
/**
* Testing getter and setter for dataLabelOptions.
*/
public function testSetGetDataLabelOptions(): void
{
$chart = new Chart();
$originalDataLabelOptions = [
'showVal' => true,
'showCatName' => true,
'showLegendKey' => false,
'showSerName' => false,
'showPercent' => false,
'showLeaderLines' => false,
'showBubbleSize' => false,
];
self::assertEquals($chart->getDataLabelOptions(), $originalDataLabelOptions);
$changedDataLabelOptions = [
'showVal' => false,
'showCatName' => false,
'showLegendKey' => true,
'showSerName' => true,
'showPercent' => true,
'showLeaderLines' => true,
'showBubbleSize' => true,
];
$chart->setDataLabelOptions(
[
'showVal' => false,
'showCatName' => false,
'showLegendKey' => true,
'showSerName' => true,
'showPercent' => true,
'showLeaderLines' => true,
'showBubbleSize' => true,
]
);
self::assertEquals($chart->getDataLabelOptions(), $changedDataLabelOptions);
}
/**
* Testing categoryLabelPosition getter and setter.
*/
public function testSetGetCategoryLabelPosition(): void
{
$chart = new Chart();
self::assertEquals($chart->getCategoryLabelPosition(), 'nextTo');
$chart->setCategoryLabelPosition('high');
self::assertEquals($chart->getCategoryLabelPosition(), 'high');
}
/**
* Testing valueLabelPosition getter and setter.
*/
public function testSetGetValueLabelPosition(): void
{
$chart = new Chart();
self::assertEquals($chart->getValueLabelPosition(), 'nextTo');
$chart->setValueLabelPosition('low');
self::assertEquals($chart->getValueLabelPosition(), 'low');
}
/**
* Testing categoryAxisTitle getter and setter.
*/
public function testSetGetCategoryAxisTitle(): void
{
$chart = new Chart();
$chart->getCategoryAxisTitle();
self::assertEquals($chart->getCategoryAxisTitle(), null);
$chart->setCategoryAxisTitle('Test Category Axis Title');
self::assertEquals($chart->getCategoryAxisTitle(), 'Test Category Axis Title');
}
/**
* Testing valueAxisTitle getter and setter.
*/
public function testSetGetValueAxisTitle(): void
{
$chart = new Chart();
$chart->getValueAxisTitle();
self::assertEquals($chart->getValueAxisTitle(), null);
$chart->setValueAxisTitle('Test Value Axis Title');
self::assertEquals($chart->getValueAxisTitle(), 'Test Value Axis Title');
}
}