Test Secure

master
Anton Smirnov 11 months ago
parent d230dbeac1
commit f85c6145dc

2
.gitignore vendored

@ -2,3 +2,5 @@
/docs/build
/vendor
/composer.lock
/.phpunit.result.cache
/reports

@ -28,6 +28,11 @@
"Random\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Arokettu\\Random\\Tests\\": "tests"
}
},
"require": {
"php": "^7.1 | ^8.0",
"ext-gmp": "*"

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
convertDeprecationsToExceptions="true"
executionOrder="random"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd">
<testsuites>
<testsuite name="all">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory>src</directory>
</include>
</coverage>
</phpunit>

@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
namespace Arokettu\Random\Tests;
use PHPUnit\Framework\TestCase;
use Random\Engine\Secure;
use Random\Randomizer;
class EngineSecureTest extends TestCase
{
public function testWorks(): void
{
$engine = new Secure();
self::assertNotEmpty($engine->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());
}
}
Loading…
Cancel
Save