22
33namespace SimpleSAML \Test ;
44
5- use \SimpleSAML \Configuration ;
5+ use SimpleSAML \Configuration ;
6+ use SimpleSAML \Error \CriticalConfigurationError ;
67
78/**
89 * Tests for \SimpleSAML\Configuration
@@ -20,10 +21,10 @@ public function testGetVersion()
2021
2122 /**
2223 * Test that the default instance fails to load even if we previously loaded another instance.
23- * @expectedException \SimpleSAML\Error\CriticalConfigurationError
2424 */
2525 public function testLoadDefaultInstance ()
2626 {
27+ $ this ->expectException (CriticalConfigurationError::class);
2728 Configuration::loadFromArray (['key ' => 'value ' ], '' , 'dummy ' );
2829 Configuration::getInstance ();
2930 }
@@ -70,10 +71,10 @@ public function testGetValue()
7071
7172 /**
7273 * Test \SimpleSAML\Configuration::getValue(), REQUIRED_OPTION flag.
73- * @expectedException Exception
7474 */
7575 public function testGetValueRequired ()
7676 {
77+ $ this ->expectException (\Exception::class);
7778 $ c = Configuration::loadFromArray ([]);
7879 $ c ->getValue ('missing ' , Configuration::REQUIRED_OPTION );
7980 }
@@ -239,20 +240,20 @@ public function testGetBoolean()
239240
240241 /**
241242 * Test \SimpleSAML\Configuration::getBoolean() missing option
242- * @expectedException Exception
243243 */
244244 public function testGetBooleanMissing ()
245245 {
246+ $ this ->expectException (\Exception::class);
246247 $ c = Configuration::loadFromArray ([]);
247248 $ c ->getBoolean ('missing_opt ' );
248249 }
249250
250251 /**
251252 * Test \SimpleSAML\Configuration::getBoolean() wrong option
252- * @expectedException Exception
253253 */
254254 public function testGetBooleanWrong ()
255255 {
256+ $ this ->expectException (\Exception::class);
256257 $ c = Configuration::loadFromArray ([
257258 'wrong ' => 'true ' ,
258259 ]);
@@ -273,20 +274,20 @@ public function testGetString()
273274
274275 /**
275276 * Test \SimpleSAML\Configuration::getString() missing option
276- * @expectedException Exception
277277 */
278278 public function testGetStringMissing ()
279279 {
280+ $ this ->expectException (\Exception::class);
280281 $ c = Configuration::loadFromArray ([]);
281282 $ c ->getString ('missing_opt ' );
282283 }
283284
284285 /**
285286 * Test \SimpleSAML\Configuration::getString() wrong option
286- * @expectedException Exception
287287 */
288288 public function testGetStringWrong ()
289289 {
290+ $ this ->expectException (\Exception::class);
290291 $ c = Configuration::loadFromArray ([
291292 'wrong ' => false ,
292293 ]);
@@ -307,20 +308,20 @@ public function testGetInteger()
307308
308309 /**
309310 * Test \SimpleSAML\Configuration::getInteger() missing option
310- * @expectedException Exception
311311 */
312312 public function testGetIntegerMissing ()
313313 {
314+ $ this ->expectException (\Exception::class);
314315 $ c = Configuration::loadFromArray ([]);
315316 $ c ->getInteger ('missing_opt ' );
316317 }
317318
318319 /**
319320 * Test \SimpleSAML\Configuration::getInteger() wrong option
320- * @expectedException Exception
321321 */
322322 public function testGetIntegerWrong ()
323323 {
324+ $ this ->expectException (\Exception::class);
324325 $ c = Configuration::loadFromArray ([
325326 'wrong ' => '42 ' ,
326327 ]);
@@ -341,10 +342,10 @@ public function testGetIntegerRange()
341342
342343 /**
343344 * Test \SimpleSAML\Configuration::getIntegerRange() below limit
344- * @expectedException Exception
345345 */
346346 public function testGetIntegerRangeBelow ()
347347 {
348+ $ this ->expectException (\Exception::class);
348349 $ c = Configuration::loadFromArray ([
349350 'int_opt ' => 9 ,
350351 ]);
@@ -353,10 +354,10 @@ public function testGetIntegerRangeBelow()
353354
354355 /**
355356 * Test \SimpleSAML\Configuration::getIntegerRange() above limit
356- * @expectedException Exception
357357 */
358358 public function testGetIntegerRangeAbove ()
359359 {
360+ $ this ->expectException (\Exception::class);
360361 $ c = Configuration::loadFromArray ([
361362 'int_opt ' => 101 ,
362363 ]);
@@ -377,10 +378,10 @@ public function testGetValueValidate()
377378
378379 /**
379380 * Test \SimpleSAML\Configuration::getValueValidate() wrong option
380- * @expectedException Exception
381381 */
382382 public function testGetValueValidateWrong ()
383383 {
384+ $ this ->expectException (\Exception::class);
384385 $ c = Configuration::loadFromArray ([
385386 'opt ' => 'd ' ,
386387 ]);
@@ -401,10 +402,10 @@ public function testGetArray()
401402
402403 /**
403404 * Test \SimpleSAML\Configuration::getArray() wrong option
404- * @expectedException Exception
405405 */
406406 public function testGetArrayWrong ()
407407 {
408+ $ this ->expectException (\Exception::class);
408409 $ c = Configuration::loadFromArray ([
409410 'opt ' => 'not_an_array ' ,
410411 ]);
@@ -444,10 +445,10 @@ public function testGetArrayizeString()
444445 /**
445446 * Test \SimpleSAML\Configuration::getArrayizeString() option
446447 * with an array that contains something that isn't a string.
447- * @expectedException Exception
448448 */
449449 public function testGetArrayizeStringWrongValue ()
450450 {
451+ $ this ->expectException (\Exception::class);
451452 $ c = Configuration::loadFromArray ([
452453 'opt ' => ['a ' , 'b ' , 42 ],
453454 ]);
@@ -470,10 +471,10 @@ public function testGetConfigItem()
470471
471472 /**
472473 * Test \SimpleSAML\Configuration::getConfigItem() wrong option
473- * @expectedException Exception
474474 */
475475 public function testGetConfigItemWrong ()
476476 {
477+ $ this ->expectException (\Exception::class);
477478 $ c = Configuration::loadFromArray ([
478479 'opt ' => 'not_an_array ' ,
479480 ]);
@@ -503,10 +504,10 @@ public function testGetConfigList()
503504
504505 /**
505506 * Test \SimpleSAML\Configuration::getConfigList() wrong option
506- * @expectedException Exception
507507 */
508508 public function testGetConfigListWrong ()
509509 {
510+ $ this ->expectException (\Exception::class);
510511 $ c = Configuration::loadFromArray ([
511512 'opt ' => 'not_an_array ' ,
512513 ]);
@@ -516,10 +517,10 @@ public function testGetConfigListWrong()
516517
517518 /**
518519 * Test \SimpleSAML\Configuration::getConfigList() with an array of wrong options.
519- * @expectedException Exception
520520 */
521521 public function testGetConfigListWrongArrayValues ()
522522 {
523+ $ this ->expectException (\Exception::class);
523524 $ c = Configuration::loadFromArray ([
524525 'opts ' => [
525526 'a ' ,
@@ -895,10 +896,10 @@ public function testGetLocalizedString()
895896
896897 /**
897898 * Test \SimpleSAML\Configuration::getLocalizedString() not array nor simple string
898- * @expectedException Exception
899899 */
900900 public function testGetLocalizedStringNotArray ()
901901 {
902+ $ this ->expectException (\Exception::class);
902903 $ c = Configuration::loadFromArray ([
903904 'opt ' => 42 ,
904905 ]);
@@ -907,10 +908,10 @@ public function testGetLocalizedStringNotArray()
907908
908909 /**
909910 * Test \SimpleSAML\Configuration::getLocalizedString() not string key
910- * @expectedException Exception
911911 */
912912 public function testGetLocalizedStringNotStringKey ()
913913 {
914+ $ this ->expectException (\Exception::class);
914915 $ c = Configuration::loadFromArray ([
915916 'opt ' => [42 => 'text ' ],
916917 ]);
@@ -919,10 +920,10 @@ public function testGetLocalizedStringNotStringKey()
919920
920921 /**
921922 * Test \SimpleSAML\Configuration::getLocalizedString() not string value
922- * @expectedException Exception
923923 */
924924 public function testGetLocalizedStringNotStringValue ()
925925 {
926+ $ this ->expectException (\Exception::class);
926927 $ c = Configuration::loadFromArray ([
927928 'opt ' => ['en ' => 42 ],
928929 ]);
@@ -931,10 +932,10 @@ public function testGetLocalizedStringNotStringValue()
931932
932933 /**
933934 * Test \SimpleSAML\Configuration::getConfig() nonexistent file
934- * @expectedException Exception
935935 */
936936 public function testGetConfigNonexistentFile ()
937937 {
938+ $ this ->expectException (\Exception::class);
938939 Configuration::getConfig ('nonexistent-nopreload.php ' );
939940 }
940941
0 commit comments