mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-08-04 10:14:44 +02:00
Applied code style to tests/
This commit is contained in:
parent
f861de791f
commit
fe0f69f762
44 changed files with 427 additions and 306 deletions
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -29,7 +32,7 @@ class BackupCodeGeneratorTest extends TestCase
|
|||
/**
|
||||
* Test if an exception is thrown if you are using a too high code length.
|
||||
*/
|
||||
public function testLengthUpperLimit()
|
||||
public function testLengthUpperLimit(): void
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
new BackupCodeGenerator(33, 10);
|
||||
|
@ -38,7 +41,7 @@ class BackupCodeGeneratorTest extends TestCase
|
|||
/**
|
||||
* Test if an exception is thrown if you are using a too high code length.
|
||||
*/
|
||||
public function testLengthLowerLimit()
|
||||
public function testLengthLowerLimit(): void
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
new BackupCodeGenerator(4, 10);
|
||||
|
@ -52,7 +55,7 @@ class BackupCodeGeneratorTest extends TestCase
|
|||
/**
|
||||
* @dataProvider codeLengthDataProvider
|
||||
*/
|
||||
public function testGenerateSingleCode(int $code_length)
|
||||
public function testGenerateSingleCode(int $code_length): void
|
||||
{
|
||||
$generator = new BackupCodeGenerator($code_length, 10);
|
||||
$this->assertRegExp("/^([a-f0-9]){{$code_length}}\$/", $generator->generateSingleCode());
|
||||
|
@ -66,7 +69,7 @@ class BackupCodeGeneratorTest extends TestCase
|
|||
/**
|
||||
* @dataProvider codeCountDataProvider
|
||||
*/
|
||||
public function testGenerateCodeSet(int $code_count)
|
||||
public function testGenerateCodeSet(int $code_count): void
|
||||
{
|
||||
$generator = new BackupCodeGenerator(8, $code_count);
|
||||
$this->assertCount($code_count, $generator->generateCodeSet());
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -32,22 +35,22 @@ class BackupCodeManagerTest extends WebTestCase
|
|||
*/
|
||||
protected $service;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->service = self::$container->get(BackupCodeManager::class);
|
||||
}
|
||||
|
||||
public function testRegenerateBackupCodes()
|
||||
public function testRegenerateBackupCodes(): void
|
||||
{
|
||||
$user = new User();
|
||||
$old_codes = ['aaaa', 'bbbb'];
|
||||
$user->setBackupCodes($old_codes);
|
||||
$this->service->regenerateBackupCodes($user);
|
||||
$this->assertNotEquals($old_codes, $user->getBackupCodes());
|
||||
$this->assertNotSame($old_codes, $user->getBackupCodes());
|
||||
}
|
||||
|
||||
public function testEnableBackupCodes()
|
||||
public function testEnableBackupCodes(): void
|
||||
{
|
||||
$user = new User();
|
||||
//Check that nothing is changed, if there are already backup codes
|
||||
|
@ -55,7 +58,7 @@ class BackupCodeManagerTest extends WebTestCase
|
|||
$old_codes = ['aaaa', 'bbbb'];
|
||||
$user->setBackupCodes($old_codes);
|
||||
$this->service->enableBackupCodes($user);
|
||||
$this->assertEquals($old_codes, $user->getBackupCodes());
|
||||
$this->assertSame($old_codes, $user->getBackupCodes());
|
||||
|
||||
//When no old codes are existing, it should generate a set
|
||||
$user->setBackupCodes([]);
|
||||
|
@ -63,7 +66,7 @@ class BackupCodeManagerTest extends WebTestCase
|
|||
$this->assertNotEmpty($user->getBackupCodes());
|
||||
}
|
||||
|
||||
public function testDisableBackupCodesIfUnused()
|
||||
public function testDisableBackupCodesIfUnused(): void
|
||||
{
|
||||
$user = new User();
|
||||
|
||||
|
@ -77,6 +80,6 @@ class BackupCodeManagerTest extends WebTestCase
|
|||
|
||||
$user->setGoogleAuthenticatorSecret('jskf');
|
||||
$this->service->disableBackupCodesIfUnused($user);
|
||||
$this->assertEquals($codes, $user->getBackupCodes());
|
||||
$this->assertSame($codes, $user->getBackupCodes());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue