f90e19c3
Andrea Petta
plugin update
|
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
<?php
/**
* Test class for PHPRtfLite.
*/
class PHPRtfLite_TableTest extends PHPUnit_Framework_TestCase
{
/**
* @var PHPRtfLite_Table
*/
private $_table;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
$rtf = new PHPRtfLite;
$this->_table = $rtf->addSection()->addTable();
}
/**
* tests addRows
*/
public function testAddRows()
{
$this->_table->addRows(4);
$this->assertEquals(4, $this->_table->getRowsCount());
return $this->_table;
}
/**
* tests addRowList
* @depends testAddRows
*/
public function testAddRowList(PHPRtfLite_Table $table)
{
$rowHeights = array(2, 5);
$table->addRowList($rowHeights);
$this->assertEquals(6, $table->getRowsCount());
return $table;
}
/**
* tests addRow
* @depends testAddRowList
*/
public function testAddRow(PHPRtfLite_Table $table)
{
$rowHeight = 2.5;
$table->addRow($rowHeight);
$this->assertEquals(7, $table->getRowsCount());
}
/**
* tests if height is set correctly when using addRow
*/
public function testCorrectHeightWhenAddRow()
{
$this->_table->addRow(5.1);
$row = $this->_table->getRow(1);
$this->assertEquals(5.1, $row->getHeight());
}
/**
* tests getRow
* @expectedException PHPRtfLite_Exception
*/
public function testGetRow()
{
$this->_table->getRow(1);
}
public function testAddColumnList()
{
$columnWidths = array(3, 4);
$this->_table->addColumnsList($columnWidths);
$this->assertEquals(2,$this->_table->getColumnsCount());
return $this->_table;
}
/**
* test addColumn
* @depends testAddColumnList
*/
public function testAddColumn(PHPRtfLite_Table $table)
{
$table->addColumn(7);
$this->assertEquals(3, $table->getColumnsCount());
return $table;
}
/**
* tests getColumn
* @depends testAddColumn
*/
public function testGetColumn(PHPRtfLite_Table $table)
{
$this->assertType('PHPRtfLite_Table_Column', $table->getColumn(3));
return $table;
}
/**
* tests getColumn
* @depends testGetColumn
* @expectedException PHPRtfLite_Exception
*/
public function testGetColumnWithInvalidIndex(PHPRtfLite_Table $table)
{
$this->assertType('PHPRtfLite_Table_Column', $table->getColumn(4));
}
/**
* tests getCell
*/
public function testGetCell()
{
$this->_table->addRow(1);
$this->_table->addColumnsList(array(2, 2));
$this->assertType('PHPRtfLite_Table_Cell', $this->_table->getCell(1, 2));
}
/**
* tests getCell
* @expectedException PHPRtfLite_Exception
*/
public function testGetCellWithInvalidIndex()
{
$this->_table->addRow(1);
$this->_table->addColumnsList(array(2, 2));
$this->_table->getCell(1, 3);
}
/**
* tests setVerticalAlignmentForCellRange
*/
public function testSetVerticalAlignmentForCellRange()
{
$this->_table->addRows(3);
$this->_table->addColumnsList(array(5, 5, 5));
$this->_table->setVerticalAlignmentForCellRange(PHPRtfLite_Table_Cell::VERTICAL_ALIGN_BOTTOM, 2, 2, 3, 3);
for ($rowIndex = 2; $rowIndex < 4; $rowIndex++) {
for ($columnIndex = 2; $columnIndex < 4; $columnIndex++) {
$cell = $this->_table->getCell($rowIndex, $columnIndex);
$this->assertEquals(PHPRtfLite_Table_Cell::VERTICAL_ALIGN_BOTTOM, $cell->getVerticalAlignment());
}
}
}
/**
* tests setVerticalAlignmentForCellRange
*/
public function testSetVerticalAlignmentForCell()
{
$this->_table->addRows(3);
$this->_table->addColumnsList(array(5, 5, 5));
$this->_table->setVerticalAlignmentForCellRange(PHPRtfLite_Table_Cell::VERTICAL_ALIGN_CENTER, 2, 2);
$cell = $this->_table->getCell(2, 2);
$this->assertEquals(PHPRtfLite_Table_Cell::VERTICAL_ALIGN_CENTER, $cell->getVerticalAlignment());
}
/**
* tests setTextAlignmentForCellRange
*/
public function testSetTextAlignmentForCellRange()
{
$this->_table->addRows(3);
$this->_table->addColumnsList(array(5, 5, 5));
$this->_table->setTextAlignmentForCellRange(PHPRtfLite_Table_Cell::TEXT_ALIGN_RIGHT, 2, 2, 3, 3);
for ($rowIndex = 2; $rowIndex < 4; $rowIndex++) {
for ($columnIndex = 2; $columnIndex < 4; $columnIndex++) {
$cell = $this->_table->getCell($rowIndex, $columnIndex);
$this->assertEquals(PHPRtfLite_Table_Cell::TEXT_ALIGN_RIGHT, $cell->getTextAlignment());
}
}
}
/**
* tests setTextAlignmentForCellRange
*/
public function testSetTextAlignmentForCell()
{
$this->_table->addRows(3);
$this->_table->addColumnsList(array(5, 5, 5));
$this->_table->setTextAlignmentForCellRange(PHPRtfLite_Table_Cell::TEXT_ALIGN_CENTER, 2, 2);
$cell = $this->_table->getCell(2, 2);
$this->assertEquals(PHPRtfLite_Table_Cell::TEXT_ALIGN_CENTER, $cell->getTextAlignment());
}
/**
* tests setFontForCellRange
*/
public function testSetFontForCellRange()
{
$font = new PHPRtfLite_Font(2, 'Arial', '#F33', '#ff0');
$this->_table->addRows(3);
$this->_table->addColumnsList(array(5, 5, 5));
$this->_table->setFontForCellRange($font, 2, 2, 3, 3);
for ($rowIndex = 2; $rowIndex < 4; $rowIndex++) {
for ($columnIndex = 2; $columnIndex < 4; $columnIndex++) {
$cell = $this->_table->getCell($rowIndex, $columnIndex);
$this->assertEquals($font, $cell->getFont());
}
}
}
/**
* tests setFontForCellRange
*/
public function testSetFontForCell()
{
$font = new PHPRtfLite_Font(2, 'Arial', '#F33', '#ff0');
$this->_table->addRows(3);
$this->_table->addColumnsList(array(5, 5, 5));
$this->_table->setFontForCellRange($font, 2, 2);
$cell = $this->_table->getCell(2, 2);
$this->assertEquals($font, $cell->getFont());
}
/**
* tests rotateCellRange
*/
public function testRotateCellRange()
{
$rotateTo = PHPRtfLite_Table_Cell::ROTATE_RIGHT;
$this->_table->addRows(3);
$this->_table->addColumnsList(array(5, 5, 5));
$this->_table->rotateCellRange($rotateTo, 2, 2, 3, 3);
for ($rowIndex = 2; $rowIndex < 4; $rowIndex++) {
for ($columnIndex = 2; $columnIndex < 4; $columnIndex++) {
$cell = $this->_table->getCell($rowIndex, $columnIndex);
$this->assertEquals($rotateTo, $cell->getRotateTo());
}
}
}
/**
* tests setBackgroundForCellRange
*/
public function testSetBackgroundForCellRange()
{
$backgroundColor = '#00F';
$this->_table->addRows(3);
$this->_table->addColumnsList(array(5, 5, 5));
$this->_table->setBackgroundForCellRange($backgroundColor, 1, 1, 2, 2);
for ($rowIndex = 1; $rowIndex <= 2; $rowIndex++) {
for ($columnIndex = 1; $columnIndex <= 2; $columnIndex++) {
$cell = $this->_table->getCell($rowIndex, $columnIndex);
$this->assertEquals($backgroundColor, $cell->getBackgroundColor());
}
}
}
/**
* tests checkIfCellExists
*/
public function testCheckIfCellExistsStartIndex()
{
$this->_table->addRows(3);
$this->_table->addColumnsList(array(5, 5, 5, 4));
$this->assertTrue($this->_table->checkIfCellExists(1, 1));
return $this->_table;
}
/**
* tests checkIfCellExists
* @depends testCheckIfCellExistsStartIndex
*/
public function testCheckIfCellExistsEndIndex(PHPRtfLite_Table $table)
{
$this->assertTrue($table->checkIfCellExists(3, 4));
}
/**
* tests checkIfCellExists
* @depends testCheckIfCellExistsStartIndex
*/
public function testCheckIfCellExistsOutOfIndex(PHPRtfLite_Table $table)
{
$this->assertFalse($table->checkIfCellExists(4, 4));
}
/**
* @todo Implement testSetBorderForCellRange().
*/
public function testSetBorderForCellRange()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testMergeCellRange().
*/
public function testMergeCellRange()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
|