Code Duplication    Length = 12-12 lines in 8 locations

tests/PhpSpreadsheetTests/CellTest.php 8 locations

@@ 26-37 (lines=12) @@
23
        return require 'data/ColumnString.php';
24
    }
25
26
    public function testColumnIndexFromStringTooLong()
27
    {
28
        $cellAddress = 'ABCD';
29
        try {
30
            $result = call_user_func([Cell::class, 'columnIndexFromString'], $cellAddress);
31
        } catch (\Exception $e) {
32
            $this->assertInstanceOf(Exception::class, $e);
33
            $this->assertEquals($e->getMessage(), 'Column string index can not be longer than 3 characters');
34
35
            return;
36
        }
37
        $this->fail('An expected exception has not been raised.');
38
    }
39
40
    public function testColumnIndexFromStringTooShort()
@@ 40-51 (lines=12) @@
37
        $this->fail('An expected exception has not been raised.');
38
    }
39
40
    public function testColumnIndexFromStringTooShort()
41
    {
42
        $cellAddress = '';
43
        try {
44
            $result = call_user_func([Cell::class, 'columnIndexFromString'], $cellAddress);
45
        } catch (\Exception $e) {
46
            $this->assertInstanceOf(Exception::class, $e);
47
            $this->assertEquals($e->getMessage(), 'Column string index can not be empty');
48
49
            return;
50
        }
51
        $this->fail('An expected exception has not been raised.');
52
    }
53
54
    /**
@@ 86-97 (lines=12) @@
83
        return require 'data/CellCoordinates.php';
84
    }
85
86
    public function testCoordinateFromStringWithRangeAddress()
87
    {
88
        $cellAddress = 'A1:AI2012';
89
        try {
90
            $result = call_user_func([Cell::class, 'coordinateFromString'], $cellAddress);
91
        } catch (\Exception $e) {
92
            $this->assertInstanceOf(Exception::class, $e);
93
            $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
94
95
            return;
96
        }
97
        $this->fail('An expected exception has not been raised.');
98
    }
99
100
    public function testCoordinateFromStringWithEmptyAddress()
@@ 100-111 (lines=12) @@
97
        $this->fail('An expected exception has not been raised.');
98
    }
99
100
    public function testCoordinateFromStringWithEmptyAddress()
101
    {
102
        $cellAddress = '';
103
        try {
104
            $result = call_user_func([Cell::class, 'coordinateFromString'], $cellAddress);
105
        } catch (\Exception $e) {
106
            $this->assertInstanceOf(Exception::class, $e);
107
            $this->assertEquals($e->getMessage(), 'Cell coordinate can not be zero-length string');
108
109
            return;
110
        }
111
        $this->fail('An expected exception has not been raised.');
112
    }
113
114
    public function testCoordinateFromStringWithInvalidAddress()
@@ 114-125 (lines=12) @@
111
        $this->fail('An expected exception has not been raised.');
112
    }
113
114
    public function testCoordinateFromStringWithInvalidAddress()
115
    {
116
        $cellAddress = 'AI';
117
        try {
118
            $result = call_user_func([Cell::class, 'coordinateFromString'], $cellAddress);
119
        } catch (\Exception $e) {
120
            $this->assertInstanceOf(Exception::class, $e);
121
            $this->assertEquals($e->getMessage(), 'Invalid cell coordinate ' . $cellAddress);
122
123
            return;
124
        }
125
        $this->fail('An expected exception has not been raised.');
126
    }
127
128
    /**
@@ 144-155 (lines=12) @@
141
        return require 'data/CellAbsoluteCoordinate.php';
142
    }
143
144
    public function testAbsoluteCoordinateFromStringWithRangeAddress()
145
    {
146
        $cellAddress = 'A1:AI2012';
147
        try {
148
            $result = call_user_func([Cell::class, 'absoluteCoordinate'], $cellAddress);
149
        } catch (\Exception $e) {
150
            $this->assertInstanceOf(Exception::class, $e);
151
            $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
152
153
            return;
154
        }
155
        $this->fail('An expected exception has not been raised.');
156
    }
157
158
    /**
@@ 174-185 (lines=12) @@
171
        return require 'data/CellAbsoluteReference.php';
172
    }
173
174
    public function testAbsoluteReferenceFromStringWithRangeAddress()
175
    {
176
        $cellAddress = 'A1:AI2012';
177
        try {
178
            $result = call_user_func([Cell::class, 'absoluteReference'], $cellAddress);
179
        } catch (\Exception $e) {
180
            $this->assertInstanceOf(Exception::class, $e);
181
            $this->assertEquals($e->getMessage(), 'Cell coordinate string can not be a range of cells');
182
183
            return;
184
        }
185
        $this->fail('An expected exception has not been raised.');
186
    }
187
188
    /**
@@ 226-237 (lines=12) @@
223
        return require 'data/CellBuildRange.php';
224
    }
225
226
    public function testBuildRangeInvalid()
227
    {
228
        $cellRange = '';
229
        try {
230
            $result = call_user_func([Cell::class, 'buildRange'], $cellRange);
231
        } catch (\Exception $e) {
232
            $this->assertInstanceOf(Exception::class, $e);
233
            $this->assertEquals($e->getMessage(), 'Range does not contain any information');
234
235
            return;
236
        }
237
        $this->fail('An expected exception has not been raised.');
238
    }
239
240
    /**