1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace PhpOffice\PhpSpreadsheetTests\Worksheet; |
4
|
|
|
|
5
|
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\Column; |
6
|
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\ColumnCellIterator; |
7
|
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; |
8
|
|
|
use PHPUnit_Framework_TestCase; |
9
|
|
|
|
10
|
|
View Code Duplication |
class ColumnTest extends PHPUnit_Framework_TestCase |
|
|
|
|
11
|
|
|
{ |
12
|
|
|
public $mockWorksheet; |
13
|
|
|
public $mockColumn; |
14
|
|
|
|
15
|
|
|
public function setUp() |
16
|
|
|
{ |
17
|
|
|
$this->mockWorksheet = $this->getMockBuilder(Worksheet::class) |
18
|
|
|
->disableOriginalConstructor() |
19
|
|
|
->getMock(); |
20
|
|
|
$this->mockWorksheet->expects($this->any()) |
21
|
|
|
->method('getHighestRow') |
22
|
|
|
->will($this->returnValue(5)); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testInstantiateColumnDefault() |
26
|
|
|
{ |
27
|
|
|
$column = new Column($this->mockWorksheet); |
28
|
|
|
self::assertInstanceOf(Column::class, $column); |
29
|
|
|
$columnIndex = $column->getColumnIndex(); |
30
|
|
|
self::assertEquals('A', $columnIndex); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testInstantiateColumnSpecified() |
34
|
|
|
{ |
35
|
|
|
$column = new Column($this->mockWorksheet, 'E'); |
36
|
|
|
self::assertInstanceOf(Column::class, $column); |
37
|
|
|
$columnIndex = $column->getColumnIndex(); |
38
|
|
|
self::assertEquals('E', $columnIndex); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testGetCellIterator() |
42
|
|
|
{ |
43
|
|
|
$column = new Column($this->mockWorksheet); |
44
|
|
|
$cellIterator = $column->getCellIterator(); |
45
|
|
|
self::assertInstanceOf(ColumnCellIterator::class, $cellIterator); |
46
|
|
|
} |
47
|
|
|
} |
48
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.