Applied symplify rules to codebase.

This commit is contained in:
Jan Böhmer 2020-01-05 22:49:00 +01:00
parent 2f20d90041
commit 388e847b17
136 changed files with 1370 additions and 789 deletions

View file

@ -26,7 +26,9 @@ namespace App\Tests\Entity\UserSystem;
use App\Entity\UserSystem\PermissionsEmbed;
use Doctrine\ORM\Mapping\Embedded;
use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use ReflectionClass;
class PermissionsEmbedTest extends TestCase
{
@ -60,7 +62,7 @@ class PermissionsEmbedTest extends TestCase
$this->assertNull($embed->getPermissionValue(PermissionsEmbed::USERS, 0));
//Set a value for testing to the part property
$reflection = new \ReflectionClass($embed);
$reflection = new ReflectionClass($embed);
$property = $reflection->getProperty('parts');
$property->setAccessible(true);
@ -79,7 +81,7 @@ class PermissionsEmbedTest extends TestCase
$embed = new PermissionsEmbed();
//Set a value for testing to the part property
$reflection = new \ReflectionClass($embed);
$reflection = new ReflectionClass($embed);
$property = $reflection->getProperty('parts');
$property->setAccessible(true);
@ -97,7 +99,7 @@ class PermissionsEmbedTest extends TestCase
{
$embed = new PermissionsEmbed();
//When encoutering an unknown permission name the class must throw an exception
$this->expectException(\InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);
$embed->getPermissionValue('invalid', 0);
}
@ -105,7 +107,7 @@ class PermissionsEmbedTest extends TestCase
{
$embed = new PermissionsEmbed();
//When encoutering an negative bit the class must throw an exception
$this->expectException(\InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);
$embed->getPermissionValue('parts', -1);
}
@ -113,7 +115,7 @@ class PermissionsEmbedTest extends TestCase
{
$embed = new PermissionsEmbed();
//When encoutering an odd bit number it must throw an error.
$this->expectException(\InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);
$embed->getPermissionValue('parts', 1);
}
@ -121,7 +123,7 @@ class PermissionsEmbedTest extends TestCase
{
$embed = new PermissionsEmbed();
//When encoutering an too high bit number it must throw an error.
$this->expectException(\InvalidArgumentException::class);
$this->expectException(InvalidArgumentException::class);
$embed->getPermissionValue('parts', 32);
}

View file

@ -26,6 +26,7 @@ namespace App\Tests\Entity\UserSystem;
use App\Entity\UserSystem\U2FKey;
use App\Entity\UserSystem\User;
use DateTime;
use PHPUnit\Framework\TestCase;
class UserTest extends TestCase
@ -69,7 +70,7 @@ class UserTest extends TestCase
$codes = ['test', 'invalid', 'test'];
$user->setBackupCodes($codes);
// Backup Codes generation date must be changed!
$this->assertEqualsWithDelta(new \DateTime(), $user->getBackupCodesGenerationDate(), 0.1);
$this->assertEqualsWithDelta(new DateTime(), $user->getBackupCodesGenerationDate(), 0.1);
$this->assertSame($codes, $user->getBackupCodes());
//Test what happens if we delete the backup keys