ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
AutoFilterTest Class Reference
+ Inheritance diagram for AutoFilterTest:
+ Collaboration diagram for AutoFilterTest:

Public Member Functions

 setUp ()
 
 testToString ()
 
 testGetParent ()
 
 testSetParent ()
 
 testGetRange ()
 
 testSetRange ()
 
 testClearRange ()
 
 testSetRangeInvalidRange ()
 PHPExcel_Exception More...
 
 testGetColumnsEmpty ()
 
 testGetColumnOffset ()
 
 testGetInvalidColumnOffset ()
 PHPExcel_Exception More...
 
 testSetColumnWithString ()
 
 testSetInvalidColumnWithString ()
 PHPExcel_Exception More...
 
 testSetColumnWithColumnObject ()
 
 testSetInvalidColumnWithObject ()
 PHPExcel_Exception More...
 
 testSetColumnWithInvalidDataType ()
 PHPExcel_Exception More...
 
 testGetColumns ()
 
 testGetColumn ()
 
 testGetColumnByOffset ()
 
 testGetColumnIfNotSet ()
 
 testGetColumnWithoutRangeSet ()
 PHPExcel_Exception More...
 
 testClearRangeWithExistingColumns ()
 
 testSetRangeWithExistingColumns ()
 
 testClone ()
 

Private Attributes

 $_testInitialRange = 'H2:O256'
 
 $_testAutoFilterObject
 

Detailed Description

Definition at line 4 of file AutoFilterTest.php.

Member Function Documentation

◆ setUp()

AutoFilterTest::setUp ( )

Definition at line 11 of file AutoFilterTest.php.

References defined.

12  {
13  if (!defined('PHPEXCEL_ROOT')) {
14  define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
15  }
16  require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
17 
18  $this->_mockWorksheetObject = $this->getMockBuilder('PHPExcel_Worksheet')
19  ->disableOriginalConstructor()
20  ->getMock();
21  $this->_mockCacheController = $this->getMockBuilder('PHPExcel_CachedObjectStorage_Memory')
22  ->disableOriginalConstructor()
23  ->getMock();
24  $this->_mockWorksheetObject->expects($this->any())
25  ->method('getCellCacheController')
26  ->will($this->returnValue($this->_mockCacheController));
27 
28  $this->_testAutoFilterObject = new PHPExcel_Worksheet_AutoFilter(
29  $this->_testInitialRange,
30  $this->_mockWorksheetObject
31  );
32  }
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27

◆ testClearRange()

AutoFilterTest::testClearRange ( )

Definition at line 82 of file AutoFilterTest.php.

References $result.

83  {
84  $expectedResult = '';
85 
86  // Setters return the instance to implement the fluent interface
87  $result = $this->_testAutoFilterObject->setRange();
88  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result);
89 
90  // Result should be a clear range
91  $result = $this->_testAutoFilterObject->getRange();
92  $this->assertEquals($expectedResult, $result);
93  }
$result

◆ testClearRangeWithExistingColumns()

AutoFilterTest::testClearRangeWithExistingColumns ( )

Definition at line 275 of file AutoFilterTest.php.

References $result, and array.

276  {
277  $expectedResult = '';
278 
279  $columnIndexes = array('L','M','N');
280  foreach($columnIndexes as $columnIndex) {
281  $this->_testAutoFilterObject->setColumn($columnIndex);
282  }
283 
284  // Setters return the instance to implement the fluent interface
285  $result = $this->_testAutoFilterObject->setRange();
286  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result);
287 
288  // Range should be cleared
289  $result = $this->_testAutoFilterObject->getRange();
290  $this->assertEquals($expectedResult, $result);
291 
292  // Column array should be cleared
293  $result = $this->_testAutoFilterObject->getColumns();
294  $this->assertInternalType('array', $result);
295  $this->assertEquals(0, count($result));
296  }
$result
Create styles array
The data for the language used.

◆ testClone()

AutoFilterTest::testClone ( )

Definition at line 328 of file AutoFilterTest.php.

References $_testAutoFilterObject, $result, and array.

329  {
330  $columnIndexes = array('L','M');
331 
332  foreach($columnIndexes as $columnIndex) {
333  $this->_testAutoFilterObject->setColumn($columnIndex);
334  }
335 
337  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result);
338  }
$result
Create styles array
The data for the language used.

◆ testGetColumn()

AutoFilterTest::testGetColumn ( )

Definition at line 224 of file AutoFilterTest.php.

References $result, and array.

225  {
226  $columnIndexes = array('L','M');
227 
228  foreach($columnIndexes as $columnIndex) {
229  $this->_testAutoFilterObject->setColumn($columnIndex);
230  }
231 
232  // If we request a specific column by its column ID, we should
233  // get a PHPExcel_Worksheet_AutoFilter_Column object returned
234  foreach($columnIndexes as $columnIndex) {
235  $result = $this->_testAutoFilterObject->getColumn($columnIndex);
236  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result);
237  }
238  }
$result
Create styles array
The data for the language used.

◆ testGetColumnByOffset()

AutoFilterTest::testGetColumnByOffset ( )

Definition at line 240 of file AutoFilterTest.php.

References $result, and array.

241  {
242  $columnIndexes = array( 0 => 'H',
243  3 => 'K',
244  5 => 'M'
245  );
246 
247  // If we request a specific column by its offset, we should
248  // get a PHPExcel_Worksheet_AutoFilter_Column object returned
249  foreach($columnIndexes as $columnIndex => $columnID) {
250  $result = $this->_testAutoFilterObject->getColumnByOffset($columnIndex);
251  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result);
252  $this->assertEquals($result->getColumnIndex(),$columnID);
253  }
254  }
$result
Create styles array
The data for the language used.

◆ testGetColumnIfNotSet()

AutoFilterTest::testGetColumnIfNotSet ( )

Definition at line 256 of file AutoFilterTest.php.

References $result.

257  {
258  // If we request a specific column by its column ID, we should
259  // get a PHPExcel_Worksheet_AutoFilter_Column object returned
260  $result = $this->_testAutoFilterObject->getColumn('K');
261  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result);
262  }
$result

◆ testGetColumnOffset()

AutoFilterTest::testGetColumnOffset ( )

Definition at line 113 of file AutoFilterTest.php.

References $result, and array.

114  {
115  $columnIndexes = array( 'H' => 0,
116  'K' => 3,
117  'M' => 5
118  );
119 
120  // If we request a specific column by its column ID, we should get an
121  // integer returned representing the column offset within the range
122  foreach($columnIndexes as $columnIndex => $columnOffset) {
123  $result = $this->_testAutoFilterObject->getColumnOffset($columnIndex);
124  $this->assertEquals($columnOffset, $result);
125  }
126  }
$result
Create styles array
The data for the language used.

◆ testGetColumns()

AutoFilterTest::testGetColumns ( )

Definition at line 205 of file AutoFilterTest.php.

References $result, and array.

206  {
207  $columnIndexes = array('L','M');
208 
209  foreach($columnIndexes as $columnIndex) {
210  $this->_testAutoFilterObject->setColumn($columnIndex);
211  }
212 
213  $result = $this->_testAutoFilterObject->getColumns();
214  // Result should be an array of PHPExcel_Worksheet_AutoFilter_Column
215  // objects for each column we set indexed by the column ID
216  $this->assertInternalType('array', $result);
217  $this->assertEquals(count($columnIndexes), count($result));
218  foreach($columnIndexes as $columnIndex) {
219  $this->assertArrayHasKey($columnIndex,$result);
220  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result[$columnIndex]);
221  }
222  }
$result
Create styles array
The data for the language used.

◆ testGetColumnsEmpty()

AutoFilterTest::testGetColumnsEmpty ( )

Definition at line 105 of file AutoFilterTest.php.

References $result.

106  {
107  // There should be no columns yet defined
108  $result = $this->_testAutoFilterObject->getColumns();
109  $this->assertInternalType('array', $result);
110  $this->assertEquals(0, count($result));
111  }
$result

◆ testGetColumnWithoutRangeSet()

AutoFilterTest::testGetColumnWithoutRangeSet ( )

PHPExcel_Exception

Definition at line 267 of file AutoFilterTest.php.

References $result.

268  {
269  // Clear the range
270  $result = $this->_testAutoFilterObject->setRange();
271 
272  $result = $this->_testAutoFilterObject->getColumn('A');
273  }
$result

◆ testGetInvalidColumnOffset()

AutoFilterTest::testGetInvalidColumnOffset ( )

PHPExcel_Exception

Definition at line 131 of file AutoFilterTest.php.

References $result.

132  {
133  $invalidColumn = 'G';
134 
135  $result = $this->_testAutoFilterObject->getColumnOffset($invalidColumn);
136  }
$result

◆ testGetParent()

AutoFilterTest::testGetParent ( )

Definition at line 43 of file AutoFilterTest.php.

References $result.

44  {
45  $result = $this->_testAutoFilterObject->getParent();
46  $this->assertInstanceOf('PHPExcel_Worksheet', $result);
47  }
$result

◆ testGetRange()

AutoFilterTest::testGetRange ( )

Definition at line 56 of file AutoFilterTest.php.

References $_testInitialRange, and $result.

57  {
58  $expectedResult = $this->_testInitialRange;
59 
60  // Result should be the active autofilter range
61  $result = $this->_testAutoFilterObject->getRange();
62  $this->assertEquals($expectedResult, $result);
63  }
$result

◆ testSetColumnWithColumnObject()

AutoFilterTest::testSetColumnWithColumnObject ( )

Definition at line 165 of file AutoFilterTest.php.

References $result.

166  {
167  $expectedResult = 'M';
168  $columnObject = new PHPExcel_Worksheet_AutoFilter_Column($expectedResult);
169 
170  // Setters return the instance to implement the fluent interface
171  $result = $this->_testAutoFilterObject->setColumn($columnObject);
172  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result);
173 
174  $result = $this->_testAutoFilterObject->getColumns();
175  // Result should be an array of PHPExcel_Worksheet_AutoFilter_Column
176  // objects for each column we set indexed by the column ID
177  $this->assertInternalType('array', $result);
178  $this->assertEquals(1, count($result));
179  $this->assertArrayHasKey($expectedResult,$result);
180  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result[$expectedResult]);
181  }
$result

◆ testSetColumnWithInvalidDataType()

AutoFilterTest::testSetColumnWithInvalidDataType ( )

PHPExcel_Exception

Definition at line 197 of file AutoFilterTest.php.

References $result.

198  {
199  $invalidColumn = 123.456;
200  $columnObject = new PHPExcel_Worksheet_AutoFilter_Column($invalidColumn);
201 
202  $result = $this->_testAutoFilterObject->setColumn($invalidColumn);
203  }
$result

◆ testSetColumnWithString()

AutoFilterTest::testSetColumnWithString ( )

Definition at line 138 of file AutoFilterTest.php.

References $result.

139  {
140  $expectedResult = 'L';
141 
142  // Setters return the instance to implement the fluent interface
143  $result = $this->_testAutoFilterObject->setColumn($expectedResult);
144  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result);
145 
146  $result = $this->_testAutoFilterObject->getColumns();
147  // Result should be an array of PHPExcel_Worksheet_AutoFilter_Column
148  // objects for each column we set indexed by the column ID
149  $this->assertInternalType('array', $result);
150  $this->assertEquals(1, count($result));
151  $this->assertArrayHasKey($expectedResult,$result);
152  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter_Column', $result[$expectedResult]);
153  }
$result

◆ testSetInvalidColumnWithObject()

AutoFilterTest::testSetInvalidColumnWithObject ( )

PHPExcel_Exception

Definition at line 186 of file AutoFilterTest.php.

References $result.

187  {
188  $invalidColumn = 'E';
189  $columnObject = new PHPExcel_Worksheet_AutoFilter_Column($invalidColumn);
190 
191  $result = $this->_testAutoFilterObject->setColumn($invalidColumn);
192  }
$result

◆ testSetInvalidColumnWithString()

AutoFilterTest::testSetInvalidColumnWithString ( )

PHPExcel_Exception

Definition at line 158 of file AutoFilterTest.php.

References $result.

159  {
160  $invalidColumn = 'A';
161 
162  $result = $this->_testAutoFilterObject->setColumn($invalidColumn);
163  }
$result

◆ testSetParent()

AutoFilterTest::testSetParent ( )

Definition at line 49 of file AutoFilterTest.php.

References $result.

50  {
51  // Setters return the instance to implement the fluent interface
52  $result = $this->_testAutoFilterObject->setParent($this->_mockWorksheetObject);
53  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result);
54  }
$result

◆ testSetRange()

AutoFilterTest::testSetRange ( )

Definition at line 65 of file AutoFilterTest.php.

References $result, and array.

66  {
67  $ranges = array('G1:J512' => 'Worksheet1!G1:J512',
68  'K1:N20' => 'K1:N20'
69  );
70 
71  foreach($ranges as $actualRange => $fullRange) {
72  // Setters return the instance to implement the fluent interface
73  $result = $this->_testAutoFilterObject->setRange($fullRange);
74  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result);
75 
76  // Result should be the new autofilter range
77  $result = $this->_testAutoFilterObject->getRange();
78  $this->assertEquals($actualRange, $result);
79  }
80  }
$result
Create styles array
The data for the language used.

◆ testSetRangeInvalidRange()

AutoFilterTest::testSetRangeInvalidRange ( )

PHPExcel_Exception

Definition at line 98 of file AutoFilterTest.php.

References $result.

99  {
100  $expectedResult = 'A1';
101 
102  $result = $this->_testAutoFilterObject->setRange($expectedResult);
103  }
$result

◆ testSetRangeWithExistingColumns()

AutoFilterTest::testSetRangeWithExistingColumns ( )

Definition at line 298 of file AutoFilterTest.php.

References $result, and array.

299  {
300  $expectedResult = 'G1:J512';
301 
302  // These columns should be retained
303  $columnIndexes1 = array('I','J');
304  foreach($columnIndexes1 as $columnIndex) {
305  $this->_testAutoFilterObject->setColumn($columnIndex);
306  }
307  // These columns should be discarded
308  $columnIndexes2 = array('K','L','M');
309  foreach($columnIndexes2 as $columnIndex) {
310  $this->_testAutoFilterObject->setColumn($columnIndex);
311  }
312 
313  // Setters return the instance to implement the fluent interface
314  $result = $this->_testAutoFilterObject->setRange($expectedResult);
315  $this->assertInstanceOf('PHPExcel_Worksheet_AutoFilter', $result);
316 
317  // Range should be correctly set
318  $result = $this->_testAutoFilterObject->getRange();
319  $this->assertEquals($expectedResult, $result);
320 
321  // Only columns that existed in the original range and that
322  // still fall within the new range should be retained
323  $result = $this->_testAutoFilterObject->getColumns();
324  $this->assertInternalType('array', $result);
325  $this->assertEquals(count($columnIndexes1), count($result));
326  }
$result
Create styles array
The data for the language used.

◆ testToString()

AutoFilterTest::testToString ( )

Definition at line 34 of file AutoFilterTest.php.

References $_testAutoFilterObject, $_testInitialRange, and $result.

35  {
36  $expectedResult = $this->_testInitialRange;
37 
38  // magic __toString should return the active autofilter range
40  $this->assertEquals($expectedResult, $result);
41  }
$result

Field Documentation

◆ $_testAutoFilterObject

AutoFilterTest::$_testAutoFilterObject
private

Definition at line 8 of file AutoFilterTest.php.

Referenced by testClone(), and testToString().

◆ $_testInitialRange

AutoFilterTest::$_testInitialRange = 'H2:O256'
private

Definition at line 6 of file AutoFilterTest.php.

Referenced by testGetRange(), and testToString().


The documentation for this class was generated from the following file: