@@ -70,11 +70,22 @@ public function testAddSheetDuplicateTitle(): void
70
70
{
71
71
$ spreadsheet = $ this ->getSpreadsheet ();
72
72
$ this ->expectException (Exception::class);
73
+ $ this ->expectExceptionMessage ("Workbook already contains a worksheet named 'someSheet2'. Rename this worksheet first. " );
73
74
$ sheet = new Worksheet ();
74
75
$ sheet ->setTitle ('someSheet2 ' );
75
76
$ spreadsheet ->addSheet ($ sheet );
76
77
}
77
78
79
+ public function testAddSheetDuplicateTitleWithDifferentCase (): void
80
+ {
81
+ $ spreadsheet = $ this ->getSpreadsheet ();
82
+ $ this ->expectException (Exception::class);
83
+ $ this ->expectExceptionMessage ("Workbook already contains a worksheet named 'SomeSheet2'. Rename this worksheet first. " );
84
+ $ sheet = new Worksheet ();
85
+ $ sheet ->setTitle ('SomeSheet2 ' );
86
+ $ spreadsheet ->addSheet ($ sheet );
87
+ }
88
+
78
89
public function testAddSheetNoAdjustActive (): void
79
90
{
80
91
$ spreadsheet = $ this ->getSpreadsheet ();
@@ -101,6 +112,7 @@ public function testRemoveSheetIndexTooHigh(): void
101
112
{
102
113
$ spreadsheet = $ this ->getSpreadsheet ();
103
114
$ this ->expectException (Exception::class);
115
+ $ this ->expectExceptionMessage ('You tried to remove a sheet by the out of bounds index: 4. The actual number of sheets is 3. ' );
104
116
$ spreadsheet ->removeSheetByIndex (4 );
105
117
}
106
118
@@ -126,13 +138,15 @@ public function testGetSheetIndexTooHigh(): void
126
138
{
127
139
$ spreadsheet = $ this ->getSpreadsheet ();
128
140
$ this ->expectException (Exception::class);
141
+ $ this ->expectExceptionMessage ('Your requested sheet index: 4 is out of bounds. The actual number of sheets is 3. ' );
129
142
$ spreadsheet ->getSheet (4 );
130
143
}
131
144
132
145
public function testGetIndexNonExistent (): void
133
146
{
134
147
$ spreadsheet = $ this ->getSpreadsheet ();
135
148
$ this ->expectException (Exception::class);
149
+ $ this ->expectExceptionMessage ('Sheet does not exist. ' );
136
150
$ sheet = new Worksheet ();
137
151
$ sheet ->setTitle ('someSheet4 ' );
138
152
$ spreadsheet ->getIndex ($ sheet );
@@ -178,13 +192,15 @@ public function testSetActiveSheetIndexTooHigh(): void
178
192
{
179
193
$ spreadsheet = $ this ->getSpreadsheet ();
180
194
$ this ->expectException (Exception::class);
195
+ $ this ->expectExceptionMessage ('You tried to set a sheet active by the out of bounds index: 4. The actual number of sheets is 3. ' );
181
196
$ spreadsheet ->setActiveSheetIndex (4 );
182
197
}
183
198
184
199
public function testSetActiveSheetNoSuchName (): void
185
200
{
186
201
$ spreadsheet = $ this ->getSpreadsheet ();
187
202
$ this ->expectException (Exception::class);
203
+ $ this ->expectExceptionMessage ('Workbook does not contain sheet:unknown ' );
188
204
$ spreadsheet ->setActiveSheetIndexByName ('unknown ' );
189
205
}
190
206
@@ -213,6 +229,7 @@ public function testAddExternal(): void
213
229
public function testAddExternalDuplicateName (): void
214
230
{
215
231
$ this ->expectException (Exception::class);
232
+ $ this ->expectExceptionMessage ("Workbook already contains a worksheet named 'someSheet1'. Rename the external sheet first. " );
216
233
$ spreadsheet = new Spreadsheet ();
217
234
$ sheet = $ spreadsheet ->createSheet ()->setTitle ('someSheet1 ' );
218
235
$ sheet ->getCell ('A1 ' )->setValue (1 );
0 commit comments