mirror of
https://github.com/RobThree/TwoFactorAuth.git
synced 2026-08-18 15:55:39 +00:00
a968dd392a
use expectNotToPerformAssertions() instead
30 lines
729 B
PHP
30 lines
729 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Providers\Rng;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use RobThree\Auth\Providers\Rng\CSRNGProvider;
|
|
|
|
class CSRNGProviderTest extends TestCase
|
|
{
|
|
use NeedsRngLengths;
|
|
|
|
/**
|
|
* @requires function random_bytes
|
|
*/
|
|
public function testCSRNGProvidersReturnExpectedNumberOfBytes(): void
|
|
{
|
|
if (function_exists('random_bytes')) {
|
|
$rng = new CSRNGProvider();
|
|
foreach ($this->rngTestLengths as $l) {
|
|
$this->assertEquals($l, strlen($rng->getRandomBytes($l)));
|
|
}
|
|
$this->assertTrue($rng->isCryptographicallySecure());
|
|
} else {
|
|
$this->expectNotToPerformAssertions();
|
|
}
|
|
}
|
|
}
|