Code Duplication    Length = 13-13 lines in 7 locations

tests/PhpSpreadsheetTests/CellTest.php 7 locations

@@ 27-39 (lines=13) @@
24
        return require 'data/ColumnString.php';
25
    }
26
27
    public function testColumnIndexFromStringTooLong()
28
    {
29
        $cellAddress = 'ABCD';
30
        try {
31
            Cell::columnIndexFromString($cellAddress);
32
        } catch (\Exception $e) {
33
            $this->assertInstanceOf(Exception::class, $e);
34
            $this->assertEquals($e->getMessage(), 'Column string index can not be longer than 3 characters');
35
36
            return;
37
        }
38
        $this->fail('An expected exception has not been raised.');
39
    }
40
41
    public function testColumnIndexFromStringTooShort()
42
    {
@@ 41-53 (lines=13) @@
38
        $this->fail('An expected exception has not been raised.');
39
    }
40
41
    public function testColumnIndexFromStringTooShort()
42
    {
43
        $cellAddress = '';
44
        try {
45
            Cell::columnIndexFromString($cellAddress);
46
        } catch (\Exception $e) {
47
            $this->assertInstanceOf(Exception::class, $e);
48
            $this->assertEquals($e->getMessage(), 'Column string index can not be empty');
49
50
            return;
51
        }
52
        $this->fail('An expected exception has not been raised.');
53
    }
54
55
    /**
56
     * @dataProvider providerColumnIndex
@@ 87-99 (lines=13) @@
84
        return require 'data/CellCoordinates.php';
85
    }
86
87
    public function testCoordinateFromStringWithRangeAddress()
88
    {
89
        $cellAddress = 'A1:AI2012';
90
        try {
91
            Cell::coordinateFromString($cellAddress);
92
        } catch (\Exception $e) {
93
            $this->assertInstanceOf(Exception::class, $e);
94
            $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
95
96
            return;
97
        }
98
        $this->fail('An expected exception has not been raised.');
99
    }
100
101
    public function testCoordinateFromStringWithEmptyAddress()
102
    {
@@ 101-113 (lines=13) @@
98
        $this->fail('An expected exception has not been raised.');
99
    }
100
101
    public function testCoordinateFromStringWithEmptyAddress()
102
    {
103
        $cellAddress = '';
104
        try {
105
            Cell::coordinateFromString($cellAddress);
106
        } catch (\Exception $e) {
107
            $this->assertInstanceOf(Exception::class, $e);
108
            $this->assertEquals($e->getMessage(), 'Cell coordinate can not be zero-length string');
109
110
            return;
111
        }
112
        $this->fail('An expected exception has not been raised.');
113
    }
114
115
    public function testCoordinateFromStringWithInvalidAddress()
116
    {
@@ 115-127 (lines=13) @@
112
        $this->fail('An expected exception has not been raised.');
113
    }
114
115
    public function testCoordinateFromStringWithInvalidAddress()
116
    {
117
        $cellAddress = 'AI';
118
        try {
119
            Cell::coordinateFromString($cellAddress);
120
        } catch (\Exception $e) {
121
            $this->assertInstanceOf(Exception::class, $e);
122
            $this->assertEquals($e->getMessage(), 'Invalid cell coordinate ' . $cellAddress);
123
124
            return;
125
        }
126
        $this->fail('An expected exception has not been raised.');
127
    }
128
129
    /**
130
     * @dataProvider providerAbsoluteCoordinates
@@ 145-157 (lines=13) @@
142
        return require 'data/CellAbsoluteCoordinate.php';
143
    }
144
145
    public function testAbsoluteCoordinateFromStringWithRangeAddress()
146
    {
147
        $cellAddress = 'A1:AI2012';
148
        try {
149
            Cell::absoluteCoordinate($cellAddress);
150
        } catch (\Exception $e) {
151
            $this->assertInstanceOf(Exception::class, $e);
152
            $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
153
154
            return;
155
        }
156
        $this->fail('An expected exception has not been raised.');
157
    }
158
159
    /**
160
     * @dataProvider providerAbsoluteReferences
@@ 175-187 (lines=13) @@
172
        return require 'data/CellAbsoluteReference.php';
173
    }
174
175
    public function testAbsoluteReferenceFromStringWithRangeAddress()
176
    {
177
        $cellAddress = 'A1:AI2012';
178
        try {
179
            Cell::absoluteReference($cellAddress);
180
        } catch (\Exception $e) {
181
            $this->assertInstanceOf(Exception::class, $e);
182
            $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
183
184
            return;
185
        }
186
        $this->fail('An expected exception has not been raised.');
187
    }
188
189
    /**
190
     * @dataProvider providerSplitRange