From f85c6145dc99cbfe61849b6a6c74825b6d08f796 Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Sat, 23 Jul 2022 08:24:38 +0300 Subject: [PATCH] Test Secure --- .gitignore | 2 ++ composer.json | 5 +++++ phpunit.xml.dist | 16 ++++++++++++++++ tests/EngineSecureTest.php | 28 ++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 phpunit.xml.dist create mode 100644 tests/EngineSecureTest.php diff --git a/.gitignore b/.gitignore index 5125304..1709f98 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ /docs/build /vendor /composer.lock +/.phpunit.result.cache +/reports diff --git a/composer.json b/composer.json index a969b4d..e7ea6e5 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,11 @@ "Random\\": "src" } }, + "autoload-dev": { + "psr-4": { + "Arokettu\\Random\\Tests\\": "tests" + } + }, "require": { "php": "^7.1 | ^8.0", "ext-gmp": "*" diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 0000000..157e3b8 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,16 @@ + + + + + tests + + + + + src + + + diff --git a/tests/EngineSecureTest.php b/tests/EngineSecureTest.php new file mode 100644 index 0000000..cc851dd --- /dev/null +++ b/tests/EngineSecureTest.php @@ -0,0 +1,28 @@ +generate()); + $rnd = new Randomizer($engine); + $int = $rnd->getInt(1, 1000); + self::assertGreaterThanOrEqual(1, $int); + self::assertLessThanOrEqual(1000, $int); + } + + public function testNonSerializable(): void + { + $this->expectException(\Exception::class); + serialize(new Secure()); + } +}