2
2
3
3
namespace PhpOffice \PhpSpreadsheetTests ;
4
4
5
- use PhpOffice \PhpSpreadsheet \Exception as ssException ;
5
+ use PhpOffice \PhpSpreadsheet \Exception ;
6
6
use PhpOffice \PhpSpreadsheet \Spreadsheet ;
7
7
use PhpOffice \PhpSpreadsheet \Worksheet \Worksheet ;
8
8
use PHPUnit \Framework \TestCase ;
@@ -67,7 +67,7 @@ public function testGetSheetByName(?int $index, string $sheetName): void
67
67
public function testAddSheetDuplicateTitle (): void
68
68
{
69
69
$ spreadsheet = $ this ->getSpreadsheet ();
70
- $ this ->expectException (ssException ::class);
70
+ $ this ->expectException (Exception ::class);
71
71
$ sheet = new Worksheet ();
72
72
$ sheet ->setTitle ('someSheet2 ' );
73
73
$ spreadsheet ->addSheet ($ sheet );
@@ -98,7 +98,7 @@ public function testAddSheetAdjustActive(): void
98
98
public function testRemoveSheetIndexTooHigh (): void
99
99
{
100
100
$ spreadsheet = $ this ->getSpreadsheet ();
101
- $ this ->expectException (ssException ::class);
101
+ $ this ->expectException (Exception ::class);
102
102
$ spreadsheet ->removeSheetByIndex (4 );
103
103
}
104
104
@@ -123,14 +123,14 @@ public function testRemoveSheetAdjustActive(): void
123
123
public function testGetSheetIndexTooHigh (): void
124
124
{
125
125
$ spreadsheet = $ this ->getSpreadsheet ();
126
- $ this ->expectException (ssException ::class);
126
+ $ this ->expectException (Exception ::class);
127
127
$ spreadsheet ->getSheet (4 );
128
128
}
129
129
130
130
public function testGetIndexNonExistent (): void
131
131
{
132
132
$ spreadsheet = $ this ->getSpreadsheet ();
133
- $ this ->expectException (ssException ::class);
133
+ $ this ->expectException (Exception ::class);
134
134
$ sheet = new Worksheet ();
135
135
$ sheet ->setTitle ('someSheet4 ' );
136
136
$ spreadsheet ->getIndex ($ sheet );
@@ -175,14 +175,14 @@ public function testBug1735(): void
175
175
public function testSetActiveSheetIndexTooHigh (): void
176
176
{
177
177
$ spreadsheet = $ this ->getSpreadsheet ();
178
- $ this ->expectException (ssException ::class);
178
+ $ this ->expectException (Exception ::class);
179
179
$ spreadsheet ->setActiveSheetIndex (4 );
180
180
}
181
181
182
182
public function testSetActiveSheetNoSuchName (): void
183
183
{
184
184
$ spreadsheet = $ this ->getSpreadsheet ();
185
- $ this ->expectException (ssException ::class);
185
+ $ this ->expectException (Exception ::class);
186
186
$ spreadsheet ->setActiveSheetIndexByName ('unknown ' );
187
187
}
188
188
@@ -210,7 +210,7 @@ public function testAddExternal(): void
210
210
211
211
public function testAddExternalDuplicateName (): void
212
212
{
213
- $ this ->expectException (ssException ::class);
213
+ $ this ->expectException (Exception ::class);
214
214
$ spreadsheet = new Spreadsheet ();
215
215
$ sheet = $ spreadsheet ->createSheet ()->setTitle ('someSheet1 ' );
216
216
$ sheet ->getCell ('A1 ' )->setValue (1 );
@@ -275,4 +275,22 @@ public function testAddExternalRowDimensionStyles(): void
275
275
self ::assertEquals ($ countXfs + $ index , $ sheet3 ->getCell ('A2 ' )->getXfIndex ());
276
276
self ::assertEquals ($ countXfs + $ index , $ sheet3 ->getRowDimension (2 )->getXfIndex ());
277
277
}
278
+
279
+ public function testNotSerializable (): void
280
+ {
281
+ $ this ->spreadsheet = $ spreadsheet = new Spreadsheet ();
282
+
283
+ $ this ->expectException (Exception::class);
284
+ $ this ->expectExceptionMessage ('Spreadsheet objects cannot be serialized ' );
285
+ serialize ($ this ->spreadsheet );
286
+ }
287
+
288
+ public function testNotJsonEncodable (): void
289
+ {
290
+ $ this ->spreadsheet = $ spreadsheet = new Spreadsheet ();
291
+
292
+ $ this ->expectException (Exception::class);
293
+ $ this ->expectExceptionMessage ('Spreadsheet objects cannot be json encoded ' );
294
+ json_encode ($ this ->spreadsheet );
295
+ }
278
296
}
0 commit comments