ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
RowIteratorTest.php
Go to the documentation of this file.
1 <?php
2 
4 {
5  public $mockWorksheet;
6  public $mockRow;
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->mockRow = $this->getMockBuilder('PHPExcel_Worksheet_Row')
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('getHighestRow')
25  ->will($this->returnValue(5));
26  $this->mockWorksheet->expects($this->any())
27  ->method('current')
28  ->will($this->returnValue($this->mockRow));
29  }
30 
31 
32  public function testIteratorFullRange()
33  {
34  $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet);
35  $rowIndexResult = 1;
36  $this->assertEquals($rowIndexResult, $iterator->key());
37 
38  foreach($iterator as $key => $row) {
39  $this->assertEquals($rowIndexResult++, $key);
40  $this->assertInstanceOf('PHPExcel_Worksheet_Row', $row);
41  }
42  }
43 
44  public function testIteratorStartEndRange()
45  {
46  $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4);
47  $rowIndexResult = 2;
48  $this->assertEquals($rowIndexResult, $iterator->key());
49 
50  foreach($iterator as $key => $row) {
51  $this->assertEquals($rowIndexResult++, $key);
52  $this->assertInstanceOf('PHPExcel_Worksheet_Row', $row);
53  }
54  }
55 
56  public function testIteratorSeekAndPrev()
57  {
58  $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4);
59  $columnIndexResult = 4;
60  $iterator->seek(4);
61  $this->assertEquals($columnIndexResult, $iterator->key());
62 
63  for($i = 1; $i < $columnIndexResult-1; $i++) {
64  $iterator->prev();
65  $this->assertEquals($columnIndexResult - $i, $iterator->key());
66  }
67  }
68 
72  public function testSeekOutOfRange()
73  {
74  $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4);
75  $iterator->seek(1);
76  }
77 
81  public function testPrevOutOfRange()
82  {
83  $iterator = new PHPExcel_Worksheet_RowIterator($this->mockWorksheet, 2, 4);
84  $iterator->prev();
85  }
86 
87 }
testPrevOutOfRange()
PHPExcel_Exception
$i
Definition: disco.tpl.php:19
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27
testSeekOutOfRange()
PHPExcel_Exception
$key
Definition: croninfo.php:18