mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-16 05:14:35 +02:00
Applied symplify rules to codebase.
This commit is contained in:
parent
2f20d90041
commit
388e847b17
136 changed files with 1370 additions and 789 deletions
|
@ -49,6 +49,7 @@ use App\Entity\Parts\Supplier;
|
|||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Entity\UserSystem\Group;
|
||||
use App\Entity\UserSystem\User;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use ReflectionClass;
|
||||
|
||||
|
@ -114,7 +115,7 @@ class AttachmentTest extends TestCase
|
|||
*/
|
||||
public function testSetElementExceptionOnSubClasses(string $attachment_class, string $allowed_class): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
/** @var Attachment $attachment */
|
||||
$attachment = new $attachment_class();
|
||||
|
|
|
@ -25,6 +25,7 @@ declare(strict_types=1);
|
|||
namespace App\Tests\Entity\Parts;
|
||||
|
||||
use App\Entity\Parts\PartLot;
|
||||
use DateTime;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PartLotTest extends TestCase
|
||||
|
@ -34,7 +35,7 @@ class PartLotTest extends TestCase
|
|||
$lot = new PartLot();
|
||||
$this->assertNull($lot->isExpired(), 'Lot must be return null when no Expiration date is set!');
|
||||
|
||||
$datetime = new \DateTime();
|
||||
$datetime = new DateTime();
|
||||
|
||||
$lot->setExpirationDate($datetime->setTimestamp(strtotime('now +1 hour')));
|
||||
$this->assertFalse($lot->isExpired(), 'Lot with expiration date in the future must not be expired!');
|
||||
|
|
|
@ -27,6 +27,7 @@ namespace App\Tests\Entity\Parts;
|
|||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use DateTime;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
|
@ -86,7 +87,7 @@ class PartTest extends TestCase
|
|||
{
|
||||
$part = new Part();
|
||||
$measurement_unit = new MeasurementUnit();
|
||||
$datetime = new \DateTime();
|
||||
$datetime = new DateTime();
|
||||
|
||||
$this->assertSame(0.0, $part->getAmountSum());
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace App\Tests\Entity;
|
|||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Parts\Category;
|
||||
use InvalidArgumentException;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Yaml\Tests\A;
|
||||
|
||||
|
@ -84,7 +85,7 @@ class StructuralDBElementTest extends TestCase
|
|||
|
||||
public function testChildOfDifferentClasses(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$category = new Category();
|
||||
$this->root->isChildOf($category);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue