Code Duplication    Length = 13-13 lines in 7 locations

tests/PhpSpreadsheetTests/CellTest.php 7 locations

@@ 26-38 (lines=13) @@
23
        return require 'data/ColumnString.php';
24
    }
25
26
    public function testColumnIndexFromStringTooLong()
27
    {
28
        $cellAddress = 'ABCD';
29
        try {
30
            Cell::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()
41
    {
@@ 40-52 (lines=13) @@
37
        $this->fail('An expected exception has not been raised.');
38
    }
39
40
    public function testColumnIndexFromStringTooShort()
41
    {
42
        $cellAddress = '';
43
        try {
44
            Cell::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
    /**
55
     * @dataProvider providerColumnIndex
@@ 86-98 (lines=13) @@
83
        return require 'data/CellCoordinates.php';
84
    }
85
86
    public function testCoordinateFromStringWithRangeAddress()
87
    {
88
        $cellAddress = 'A1:AI2012';
89
        try {
90
            Cell::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()
101
    {
@@ 100-112 (lines=13) @@
97
        $this->fail('An expected exception has not been raised.');
98
    }
99
100
    public function testCoordinateFromStringWithEmptyAddress()
101
    {
102
        $cellAddress = '';
103
        try {
104
            Cell::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()
115
    {
@@ 114-126 (lines=13) @@
111
        $this->fail('An expected exception has not been raised.');
112
    }
113
114
    public function testCoordinateFromStringWithInvalidAddress()
115
    {
116
        $cellAddress = 'AI';
117
        try {
118
            Cell::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
    /**
129
     * @dataProvider providerAbsoluteCoordinates
@@ 144-156 (lines=13) @@
141
        return require 'data/CellAbsoluteCoordinate.php';
142
    }
143
144
    public function testAbsoluteCoordinateFromStringWithRangeAddress()
145
    {
146
        $cellAddress = 'A1:AI2012';
147
        try {
148
            Cell::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
    /**
159
     * @dataProvider providerAbsoluteReferences
@@ 174-186 (lines=13) @@
171
        return require 'data/CellAbsoluteReference.php';
172
    }
173
174
    public function testAbsoluteReferenceFromStringWithRangeAddress()
175
    {
176
        $cellAddress = 'A1:AI2012';
177
        try {
178
            Cell::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
    /**
189
     * @dataProvider providerSplitRange