mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-24 12:54:44 +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
|
@ -26,6 +26,7 @@ namespace App\Tests\Services;
|
|||
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Services\AmountFormatter;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class AmountFormatterTest extends WebTestCase
|
||||
|
@ -55,7 +56,7 @@ class AmountFormatterTest extends WebTestCase
|
|||
|
||||
public function testInvalidInput(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->service->format('test');
|
||||
}
|
||||
|
||||
|
@ -83,8 +84,14 @@ class AmountFormatterTest extends WebTestCase
|
|||
|
||||
public function testFormatMoreDigits(): void
|
||||
{
|
||||
$this->assertSame('12.12345', $this->service->format(12.1234532, null, ['is_integer' => false, 'decimals' => 5]));
|
||||
$this->assertSame('12.1', $this->service->format(12.1234532, null, ['is_integer' => false, 'decimals' => 1]));
|
||||
$this->assertSame('12.12345', $this->service->format(12.1234532, null, [
|
||||
'is_integer' => false,
|
||||
'decimals' => 5,
|
||||
]));
|
||||
$this->assertSame('12.1', $this->service->format(12.1234532, null, [
|
||||
'is_integer' => false,
|
||||
'decimals' => 1,
|
||||
]));
|
||||
}
|
||||
|
||||
public function testFormatOptionsOverride(): void
|
||||
|
|
|
@ -26,18 +26,19 @@ namespace App\Tests\Services\Attachments;
|
|||
|
||||
use App\Services\AmountFormatter;
|
||||
use App\Services\Attachments\AttachmentPathResolver;
|
||||
use const DIRECTORY_SEPARATOR;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class AttachmentPathResolverTest extends WebTestCase
|
||||
{
|
||||
public static $media_path;
|
||||
public static $footprint_path;
|
||||
protected static $projectDir_orig;
|
||||
protected static $projectDir;
|
||||
/**
|
||||
* @var AmountFormatter
|
||||
*/
|
||||
protected static $service;
|
||||
protected static $projectDir_orig;
|
||||
protected static $projectDir;
|
||||
|
||||
public function __construct($name = null, array $data = [], $dataName = '')
|
||||
{
|
||||
|
@ -68,8 +69,8 @@ class AttachmentPathResolverTest extends WebTestCase
|
|||
$this->assertSame(self::$projectDir_orig, self::$service->parameterToAbsolutePath(self::$projectDir));
|
||||
|
||||
//Relative pathes should be resolved
|
||||
$this->assertSame(self::$projectDir_orig.\DIRECTORY_SEPARATOR.'src', self::$service->parameterToAbsolutePath('src'));
|
||||
$this->assertSame(self::$projectDir_orig.\DIRECTORY_SEPARATOR.'src', self::$service->parameterToAbsolutePath('./src'));
|
||||
$this->assertSame(self::$projectDir_orig.DIRECTORY_SEPARATOR.'src', self::$service->parameterToAbsolutePath('src'));
|
||||
$this->assertSame(self::$projectDir_orig.DIRECTORY_SEPARATOR.'src', self::$service->parameterToAbsolutePath('./src'));
|
||||
|
||||
//Invalid pathes should return null
|
||||
$this->assertNull(self::$service->parameterToAbsolutePath('/this/path/does/not/exist'));
|
||||
|
|
|
@ -29,13 +29,14 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||
|
||||
class BuiltinAttachmentsFinderTest extends WebTestCase
|
||||
{
|
||||
/** @var BuiltinAttachmentsFinder */
|
||||
protected static $service;
|
||||
|
||||
protected static $mock_list = [
|
||||
'%FOOTPRINTS%/test/test.jpg', '%FOOTPRINTS%/test/test.png', '%FOOTPRINTS%/123.jpg', '%FOOTPRINTS%/123.jpeg',
|
||||
'%FOOTPRINTS_3D%/test.jpg', '%FOOTPRINTS_3D%/hallo.txt',
|
||||
];
|
||||
/**
|
||||
* @var BuiltinAttachmentsFinder
|
||||
*/
|
||||
protected static $service;
|
||||
|
||||
public static function setUpBeforeClass(): void
|
||||
{
|
||||
|
|
|
@ -28,19 +28,20 @@ use App\Entity\UserSystem\Group;
|
|||
use App\Entity\UserSystem\PermissionsEmbed;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Services\PermissionResolver;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
class PermissionResolverTest extends WebTestCase
|
||||
{
|
||||
protected $user_withoutGroup;
|
||||
|
||||
protected $user;
|
||||
protected $group;
|
||||
/**
|
||||
* @var PermissionResolver
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
protected $user;
|
||||
protected $user_withoutGroup;
|
||||
protected $group;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp(); // TODO: Change the autogenerated stub
|
||||
|
@ -132,7 +133,7 @@ class PermissionResolverTest extends WebTestCase
|
|||
|
||||
public function testInvalidListOperationsForPermission(): void
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
//Must throw an exception
|
||||
$this->service->listOperationsForPermission('invalid');
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace App\Tests\Services\TFA;
|
|||
|
||||
use App\Services\TFA\BackupCodeGenerator;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RuntimeException;
|
||||
|
||||
class BackupCodeGeneratorTest extends TestCase
|
||||
{
|
||||
|
@ -34,7 +35,7 @@ class BackupCodeGeneratorTest extends TestCase
|
|||
*/
|
||||
public function testLengthUpperLimit(): void
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectException(RuntimeException::class);
|
||||
new BackupCodeGenerator(33, 10);
|
||||
}
|
||||
|
||||
|
@ -43,7 +44,7 @@ class BackupCodeGeneratorTest extends TestCase
|
|||
*/
|
||||
public function testLengthLowerLimit(): void
|
||||
{
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectException(RuntimeException::class);
|
||||
new BackupCodeGenerator(4, 10);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,11 +34,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||
*/
|
||||
class NodesListBuilderTest extends WebTestCase
|
||||
{
|
||||
protected $em;
|
||||
/**
|
||||
* @var NodesListBuilder
|
||||
*/
|
||||
protected $service;
|
||||
protected $em;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
|
@ -36,11 +36,11 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|||
*/
|
||||
class TreeViewGeneratorTest extends WebTestCase
|
||||
{
|
||||
protected $em;
|
||||
/**
|
||||
* @var TreeViewGenerator
|
||||
*/
|
||||
protected $service;
|
||||
protected $em;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue