diff options
Diffstat (limited to 'tests/lib/Security/SecureRandomTest.php')
-rw-r--r-- | tests/lib/Security/SecureRandomTest.php | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/tests/lib/Security/SecureRandomTest.php b/tests/lib/Security/SecureRandomTest.php index 8000917579b..954fd85eaf1 100644 --- a/tests/lib/Security/SecureRandomTest.php +++ b/tests/lib/Security/SecureRandomTest.php @@ -13,7 +13,7 @@ namespace Test\Security; use OC\Security\SecureRandom; class SecureRandomTest extends \Test\TestCase { - public function stringGenerationProvider() { + public static function stringGenerationProvider(): array { return [ [1, 1], [128, 128], @@ -24,7 +24,7 @@ class SecureRandomTest extends \Test\TestCase { ]; } - public static function charCombinations() { + public static function charCombinations(): array { return [ ['CHAR_LOWER', '[a-z]'], ['CHAR_UPPER', '[A-Z]'], @@ -37,37 +37,29 @@ class SecureRandomTest extends \Test\TestCase { protected function setUp(): void { parent::setUp(); - $this->rng = new \OC\Security\SecureRandom(); + $this->rng = new SecureRandom(); } - /** - * @dataProvider stringGenerationProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('stringGenerationProvider')] public function testGetLowStrengthGeneratorLength($length, $expectedLength): void { $generator = $this->rng; $this->assertEquals($expectedLength, strlen($generator->generate($length))); } - /** - * @dataProvider stringGenerationProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('stringGenerationProvider')] public function testMediumLowStrengthGeneratorLength($length, $expectedLength): void { $generator = $this->rng; $this->assertEquals($expectedLength, strlen($generator->generate($length))); } - /** - * @dataProvider stringGenerationProvider - */ + #[\PHPUnit\Framework\Attributes\DataProvider('stringGenerationProvider')] public function testUninitializedGenerate($length, $expectedLength): void { $this->assertEquals($expectedLength, strlen($this->rng->generate($length))); } - /** - * @dataProvider charCombinations - */ + #[\PHPUnit\Framework\Attributes\DataProvider('charCombinations')] public function testScheme($charName, $chars): void { $generator = $this->rng; $scheme = constant('OCP\Security\ISecureRandom::' . $charName); @@ -76,16 +68,14 @@ class SecureRandomTest extends \Test\TestCase { $this->assertSame(1, $matchesRegex); } - public static function invalidLengths() { + public static function invalidLengths(): array { return [ [0], [-1], ]; } - /** - * @dataProvider invalidLengths - */ + #[\PHPUnit\Framework\Attributes\DataProvider('invalidLengths')] public function testInvalidLengths($length): void { $this->expectException(\LengthException::class); $generator = $this->rng; |