ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
RowCellIteratorTest.php
Go to the documentation of this file.
1<?php
2
4{
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->mockCell = $this->getMockBuilder('PHPExcel_Cell')
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('getCellByColumnAndRow')
28 ->will($this->returnValue($this->mockCell));
29 }
30
31
32 public function testIteratorFullRange()
33 {
34 $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet);
35 $RowCellIndexResult = 'A';
36 $this->assertEquals($RowCellIndexResult, $iterator->key());
37
38 foreach($iterator as $key => $RowCell) {
39 $this->assertEquals($RowCellIndexResult++, $key);
40 $this->assertInstanceOf('PHPExcel_Cell', $RowCell);
41 }
42 }
43
44 public function testIteratorStartEndRange()
45 {
46 $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
47 $RowCellIndexResult = 'B';
48 $this->assertEquals($RowCellIndexResult, $iterator->key());
49
50 foreach($iterator as $key => $RowCell) {
51 $this->assertEquals($RowCellIndexResult++, $key);
52 $this->assertInstanceOf('PHPExcel_Cell', $RowCell);
53 }
54 }
55
56 public function testIteratorSeekAndPrev()
57 {
58 $ranges = range('A','E');
59 $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
60 $RowCellIndexResult = 'D';
61 $iterator->seek('D');
62 $this->assertEquals($RowCellIndexResult, $iterator->key());
63
64 for($i = 1; $i < array_search($RowCellIndexResult, $ranges); $i++) {
65 $iterator->prev();
66 $expectedResult = $ranges[array_search($RowCellIndexResult, $ranges) - $i];
67 $this->assertEquals($expectedResult, $iterator->key());
68 }
69 }
70
74 public function testSeekOutOfRange()
75 {
76 $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
77 $iterator->seek(1);
78 }
79
83 public function testPrevOutOfRange()
84 {
85 $iterator = new PHPExcel_Worksheet_RowCellIterator($this->mockWorksheet, 2, 'B', 'D');
86 $iterator->prev();
87 }
88
89}
An exception for terminatinating execution or to throw for unit testing.
testSeekOutOfRange()
@expectedException PHPExcel_Exception
testPrevOutOfRange()
@expectedException PHPExcel_Exception
$key
Definition: croninfo.php:18
$i
Definition: disco.tpl.php:19
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27