ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ColumnIteratorTest.php
Go to the documentation of this file.
1 <?php
2 
4 {
5  public $mockWorksheet;
6  public $mockColumn;
7 
8  public function setUp()
9  {
10  if (!defined('PHPEXCEL_ROOT')) {
11  define('PHPEXCEL_ROOT', APPLICATION_PATH . '/');
12  }
13  require_once(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php');
14 
15  $this->mockColumn = $this->getMockBuilder('PHPExcel_Worksheet_Column')
16  ->disableOriginalConstructor()
17  ->getMock();
18 
19  $this->mockWorksheet = $this->getMockBuilder('PHPExcel_Worksheet')
20  ->disableOriginalConstructor()
21  ->getMock();
22 
23  $this->mockWorksheet->expects($this->any())
24  ->method('getHighestColumn')
25  ->will($this->returnValue('E'));
26  $this->mockWorksheet->expects($this->any())
27  ->method('current')
28  ->will($this->returnValue($this->mockColumn));
29  }
30 
31 
32  public function testIteratorFullRange()
33  {
34  $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet);
35  $columnIndexResult = 'A';
36  $this->assertEquals($columnIndexResult, $iterator->key());
37 
38  foreach($iterator as $key => $column) {
39  $this->assertEquals($columnIndexResult++, $key);
40  $this->assertInstanceOf('PHPExcel_Worksheet_Column', $column);
41  }
42  }
43 
44  public function testIteratorStartEndRange()
45  {
46  $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D');
47  $columnIndexResult = 'B';
48  $this->assertEquals($columnIndexResult, $iterator->key());
49 
50  foreach($iterator as $key => $column) {
51  $this->assertEquals($columnIndexResult++, $key);
52  $this->assertInstanceOf('PHPExcel_Worksheet_Column', $column);
53  }
54  }
55 
56  public function testIteratorSeekAndPrev()
57  {
58  $ranges = range('A','E');
59  $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D');
60  $columnIndexResult = 'D';
61  $iterator->seek('D');
62  $this->assertEquals($columnIndexResult, $iterator->key());
63 
64  for($i = 1; $i < array_search($columnIndexResult, $ranges); $i++) {
65  $iterator->prev();
66  $expectedResult = $ranges[array_search($columnIndexResult, $ranges) - $i];
67  $this->assertEquals($expectedResult, $iterator->key());
68  }
69  }
70 
74  public function testSeekOutOfRange()
75  {
76  $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D');
77  $iterator->seek('A');
78  }
79 
83  public function testPrevOutOfRange()
84  {
85  $iterator = new PHPExcel_Worksheet_ColumnIterator($this->mockWorksheet, 'B', 'D');
86  $iterator->prev();
87  }
88 
89 }
testSeekOutOfRange()
PHPExcel_Exception
testPrevOutOfRange()
PHPExcel_Exception
Resolve range
$column
Definition: 39dropdown.php:62
$i
Definition: disco.tpl.php:19
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
$key
Definition: croninfo.php:18