2727
2828namespace Clickalicious \Rng ;
2929
30+ use PHPUnit \Framework \TestCase ;
31+
3032/**
3133 * Class GeneratorTest
3234 *
3335 * @package Rng
3436 */
35- class GeneratorTest extends \PHPUnit_Framework_TestCase
37+ class GeneratorTest extends TestCase
3638{
3739 /**
3840 * Test: Get instance.
@@ -42,7 +44,7 @@ class GeneratorTest extends \PHPUnit_Framework_TestCase
4244 public function testInstance ()
4345 {
4446 $ this ->assertInstanceOf (
45- ' Clickalicious\Rng\ Generator' ,
47+ Generator::class ,
4648 new Generator ()
4749 );
4850 }
@@ -57,7 +59,7 @@ public function testCreatingInstanceByModeDefault()
5759 $ generator = new Generator ();
5860
5961 $ this ->assertInstanceOf (
60- ' Clickalicious\Rng\ Generator' ,
62+ Generator::class ,
6163 $ generator
6264 );
6365 }
@@ -74,7 +76,7 @@ public function testCreatingInstanceByModePhpDefault()
7476 );
7577
7678 $ this ->assertInstanceOf (
77- ' Clickalicious\Rng\ Generator' ,
79+ Generator::class ,
7880 $ generator
7981 );
8082 }
@@ -91,7 +93,7 @@ public function testCreatingInstanceByModePhpMersenneTwister()
9193 );
9294
9395 $ this ->assertInstanceOf (
94- ' Clickalicious\Rng\ Generator' ,
96+ Generator::class ,
9597 $ generator
9698 );
9799 }
@@ -108,7 +110,7 @@ public function testCreatingInstanceByModeOpenSsl()
108110 );
109111
110112 $ this ->assertInstanceOf (
111- ' Clickalicious\Rng\ Generator' ,
113+ Generator::class ,
112114 $ generator
113115 );
114116 }
@@ -277,6 +279,35 @@ public function testTryToSetInvalidEncryptionMode()
277279 public function testPassingSeedToConstructor ()
278280 {
279281 $ generator = new Generator (Generator::MODE_OPEN_SSL , time ());
280- $ this ->assertInstanceOf ('Clickalicious\Rng\Generator ' , $ generator );
282+ $ this ->assertInstanceOf (Generator::class, $ generator );
283+ }
284+
285+ /**
286+ * Test: Test should throw the invalid range excpetion.
287+ *
288+ * @author Benjamin Carl <opensource@clickalicious.de>
289+ */
290+ public function testGenerateOnInvalidRange ()
291+ {
292+ $ this ->expectException (Exception::class);
293+ $ this ->expectExceptionMessage ("Bad range " );
294+ $ generator = new Generator (Generator::MODE_OPEN_SSL );
295+ $ generator ->generate (-PHP_INT_MAX , PHP_INT_MAX );
296+ }
297+
298+ /**
299+ * Test: Test should throw the invalid range excpetion.
300+ *
301+ * @author Benjamin Carl <opensource@clickalicious.de>
302+ */
303+ public function testIsCryptographicStrong ()
304+ {
305+ $ generator = new Generator (Generator::MODE_OPEN_SSL );
306+ $ this ->assertNull ($ generator ->isCryptographicStrong ());
307+
308+
309+ $ generator = new Generator (Generator::MODE_OPEN_SSL );
310+ $ generator ->generate ();
311+ $ this ->assertTrue ($ generator ->isCryptographicStrong ());
281312 }
282313}
0 commit comments