mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Applied rector suggestions
This commit is contained in:
parent
4106bcef5f
commit
20f32c7f12
170 changed files with 808 additions and 761 deletions
|
@ -34,7 +34,7 @@ class APITokenAuthenticationTest extends ApiTestCase
|
|||
self::ensureKernelShutdown();
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/api/parts');
|
||||
self::assertResponseStatusCodeSame(401);
|
||||
$this->assertResponseStatusCodeSame(401);
|
||||
}
|
||||
|
||||
public function testExpiredToken(): void
|
||||
|
@ -42,7 +42,7 @@ class APITokenAuthenticationTest extends ApiTestCase
|
|||
self::ensureKernelShutdown();
|
||||
$client = $this->createClientWithCredentials(APITokenFixtures::TOKEN_EXPIRED);
|
||||
$client->request('GET', '/api/parts');
|
||||
self::assertResponseStatusCodeSame(401);
|
||||
$this->assertResponseStatusCodeSame(401);
|
||||
}
|
||||
|
||||
public function testReadOnlyToken(): void
|
||||
|
@ -52,14 +52,14 @@ class APITokenAuthenticationTest extends ApiTestCase
|
|||
|
||||
//Read should be possible
|
||||
$client->request('GET', '/api/parts');
|
||||
self::assertResponseIsSuccessful();
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
//Trying to list all users and create a new footprint should fail
|
||||
$client->request('GET', '/api/users');
|
||||
self::assertResponseStatusCodeSame(403);
|
||||
$this->assertResponseStatusCodeSame(403);
|
||||
|
||||
$client->request('POST', '/api/footprints', ['json' => ['name' => 'post test']]);
|
||||
self::assertResponseStatusCodeSame(403);
|
||||
$this->assertResponseStatusCodeSame(403);
|
||||
}
|
||||
|
||||
public function testEditToken(): void
|
||||
|
@ -69,14 +69,14 @@ class APITokenAuthenticationTest extends ApiTestCase
|
|||
|
||||
//Read should be possible
|
||||
$client->request('GET', '/api/parts');
|
||||
self::assertResponseIsSuccessful();
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
//Trying to list all users
|
||||
$client->request('GET', '/api/users');
|
||||
self::assertResponseStatusCodeSame(403);
|
||||
$this->assertResponseStatusCodeSame(403);
|
||||
|
||||
$client->request('POST', '/api/footprints', ['json' => ['name' => 'post test']]);
|
||||
self::assertResponseIsSuccessful();
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public function testAdminToken(): void
|
||||
|
@ -86,14 +86,14 @@ class APITokenAuthenticationTest extends ApiTestCase
|
|||
|
||||
//Read should be possible
|
||||
$client->request('GET', '/api/parts');
|
||||
self::assertResponseIsSuccessful();
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
//Trying to list all users
|
||||
$client->request('GET', '/api/users');
|
||||
self::assertResponseIsSuccessful();
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$client->request('POST', '/api/footprints', ['json' => ['name' => 'post test']]);
|
||||
self::assertResponseIsSuccessful();
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public function testWithAuthorizationToken(): void
|
||||
|
@ -104,14 +104,14 @@ class APITokenAuthenticationTest extends ApiTestCase
|
|||
|
||||
//Read should be possible
|
||||
$client->request('GET', '/api/parts');
|
||||
self::assertResponseIsSuccessful();
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
//Trying to list all users
|
||||
$client->request('GET', '/api/users');
|
||||
self::assertResponseIsSuccessful();
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$client->request('POST', '/api/footprints', ['json' => ['name' => 'post test']]);
|
||||
self::assertResponseIsSuccessful();
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
protected function createClientWithCredentials(string $token): Client
|
||||
|
|
|
@ -30,9 +30,9 @@ class ApiTokenEnpointTest extends AuthenticatedApiTestCase
|
|||
public function testGetCurrentToken(): void
|
||||
{
|
||||
$response = self::createAuthenticatedClient()->request('GET', '/api/tokens/current');
|
||||
self::assertResponseIsSuccessful();
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
self::assertJsonContains([
|
||||
$this->assertJsonContains([
|
||||
'name' => 'admin',
|
||||
'level' => 3,
|
||||
]);
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Doctrine;
|
||||
|
||||
use App\Doctrine\Middleware\SQLiteRegexExtensionMiddlewareDriver;
|
||||
|
|
|
@ -72,22 +72,20 @@ class AttachmentTest extends TestCase
|
|||
$this->assertEmpty($attachment->getFilename());
|
||||
}
|
||||
|
||||
public function subClassesDataProvider(): array
|
||||
public function subClassesDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
[AttachmentTypeAttachment::class, AttachmentType::class],
|
||||
[CategoryAttachment::class, Category::class],
|
||||
[CurrencyAttachment::class, Currency::class],
|
||||
[ProjectAttachment::class, Project::class],
|
||||
[FootprintAttachment::class, Footprint::class],
|
||||
[GroupAttachment::class, Group::class],
|
||||
[ManufacturerAttachment::class, Manufacturer::class],
|
||||
[MeasurementUnitAttachment::class, MeasurementUnit::class],
|
||||
[PartAttachment::class, Part::class],
|
||||
[StorageLocationAttachment::class, StorageLocation::class],
|
||||
[SupplierAttachment::class, Supplier::class],
|
||||
[UserAttachment::class, User::class],
|
||||
];
|
||||
yield [AttachmentTypeAttachment::class, AttachmentType::class];
|
||||
yield [CategoryAttachment::class, Category::class];
|
||||
yield [CurrencyAttachment::class, Currency::class];
|
||||
yield [ProjectAttachment::class, Project::class];
|
||||
yield [FootprintAttachment::class, Footprint::class];
|
||||
yield [GroupAttachment::class, Group::class];
|
||||
yield [ManufacturerAttachment::class, Manufacturer::class];
|
||||
yield [MeasurementUnitAttachment::class, MeasurementUnit::class];
|
||||
yield [PartAttachment::class, Part::class];
|
||||
yield [StorageLocationAttachment::class, StorageLocation::class];
|
||||
yield [SupplierAttachment::class, Supplier::class];
|
||||
yield [UserAttachment::class, User::class];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -117,27 +115,21 @@ class AttachmentTest extends TestCase
|
|||
|
||||
/** @var Attachment $attachment */
|
||||
$attachment = new $attachment_class();
|
||||
if (Project::class !== $allowed_class) {
|
||||
$element = new Project();
|
||||
} else {
|
||||
$element = new Category();
|
||||
}
|
||||
$element = Project::class !== $allowed_class ? new Project() : new Category();
|
||||
$attachment->setElement($element);
|
||||
}
|
||||
|
||||
public function externalDataProvider(): array
|
||||
public function externalDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['', false],
|
||||
['%MEDIA%/foo/bar.txt', false],
|
||||
['%BASE%/foo/bar.jpg', false],
|
||||
['%FOOTPRINTS%/foo/bar.jpg', false],
|
||||
['%FOOTPRINTS3D%/foo/bar.jpg', false],
|
||||
['%SECURE%/test.txt', false],
|
||||
['%test%/foo/bar.ghp', true],
|
||||
['foo%MEDIA%/foo.jpg', true],
|
||||
['foo%MEDIA%/%BASE%foo.jpg', true],
|
||||
];
|
||||
yield ['', false];
|
||||
yield ['%MEDIA%/foo/bar.txt', false];
|
||||
yield ['%BASE%/foo/bar.jpg', false];
|
||||
yield ['%FOOTPRINTS%/foo/bar.jpg', false];
|
||||
yield ['%FOOTPRINTS3D%/foo/bar.jpg', false];
|
||||
yield ['%SECURE%/test.txt', false];
|
||||
yield ['%test%/foo/bar.ghp', true];
|
||||
yield ['foo%MEDIA%/foo.jpg', true];
|
||||
yield ['foo%MEDIA%/%BASE%foo.jpg', true];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,20 +142,18 @@ class AttachmentTest extends TestCase
|
|||
$this->assertSame($expected, $attachment->isExternal());
|
||||
}
|
||||
|
||||
public function extensionDataProvider(): array
|
||||
public function extensionDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['%MEDIA%/foo/bar.txt', null, 'txt'],
|
||||
['%MEDIA%/foo/bar.JPeg', null, 'jpeg'],
|
||||
['%MEDIA%/foo/bar.JPeg', 'test.txt', 'txt'],
|
||||
['%MEDIA%/foo/bar', null, ''],
|
||||
['%MEDIA%/foo.bar', 'bar', ''],
|
||||
['http://google.de', null, null],
|
||||
['https://foo.bar', null, null],
|
||||
['https://foo.bar/test.jpeg', null, null],
|
||||
['test', null, null],
|
||||
['test.txt', null, null],
|
||||
];
|
||||
yield ['%MEDIA%/foo/bar.txt', null, 'txt'];
|
||||
yield ['%MEDIA%/foo/bar.JPeg', null, 'jpeg'];
|
||||
yield ['%MEDIA%/foo/bar.JPeg', 'test.txt', 'txt'];
|
||||
yield ['%MEDIA%/foo/bar', null, ''];
|
||||
yield ['%MEDIA%/foo.bar', 'bar', ''];
|
||||
yield ['http://google.de', null, null];
|
||||
yield ['https://foo.bar', null, null];
|
||||
yield ['https://foo.bar/test.jpeg', null, null];
|
||||
yield ['test', null, null];
|
||||
yield ['test.txt', null, null];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,21 +167,19 @@ class AttachmentTest extends TestCase
|
|||
$this->assertSame($expected, $attachment->getExtension());
|
||||
}
|
||||
|
||||
public function pictureDataProvider(): array
|
||||
public function pictureDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['%MEDIA%/foo/bar.txt', false],
|
||||
['https://test.de/picture.jpeg', true],
|
||||
['https://test.de/picture.png?test=fdsj&width=34', true],
|
||||
['https://invalid.invalid/file.txt', false],
|
||||
['http://infsf.inda/file.zip?test', false],
|
||||
['https://test.de', true],
|
||||
['https://invalid.com/invalid/pic', true],
|
||||
['%MEDIA%/foo/bar.jpeg', true],
|
||||
['%MEDIA%/foo/bar.webp', true],
|
||||
['%MEDIA%/foo', false],
|
||||
['%SECURE%/foo.txt/test', false],
|
||||
];
|
||||
yield ['%MEDIA%/foo/bar.txt', false];
|
||||
yield ['https://test.de/picture.jpeg', true];
|
||||
yield ['https://test.de/picture.png?test=fdsj&width=34', true];
|
||||
yield ['https://invalid.invalid/file.txt', false];
|
||||
yield ['http://infsf.inda/file.zip?test', false];
|
||||
yield ['https://test.de', true];
|
||||
yield ['https://invalid.com/invalid/pic', true];
|
||||
yield ['%MEDIA%/foo/bar.jpeg', true];
|
||||
yield ['%MEDIA%/foo/bar.webp', true];
|
||||
yield ['%MEDIA%/foo', false];
|
||||
yield ['%SECURE%/foo.txt/test', false];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -204,16 +192,14 @@ class AttachmentTest extends TestCase
|
|||
$this->assertSame($expected, $attachment->isPicture());
|
||||
}
|
||||
|
||||
public function builtinDataProvider(): array
|
||||
public function builtinDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['', false],
|
||||
['%MEDIA%/foo/bar.txt', false],
|
||||
['%BASE%/foo/bar.txt', false],
|
||||
['/', false],
|
||||
['https://google.de', false],
|
||||
['%FOOTPRINTS%/foo/bar.txt', true],
|
||||
];
|
||||
yield ['', false];
|
||||
yield ['%MEDIA%/foo/bar.txt', false];
|
||||
yield ['%BASE%/foo/bar.txt', false];
|
||||
yield ['/', false];
|
||||
yield ['https://google.de', false];
|
||||
yield ['%FOOTPRINTS%/foo/bar.txt', true];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -226,13 +212,11 @@ class AttachmentTest extends TestCase
|
|||
$this->assertSame($expected, $attachment->isBuiltIn());
|
||||
}
|
||||
|
||||
public function hostDataProvider(): array
|
||||
public function hostDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['%MEDIA%/foo/bar.txt', null],
|
||||
['https://www.google.de/test.txt', 'www.google.de'],
|
||||
['https://foo.bar/test?txt=test', 'foo.bar'],
|
||||
];
|
||||
yield ['%MEDIA%/foo/bar.txt', null];
|
||||
yield ['https://www.google.de/test.txt', 'www.google.de'];
|
||||
yield ['https://foo.bar/test?txt=test', 'foo.bar'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,13 +229,11 @@ class AttachmentTest extends TestCase
|
|||
$this->assertSame($expected, $attachment->getHost());
|
||||
}
|
||||
|
||||
public function filenameProvider(): array
|
||||
public function filenameProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['%MEDIA%/foo/bar.txt', null, 'bar.txt'],
|
||||
['%MEDIA%/foo/bar.JPeg', 'test.txt', 'test.txt'],
|
||||
['https://www.google.de/test.txt', null, null],
|
||||
];
|
||||
yield ['%MEDIA%/foo/bar.txt', null, 'bar.txt'];
|
||||
yield ['%MEDIA%/foo/bar.JPeg', 'test.txt', 'test.txt'];
|
||||
yield ['https://www.google.de/test.txt', null, null];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\LogSystem;
|
||||
|
||||
use App\Entity\LogSystem\LogLevel;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\LogSystem;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
|
|
|
@ -46,29 +46,25 @@ use PHPUnit\Framework\TestCase;
|
|||
|
||||
class PartParameterTest extends TestCase
|
||||
{
|
||||
public function valueWithUnitDataProvider(): array
|
||||
public function valueWithUnitDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['1', 1.0, ''],
|
||||
['1 V', 1.0, 'V'],
|
||||
['1.23', 1.23, ''],
|
||||
['1.23 V', 1.23, 'V'],
|
||||
];
|
||||
yield ['1', 1.0, ''];
|
||||
yield ['1 V', 1.0, 'V'];
|
||||
yield ['1.23', 1.23, ''];
|
||||
yield ['1.23 V', 1.23, 'V'];
|
||||
}
|
||||
|
||||
public function formattedValueDataProvider(): array
|
||||
public function formattedValueDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['Text Test', null, null, null, 'V', 'Text Test'],
|
||||
['10.23 V', null, 10.23, null, 'V', ''],
|
||||
['10.23 V [Text]', null, 10.23, null, 'V', 'Text'],
|
||||
['max. 10.23 V', null, null, 10.23, 'V', ''],
|
||||
['max. 10.23 [Text]', null, null, 10.23, '', 'Text'],
|
||||
['min. 10.23 V', 10.23, null, null, 'V', ''],
|
||||
['10.23 V ... 11 V', 10.23, null, 11, 'V', ''],
|
||||
['10.23 V (9 V ... 11 V)', 9, 10.23, 11, 'V', ''],
|
||||
['10.23 V (9 V ... 11 V) [Test]', 9, 10.23, 11, 'V', 'Test'],
|
||||
];
|
||||
yield ['Text Test', null, null, null, 'V', 'Text Test'];
|
||||
yield ['10.23 V', null, 10.23, null, 'V', ''];
|
||||
yield ['10.23 V [Text]', null, 10.23, null, 'V', 'Text'];
|
||||
yield ['max. 10.23 V', null, null, 10.23, 'V', ''];
|
||||
yield ['max. 10.23 [Text]', null, null, 10.23, '', 'Text'];
|
||||
yield ['min. 10.23 V', 10.23, null, null, 'V', ''];
|
||||
yield ['10.23 V ... 11 V', 10.23, null, 11, 'V', ''];
|
||||
yield ['10.23 V (9 V ... 11 V)', 9, 10.23, 11, 'V', ''];
|
||||
yield ['10.23 V (9 V ... 11 V) [Test]', 9, 10.23, 11, 'V', 'Test'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\Parts;
|
||||
|
||||
use App\Entity\Parts\InfoProviderReference;
|
||||
|
@ -46,9 +48,9 @@ class InfoProviderReferenceTest extends TestCase
|
|||
//The provider reference instance should return true for the providerCreated method
|
||||
$this->assertTrue($provider->isProviderCreated());
|
||||
//And the correct values for all other methods
|
||||
$this->assertEquals('test', $provider->getProviderKey());
|
||||
$this->assertEquals('id', $provider->getProviderId());
|
||||
$this->assertEquals('url', $provider->getProviderUrl());
|
||||
$this->assertSame('test', $provider->getProviderKey());
|
||||
$this->assertSame('id', $provider->getProviderId());
|
||||
$this->assertSame('url', $provider->getProviderUrl());
|
||||
$this->assertNotNull($provider->getLastUpdated());
|
||||
}
|
||||
|
||||
|
@ -60,9 +62,9 @@ class InfoProviderReferenceTest extends TestCase
|
|||
//The provider reference instance should return true for the providerCreated method
|
||||
$this->assertTrue($reference->isProviderCreated());
|
||||
//And the correct values for all other methods
|
||||
$this->assertEquals('test', $reference->getProviderKey());
|
||||
$this->assertEquals('id', $reference->getProviderId());
|
||||
$this->assertEquals('url', $reference->getProviderUrl());
|
||||
$this->assertSame('test', $reference->getProviderKey());
|
||||
$this->assertSame('id', $reference->getProviderId());
|
||||
$this->assertSame('url', $reference->getProviderUrl());
|
||||
$this->assertNotNull($reference->getLastUpdated());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\Parts;
|
||||
|
||||
use App\Entity\Parts\AssociationType;
|
||||
|
@ -34,7 +36,7 @@ class PartAssociationTest extends TestCase
|
|||
$assoc->setOtherType('Custom Type');
|
||||
|
||||
//If the type is not OTHER the translation key should be the same as the type
|
||||
$this->assertEquals($assoc->getType()->getTranslationKey(), $assoc->getTypeTranslationKey());
|
||||
$this->assertSame($assoc->getType()->getTranslationKey(), $assoc->getTypeTranslationKey());
|
||||
|
||||
//If the type is OTHER the translation key should be the other type
|
||||
$assoc->setType(AssociationType::OTHER);
|
||||
|
|
|
@ -55,15 +55,15 @@ class PartTest extends TestCase
|
|||
|
||||
//Without a set measurement unit the part must return an int
|
||||
$part->setMinAmount(1.345);
|
||||
$this->assertSame(1.0, $part->getMinAmount());
|
||||
$this->assertEqualsWithDelta(1.0, $part->getMinAmount(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//If a non-int-based unit is assigned, a float is returned
|
||||
$part->setPartUnit($measurement_unit);
|
||||
$this->assertSame(1.345, $part->getMinAmount());
|
||||
$this->assertEqualsWithDelta(1.345, $part->getMinAmount(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//If an int-based unit is assigned an int is returned
|
||||
$measurement_unit->setIsInteger(true);
|
||||
$this->assertSame(1.0, $part->getMinAmount());
|
||||
$this->assertEqualsWithDelta(1.0, $part->getMinAmount(), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
|
||||
public function testUseFloatAmount(): void
|
||||
|
@ -87,7 +87,7 @@ class PartTest extends TestCase
|
|||
$measurement_unit = new MeasurementUnit();
|
||||
$datetime = new DateTime();
|
||||
|
||||
$this->assertSame(0.0, $part->getAmountSum());
|
||||
$this->assertEqualsWithDelta(0.0, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
|
||||
$part->addPartLot((new PartLot())->setAmount(3.141));
|
||||
$part->addPartLot((new PartLot())->setAmount(10.0));
|
||||
|
@ -98,15 +98,15 @@ class PartTest extends TestCase
|
|||
->setExpirationDate($datetime->setTimestamp(strtotime('now -1 hour')))
|
||||
);
|
||||
|
||||
$this->assertSame(13.0, $part->getAmountSum());
|
||||
$this->assertEqualsWithDelta(13.0, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
|
||||
$part->setPartUnit($measurement_unit);
|
||||
$this->assertSame(13.141, $part->getAmountSum());
|
||||
$this->assertEqualsWithDelta(13.141, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//1 billion part lot
|
||||
$part->addPartLot((new PartLot())->setAmount(1_000_000_000));
|
||||
$this->assertSame(1_000_000_013.141, $part->getAmountSum());
|
||||
$this->assertEqualsWithDelta(1_000_000_013.141, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
$measurement_unit->setIsInteger(true);
|
||||
$this->assertSame(1_000_000_013.0, $part->getAmountSum());
|
||||
$this->assertEqualsWithDelta(1_000_000_013.0, $part->getAmountSum(), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,18 +60,18 @@ class PricedetailTest extends TestCase
|
|||
$orderdetail2->method('getPart')->willReturn($part2);
|
||||
|
||||
//By default a price detail returns 1
|
||||
$this->assertSame(1.0, $pricedetail->getPriceRelatedQuantity());
|
||||
$this->assertEqualsWithDelta(1.0, $pricedetail->getPriceRelatedQuantity(), PHP_FLOAT_EPSILON);
|
||||
|
||||
$pricedetail->setOrderdetail($orderdetail);
|
||||
$pricedetail->setPriceRelatedQuantity(10.23);
|
||||
$this->assertSame(10.0, $pricedetail->getPriceRelatedQuantity());
|
||||
$this->assertEqualsWithDelta(10.0, $pricedetail->getPriceRelatedQuantity(), PHP_FLOAT_EPSILON);
|
||||
//Price related quantity must not be zero!
|
||||
$pricedetail->setPriceRelatedQuantity(0.23);
|
||||
$this->assertSame(1.0, $pricedetail->getPriceRelatedQuantity());
|
||||
$this->assertEqualsWithDelta(1.0, $pricedetail->getPriceRelatedQuantity(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//With a part that has a float amount unit, also values like 0.23 can be returned
|
||||
$pricedetail->setOrderdetail($orderdetail2);
|
||||
$this->assertSame(0.23, $pricedetail->getPriceRelatedQuantity());
|
||||
$this->assertEqualsWithDelta(0.23, $pricedetail->getPriceRelatedQuantity(), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
|
||||
public function testGetMinDiscountQuantity(): void
|
||||
|
@ -88,17 +88,17 @@ class PricedetailTest extends TestCase
|
|||
$orderdetail2->method('getPart')->willReturn($part2);
|
||||
|
||||
//By default a price detail returns 1
|
||||
$this->assertSame(1.0, $pricedetail->getMinDiscountQuantity());
|
||||
$this->assertEqualsWithDelta(1.0, $pricedetail->getMinDiscountQuantity(), PHP_FLOAT_EPSILON);
|
||||
|
||||
$pricedetail->setOrderdetail($orderdetail);
|
||||
$pricedetail->setMinDiscountQuantity(10.23);
|
||||
$this->assertSame(10.0, $pricedetail->getMinDiscountQuantity());
|
||||
$this->assertEqualsWithDelta(10.0, $pricedetail->getMinDiscountQuantity(), PHP_FLOAT_EPSILON);
|
||||
//Price related quantity must not be zero!
|
||||
$pricedetail->setMinDiscountQuantity(0.23);
|
||||
$this->assertSame(1.0, $pricedetail->getMinDiscountQuantity());
|
||||
$this->assertEqualsWithDelta(1.0, $pricedetail->getMinDiscountQuantity(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//With a part that has a float amount unit, also values like 0.23 can be returned
|
||||
$pricedetail->setOrderdetail($orderdetail2);
|
||||
$this->assertSame(0.23, $pricedetail->getMinDiscountQuantity());
|
||||
$this->assertEqualsWithDelta(0.23, $pricedetail->getMinDiscountQuantity(), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Entity\UserSystem;
|
||||
|
||||
use App\Entity\UserSystem\ApiTokenType;
|
||||
|
@ -28,7 +30,7 @@ class ApiTokenTypeTest extends TestCase
|
|||
|
||||
public function testGetTokenPrefix(): void
|
||||
{
|
||||
$this->assertEquals('tcp_', ApiTokenType::PERSONAL_ACCESS_TOKEN->getTokenPrefix());
|
||||
$this->assertSame('tcp_', ApiTokenType::PERSONAL_ACCESS_TOKEN->getTokenPrefix());
|
||||
}
|
||||
|
||||
public function testGetTypeFromToken(): void
|
||||
|
|
|
@ -45,13 +45,11 @@ class UserTest extends TestCase
|
|||
$this->assertSame('John (@username)', $user->getFullName(true));
|
||||
}
|
||||
|
||||
public function googleAuthenticatorEnabledDataProvider(): array
|
||||
public function googleAuthenticatorEnabledDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
[null, false],
|
||||
['', false],
|
||||
['SSSk38498', true],
|
||||
];
|
||||
yield [null, false];
|
||||
yield ['', false];
|
||||
yield ['SSSk38498', true];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -120,11 +120,11 @@ class ProjectBuildRequestTest extends TestCase
|
|||
//The values should be already prefilled correctly
|
||||
$request = new ProjectBuildRequest($this->project1, 10);
|
||||
//We need totally 20: Take 10 from the first (maximum 10) and 10 from the second (maximum 20)
|
||||
$this->assertSame(10.0, $request->getLotWithdrawAmount($this->lot1a));
|
||||
$this->assertSame(10.0, $request->getLotWithdrawAmount($this->lot1b));
|
||||
$this->assertEqualsWithDelta(10.0, $request->getLotWithdrawAmount($this->lot1a), PHP_FLOAT_EPSILON);
|
||||
$this->assertEqualsWithDelta(10.0, $request->getLotWithdrawAmount($this->lot1b), PHP_FLOAT_EPSILON);
|
||||
|
||||
//If the needed amount is higher than the maximum, we should get the maximum
|
||||
$this->assertSame(2.5, $request->getLotWithdrawAmount($this->lot2));
|
||||
$this->assertEqualsWithDelta(2.5, $request->getLotWithdrawAmount($this->lot2), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
|
||||
public function testGetNumberOfBuilds(): void
|
||||
|
@ -142,9 +142,9 @@ class ProjectBuildRequestTest extends TestCase
|
|||
public function testGetNeededAmountForBOMEntry(): void
|
||||
{
|
||||
$build_request = new ProjectBuildRequest($this->project1, 5);
|
||||
$this->assertSame(10.0, $build_request->getNeededAmountForBOMEntry($this->bom_entry1a));
|
||||
$this->assertSame(7.5, $build_request->getNeededAmountForBOMEntry($this->bom_entry1b));
|
||||
$this->assertSame(20.0, $build_request->getNeededAmountForBOMEntry($this->bom_entry1c));
|
||||
$this->assertEqualsWithDelta(10.0, $build_request->getNeededAmountForBOMEntry($this->bom_entry1a), PHP_FLOAT_EPSILON);
|
||||
$this->assertEqualsWithDelta(7.5, $build_request->getNeededAmountForBOMEntry($this->bom_entry1b), PHP_FLOAT_EPSILON);
|
||||
$this->assertEqualsWithDelta(20.0, $build_request->getNeededAmountForBOMEntry($this->bom_entry1c), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
|
||||
public function testGetSetLotWithdrawAmount(): void
|
||||
|
@ -156,8 +156,8 @@ class ProjectBuildRequestTest extends TestCase
|
|||
$build_request->setLotWithdrawAmount($this->lot1b->getID(), 3);
|
||||
|
||||
//And it should be possible to get the amount via the lot object or via the ID
|
||||
$this->assertSame(2.0, $build_request->getLotWithdrawAmount($this->lot1a->getID()));
|
||||
$this->assertSame(3.0, $build_request->getLotWithdrawAmount($this->lot1b));
|
||||
$this->assertEqualsWithDelta(2.0, $build_request->getLotWithdrawAmount($this->lot1a->getID()), PHP_FLOAT_EPSILON);
|
||||
$this->assertEqualsWithDelta(3.0, $build_request->getLotWithdrawAmount($this->lot1b), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
|
||||
public function testGetWithdrawAmountSum(): void
|
||||
|
@ -168,9 +168,9 @@ class ProjectBuildRequestTest extends TestCase
|
|||
$build_request->setLotWithdrawAmount($this->lot1a, 2);
|
||||
$build_request->setLotWithdrawAmount($this->lot1b, 3);
|
||||
|
||||
$this->assertSame(5.0, $build_request->getWithdrawAmountSum($this->bom_entry1a));
|
||||
$this->assertEqualsWithDelta(5.0, $build_request->getWithdrawAmountSum($this->bom_entry1a), PHP_FLOAT_EPSILON);
|
||||
$build_request->setLotWithdrawAmount($this->lot2, 1.5);
|
||||
$this->assertSame(1.5, $build_request->getWithdrawAmountSum($this->bom_entry1b));
|
||||
$this->assertEqualsWithDelta(1.5, $build_request->getWithdrawAmountSum($this->bom_entry1b), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Helpers;
|
||||
|
||||
use App\Helpers\TrinaryLogicHelper;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Repository;
|
||||
|
||||
use App\Entity\Parts\Category;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Repository;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Repository;
|
||||
|
||||
use App\Entity\UserSystem\User;
|
||||
|
|
|
@ -110,7 +110,7 @@ class PartNormalizerTest extends WebTestCase
|
|||
$this->assertCount(1, $part->getPartLots());
|
||||
/** @var PartLot $partLot */
|
||||
$partLot = $part->getPartLots()->first();
|
||||
$this->assertSame(5.0, $partLot->getAmount());
|
||||
$this->assertEqualsWithDelta(5.0, $partLot->getAmount(), PHP_FLOAT_EPSILON);
|
||||
$this->assertNotNull($partLot->getStorageLocation());
|
||||
$this->assertSame('Test Storage Location', $partLot->getStorageLocation()->getName());
|
||||
|
||||
|
@ -130,7 +130,7 @@ class PartNormalizerTest extends WebTestCase
|
|||
//Must be in base currency
|
||||
$this->assertNull($priceDetail->getCurrency());
|
||||
//Must be for 1 part and 1 minimum order quantity
|
||||
$this->assertSame(1.0, $priceDetail->getPriceRelatedQuantity());
|
||||
$this->assertSame(1.0, $priceDetail->getMinDiscountQuantity());
|
||||
$this->assertEqualsWithDelta(1.0, $priceDetail->getPriceRelatedQuantity(), PHP_FLOAT_EPSILON);
|
||||
$this->assertEqualsWithDelta(1.0, $priceDetail->getMinDiscountQuantity(), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ class AttachmentPathResolverTest extends WebTestCase
|
|||
$this->assertNull($this->service->parameterToAbsolutePath('/./this/one/too'));
|
||||
}
|
||||
|
||||
public function placeholderDataProvider(): array
|
||||
public function placeholderDataProvider(): \Iterator
|
||||
{
|
||||
//We need to do initialization (again), as dataprovider is called before setUp()
|
||||
self::bootKernel();
|
||||
|
@ -77,28 +77,28 @@ class AttachmentPathResolverTest extends WebTestCase
|
|||
$this->projectDir = str_replace('\\', '/', $this->projectDir_orig);
|
||||
$this->media_path = $this->projectDir.'/public/media';
|
||||
$this->footprint_path = $this->projectDir.'/public/img/footprints';
|
||||
|
||||
return [
|
||||
['%FOOTPRINTS%/test/test.jpg', $this->footprint_path.'/test/test.jpg'],
|
||||
['%FOOTPRINTS%/test/', $this->footprint_path.'/test/'],
|
||||
['%MEDIA%/test', $this->media_path.'/test'],
|
||||
['%MEDIA%', $this->media_path],
|
||||
['%FOOTPRINTS%', $this->footprint_path],
|
||||
//Footprints 3D are disabled
|
||||
['%FOOTPRINTS_3D%', null],
|
||||
//Check that invalid pathes return null
|
||||
['/no/placeholder', null],
|
||||
['%INVALID_PLACEHOLDER%', null],
|
||||
['%FOOTPRINTS/test/', null], //Malformed placeholder
|
||||
['/wrong/%FOOTRPINTS%/', null], //Placeholder not at beginning
|
||||
['%FOOTPRINTS%/%MEDIA%', null], //No more than one placholder
|
||||
['%FOOTPRINTS%/%FOOTPRINTS%', null],
|
||||
['%FOOTPRINTS%/../../etc/passwd', null],
|
||||
['%FOOTPRINTS%/0\..\test', null],
|
||||
];
|
||||
yield ['%FOOTPRINTS%/test/test.jpg', $this->footprint_path.'/test/test.jpg'];
|
||||
yield ['%FOOTPRINTS%/test/', $this->footprint_path.'/test/'];
|
||||
yield ['%MEDIA%/test', $this->media_path.'/test'];
|
||||
yield ['%MEDIA%', $this->media_path];
|
||||
yield ['%FOOTPRINTS%', $this->footprint_path];
|
||||
//Footprints 3D are disabled
|
||||
yield ['%FOOTPRINTS_3D%', null];
|
||||
//Check that invalid pathes return null
|
||||
yield ['/no/placeholder', null];
|
||||
yield ['%INVALID_PLACEHOLDER%', null];
|
||||
yield ['%FOOTPRINTS/test/', null];
|
||||
//Malformed placeholder
|
||||
yield ['/wrong/%FOOTRPINTS%/', null];
|
||||
//Placeholder not at beginning
|
||||
yield ['%FOOTPRINTS%/%MEDIA%', null];
|
||||
//No more than one placholder
|
||||
yield ['%FOOTPRINTS%/%FOOTPRINTS%', null];
|
||||
yield ['%FOOTPRINTS%/../../etc/passwd', null];
|
||||
yield ['%FOOTPRINTS%/0\..\test', null];
|
||||
}
|
||||
|
||||
public function realPathDataProvider(): array
|
||||
public function realPathDataProvider(): \Iterator
|
||||
{
|
||||
//We need to do initialization (again), as dataprovider is called before setUp()
|
||||
self::bootKernel();
|
||||
|
@ -106,20 +106,17 @@ class AttachmentPathResolverTest extends WebTestCase
|
|||
$this->projectDir = str_replace('\\', '/', $this->projectDir_orig);
|
||||
$this->media_path = $this->projectDir.'/public/media';
|
||||
$this->footprint_path = $this->projectDir.'/public/img/footprints';
|
||||
|
||||
return [
|
||||
[$this->media_path.'/test/img.jpg', '%MEDIA%/test/img.jpg'],
|
||||
[$this->media_path.'/test/img.jpg', '%BASE%/data/media/test/img.jpg', true],
|
||||
[$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg'],
|
||||
[$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg', true],
|
||||
//Every kind of absolute path, that is not based with our placeholder dirs must be invald
|
||||
['/etc/passwd', null],
|
||||
['C:\\not\\existing.txt', null],
|
||||
//More than one placeholder is not allowed
|
||||
[$this->footprint_path.'/test/'.$this->footprint_path, null],
|
||||
//Path must begin with path
|
||||
['/not/root'.$this->footprint_path, null],
|
||||
];
|
||||
yield [$this->media_path.'/test/img.jpg', '%MEDIA%/test/img.jpg'];
|
||||
yield [$this->media_path.'/test/img.jpg', '%BASE%/data/media/test/img.jpg', true];
|
||||
yield [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg'];
|
||||
yield [$this->footprint_path.'/foo.jpg', '%FOOTPRINTS%/foo.jpg', true];
|
||||
//Every kind of absolute path, that is not based with our placeholder dirs must be invald
|
||||
yield ['/etc/passwd', null];
|
||||
yield ['C:\\not\\existing.txt', null];
|
||||
//More than one placeholder is not allowed
|
||||
yield [$this->footprint_path.'/test/'.$this->footprint_path, null];
|
||||
//Path must begin with path
|
||||
yield ['/not/root'.$this->footprint_path, null];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,56 +35,52 @@ class FileTypeFilterToolsTest extends WebTestCase
|
|||
self::$service = self::getContainer()->get(FileTypeFilterTools::class);
|
||||
}
|
||||
|
||||
public function validateDataProvider(): array
|
||||
public function validateDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['', true], //Empty string is valid
|
||||
['.jpeg,.png, .gif', true], //Only extensions are valid
|
||||
['image/*, video/*, .mp4, video/x-msvideo, application/vnd.amazon.ebook', true],
|
||||
['application/vnd.amazon.ebook, audio/opus', true],
|
||||
|
||||
['*.notvalid, .png', false], //No stars in extension
|
||||
['test.png', false], //No full filename
|
||||
['application/*', false], //Only certain placeholders are allowed
|
||||
['.png;.png,.jpg', false], //Wrong separator
|
||||
['.png .jpg .gif', false],
|
||||
];
|
||||
yield ['', true];
|
||||
//Empty string is valid
|
||||
yield ['.jpeg,.png, .gif', true];
|
||||
//Only extensions are valid
|
||||
yield ['image/*, video/*, .mp4, video/x-msvideo, application/vnd.amazon.ebook', true];
|
||||
yield ['application/vnd.amazon.ebook, audio/opus', true];
|
||||
yield ['*.notvalid, .png', false];
|
||||
//No stars in extension
|
||||
yield ['test.png', false];
|
||||
//No full filename
|
||||
yield ['application/*', false];
|
||||
//Only certain placeholders are allowed
|
||||
yield ['.png;.png,.jpg', false];
|
||||
//Wrong separator
|
||||
yield ['.png .jpg .gif', false];
|
||||
}
|
||||
|
||||
public function normalizeDataProvider(): array
|
||||
public function normalizeDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['', ''],
|
||||
['.jpeg,.png,.gif', '.jpeg,.png,.gif'],
|
||||
['.jpeg, .png, .gif,', '.jpeg,.png,.gif'],
|
||||
['jpg, *.gif', '.jpg,.gif'],
|
||||
['video, image/', 'video/*,image/*'],
|
||||
['video/*', 'video/*'],
|
||||
['video/x-msvideo,.jpeg', 'video/x-msvideo,.jpeg'],
|
||||
['.video', '.video'],
|
||||
//Remove duplicate entries
|
||||
['png, .gif, .png,', '.png,.gif'],
|
||||
];
|
||||
yield ['', ''];
|
||||
yield ['.jpeg,.png,.gif', '.jpeg,.png,.gif'];
|
||||
yield ['.jpeg, .png, .gif,', '.jpeg,.png,.gif'];
|
||||
yield ['jpg, *.gif', '.jpg,.gif'];
|
||||
yield ['video, image/', 'video/*,image/*'];
|
||||
yield ['video/*', 'video/*'];
|
||||
yield ['video/x-msvideo,.jpeg', 'video/x-msvideo,.jpeg'];
|
||||
yield ['.video', '.video'];
|
||||
//Remove duplicate entries
|
||||
yield ['png, .gif, .png,', '.png,.gif'];
|
||||
}
|
||||
|
||||
public function extensionAllowedDataProvider(): array
|
||||
public function extensionAllowedDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['', 'txt', true],
|
||||
['', 'everything_should_match', true],
|
||||
|
||||
['.jpg,.png', 'jpg', true],
|
||||
['.jpg,.png', 'png', true],
|
||||
['.jpg,.png', 'txt', false],
|
||||
|
||||
['image/*', 'jpeg', true],
|
||||
['image/*', 'png', true],
|
||||
['image/*', 'txt', false],
|
||||
|
||||
['application/pdf,.txt', 'pdf', true],
|
||||
['application/pdf,.txt', 'txt', true],
|
||||
['application/pdf,.txt', 'jpg', false],
|
||||
];
|
||||
yield ['', 'txt', true];
|
||||
yield ['', 'everything_should_match', true];
|
||||
yield ['.jpg,.png', 'jpg', true];
|
||||
yield ['.jpg,.png', 'png', true];
|
||||
yield ['.jpg,.png', 'txt', false];
|
||||
yield ['image/*', 'jpeg', true];
|
||||
yield ['image/*', 'png', true];
|
||||
yield ['image/*', 'txt', false];
|
||||
yield ['application/pdf,.txt', 'pdf', true];
|
||||
yield ['application/pdf,.txt', 'txt', true];
|
||||
yield ['application/pdf,.txt', 'jpg', false];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\EntityMergers\Mergers;
|
||||
|
||||
use App\Entity\Parts\Part;
|
||||
|
|
|
@ -37,7 +37,7 @@ class MergeTestClass
|
|||
|
||||
public Collection $collection;
|
||||
|
||||
public ?Category $category;
|
||||
public ?Category $category = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\EntityMergers\Mergers;
|
||||
|
||||
use App\Entity\Parts\AssociationType;
|
||||
|
|
|
@ -84,7 +84,7 @@ class BOMImporterTest extends WebTestCase
|
|||
$this->assertCount(4, $bom);
|
||||
|
||||
$this->assertSame('R19,R17', $bom[0]->getMountnames());
|
||||
$this->assertSame(2.0, $bom[0]->getQuantity());
|
||||
$this->assertEqualsWithDelta(2.0, $bom[0]->getQuantity(), PHP_FLOAT_EPSILON);
|
||||
$this->assertSame('4.7k (R_0805_2012Metric_Pad1.20x1.40mm_HandSolder)', $bom[0]->getName());
|
||||
$this->assertSame('Test', $bom[0]->getComment());
|
||||
|
||||
|
@ -103,7 +103,7 @@ class BOMImporterTest extends WebTestCase
|
|||
$this->assertCount(4, $bom);
|
||||
|
||||
$this->assertSame('R19,R17', $bom[0]->getMountnames());
|
||||
$this->assertSame(2.0, $bom[0]->getQuantity());
|
||||
$this->assertEqualsWithDelta(2.0, $bom[0]->getQuantity(), PHP_FLOAT_EPSILON);
|
||||
$this->assertSame('4.7k (R_0805_2012Metric_Pad1.20x1.40mm_HandSolder)', $bom[0]->getName());
|
||||
$this->assertSame('Test', $bom[0]->getComment());
|
||||
}
|
||||
|
|
|
@ -172,16 +172,14 @@ EOT;
|
|||
$this->assertSame($longName, $errors[0]['entity']->getName());
|
||||
}
|
||||
|
||||
public function formatDataProvider(): array
|
||||
public function formatDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['csv', 'csv'],
|
||||
['csv', 'CSV'],
|
||||
['xml', 'Xml'],
|
||||
['json', 'json'],
|
||||
['yaml', 'yml'],
|
||||
['yaml', 'YAML'],
|
||||
];
|
||||
yield ['csv', 'csv'];
|
||||
yield ['csv', 'CSV'];
|
||||
yield ['xml', 'Xml'];
|
||||
yield ['json', 'json'];
|
||||
yield ['yaml', 'yml'];
|
||||
yield ['yaml', 'YAML'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\InfoProviderSystem\DTOs;
|
||||
|
||||
use App\Services\InfoProviderSystem\DTOs\ParameterDTO;
|
||||
|
@ -241,18 +243,18 @@ class ParameterDTOTest extends TestCase
|
|||
|
||||
public function testSplitIntoValueAndUnit(): void
|
||||
{
|
||||
$this->assertEquals(['1.0', 'kg'], ParameterDTO::splitIntoValueAndUnit('1.0 kg'));
|
||||
$this->assertEquals(['1.0', 'kg'], ParameterDTO::splitIntoValueAndUnit('1.0kg'));
|
||||
$this->assertEquals(['1', 'kg'], ParameterDTO::splitIntoValueAndUnit('1 kg'));
|
||||
$this->assertSame(['1.0', 'kg'], ParameterDTO::splitIntoValueAndUnit('1.0 kg'));
|
||||
$this->assertSame(['1.0', 'kg'], ParameterDTO::splitIntoValueAndUnit('1.0kg'));
|
||||
$this->assertSame(['1', 'kg'], ParameterDTO::splitIntoValueAndUnit('1 kg'));
|
||||
|
||||
$this->assertEquals(['1.0', '°C'], ParameterDTO::splitIntoValueAndUnit('1.0°C'));
|
||||
$this->assertEquals(['1.0', '°C'], ParameterDTO::splitIntoValueAndUnit('1.0 °C'));
|
||||
$this->assertSame(['1.0', '°C'], ParameterDTO::splitIntoValueAndUnit('1.0°C'));
|
||||
$this->assertSame(['1.0', '°C'], ParameterDTO::splitIntoValueAndUnit('1.0 °C'));
|
||||
|
||||
$this->assertEquals(['1.0', 'C_m'], ParameterDTO::splitIntoValueAndUnit('1.0C_m'));
|
||||
$this->assertEquals(["70", "℃"], ParameterDTO::splitIntoValueAndUnit("70℃"));
|
||||
$this->assertSame(['1.0', 'C_m'], ParameterDTO::splitIntoValueAndUnit('1.0C_m'));
|
||||
$this->assertSame(["70", "℃"], ParameterDTO::splitIntoValueAndUnit("70℃"));
|
||||
|
||||
$this->assertEquals(["-5.0", "kg"], ParameterDTO::splitIntoValueAndUnit("-5.0 kg"));
|
||||
$this->assertEquals(["-5.0", "µg"], ParameterDTO::splitIntoValueAndUnit("-5.0 µg"));
|
||||
$this->assertSame(["-5.0", "kg"], ParameterDTO::splitIntoValueAndUnit("-5.0 kg"));
|
||||
$this->assertSame(["-5.0", "µg"], ParameterDTO::splitIntoValueAndUnit("-5.0 µg"));
|
||||
|
||||
$this->assertNull(ParameterDTO::splitIntoValueAndUnit('kg'));
|
||||
$this->assertNull(ParameterDTO::splitIntoValueAndUnit('Test'));
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\InfoProviderSystem\DTOs;
|
||||
|
||||
use App\Services\InfoProviderSystem\DTOs\PurchaseInfoDTO;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\InfoProviderSystem\DTOs;
|
||||
|
||||
use App\Services\InfoProviderSystem\DTOs\SearchResultDTO;
|
||||
|
@ -45,8 +47,8 @@ class SearchResultDTOTest extends TestCase
|
|||
'description',
|
||||
preview_image_url: 'https://invalid.com/preview_image_url.jpg'
|
||||
);
|
||||
$this->assertEquals('https://invalid.com/preview_image_url.jpg', $searchResultDTO->preview_image_url);
|
||||
$this->assertEquals('https://invalid.com/preview_image_url.jpg', $searchResultDTO->preview_image_file->url);
|
||||
$this->assertSame('https://invalid.com/preview_image_url.jpg', $searchResultDTO->preview_image_url);
|
||||
$this->assertSame('https://invalid.com/preview_image_url.jpg', $searchResultDTO->preview_image_file->url);
|
||||
|
||||
//Invalid url characters should be replaced with their URL encoded version (similar to FileDTO)
|
||||
$searchResultDTO = new SearchResultDTO(
|
||||
|
@ -56,7 +58,7 @@ class SearchResultDTOTest extends TestCase
|
|||
'description',
|
||||
preview_image_url: 'https://invalid.com/preview_image^url.jpg?param1=1¶m2=2'
|
||||
);
|
||||
$this->assertEquals('https://invalid.com/preview_image%5Eurl.jpg?param1=1¶m2=2', $searchResultDTO->preview_image_url);
|
||||
$this->assertEquals('https://invalid.com/preview_image%5Eurl.jpg?param1=1¶m2=2', $searchResultDTO->preview_image_file->url);
|
||||
$this->assertSame('https://invalid.com/preview_image%5Eurl.jpg?param1=1¶m2=2', $searchResultDTO->preview_image_url);
|
||||
$this->assertSame('https://invalid.com/preview_image%5Eurl.jpg?param1=1¶m2=2', $searchResultDTO->preview_image_file->url);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\InfoProviderSystem;
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
|
@ -53,7 +55,7 @@ class DTOtoEntityConverterTest extends WebTestCase
|
|||
|
||||
$entity = $this->service->convertParameter($dto);
|
||||
|
||||
$this->assertEquals($dto->name, $entity->getName());
|
||||
$this->assertSame($dto->name, $entity->getName());
|
||||
$this->assertEquals($dto->value_text, $entity->getValueText());
|
||||
$this->assertEquals($dto->value_typ, $entity->getValueTypical());
|
||||
$this->assertEquals($dto->value_min, $entity->getValueMin());
|
||||
|
@ -74,8 +76,8 @@ class DTOtoEntityConverterTest extends WebTestCase
|
|||
);
|
||||
|
||||
$entity = $this->service->convertPrice($dto);
|
||||
$this->assertEquals($dto->minimum_discount_amount, $entity->getMinDiscountQuantity());
|
||||
$this->assertEquals((float) $dto->price, (float) (string) $entity->getPrice());
|
||||
$this->assertSame($dto->minimum_discount_amount, $entity->getMinDiscountQuantity());
|
||||
$this->assertSame((float) $dto->price, (float) (string) $entity->getPrice());
|
||||
$this->assertEquals($dto->price_related_quantity, $entity->getPriceRelatedQuantity());
|
||||
|
||||
//For non-base currencies, a new currency entity is created
|
||||
|
@ -114,8 +116,8 @@ class DTOtoEntityConverterTest extends WebTestCase
|
|||
|
||||
$entity = $this->service->convertPurchaseInfo($dto);
|
||||
|
||||
$this->assertEquals($dto->distributor_name, $entity->getSupplier()->getName());
|
||||
$this->assertEquals($dto->order_number, $entity->getSupplierPartNr());
|
||||
$this->assertSame($dto->distributor_name, $entity->getSupplier()->getName());
|
||||
$this->assertSame($dto->order_number, $entity->getSupplierPartNr());
|
||||
$this->assertEquals($dto->product_url, $entity->getSupplierProductUrl());
|
||||
}
|
||||
|
||||
|
@ -128,7 +130,7 @@ class DTOtoEntityConverterTest extends WebTestCase
|
|||
$entity = $this->service->convertFile($dto, $type);
|
||||
|
||||
$this->assertEquals($dto->name, $entity->getName());
|
||||
$this->assertEquals($dto->url, $entity->getUrl());
|
||||
$this->assertSame($dto->url, $entity->getUrl());
|
||||
$this->assertEquals($type, $entity->getAttachmentType());
|
||||
}
|
||||
|
||||
|
@ -141,8 +143,8 @@ class DTOtoEntityConverterTest extends WebTestCase
|
|||
$entity = $this->service->convertFile($dto, $type);
|
||||
|
||||
//If no name is given, the name is derived from the url
|
||||
$this->assertEquals('file.pdf', $entity->getName());
|
||||
$this->assertEquals($dto->url, $entity->getUrl());
|
||||
$this->assertSame('file.pdf', $entity->getName());
|
||||
$this->assertSame($dto->url, $entity->getUrl());
|
||||
$this->assertEquals($type, $entity->getAttachmentType());
|
||||
}
|
||||
|
||||
|
@ -184,11 +186,11 @@ class DTOtoEntityConverterTest extends WebTestCase
|
|||
$this->assertCount(3, $entity->getAttachments());
|
||||
//The attachments should have the name of the named duplicate file
|
||||
$image1 = $entity->getAttachments()[0];
|
||||
$this->assertEquals('Main image', $image1->getName());
|
||||
$this->assertSame('Main image', $image1->getName());
|
||||
|
||||
$image1 = $entity->getAttachments()[1];
|
||||
|
||||
$datasheet = $entity->getAttachments()[2];
|
||||
$this->assertEquals('TestFile', $datasheet->getName());
|
||||
$this->assertSame('TestFile', $datasheet->getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\InfoProviderSystem;
|
||||
|
||||
use App\Services\InfoProviderSystem\ProviderRegistry;
|
||||
|
|
|
@ -57,22 +57,18 @@ class BarcodeContentGeneratorTest extends KernelTestCase
|
|||
$this->service = self::getContainer()->get(BarcodeContentGenerator::class);
|
||||
}
|
||||
|
||||
public function Barcode1DDataProvider(): array
|
||||
public function Barcode1DDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['P0000', Part::class],
|
||||
['L0000', PartLot::class],
|
||||
['S0000', StorageLocation::class],
|
||||
];
|
||||
yield ['P0000', Part::class];
|
||||
yield ['L0000', PartLot::class];
|
||||
yield ['S0000', StorageLocation::class];
|
||||
}
|
||||
|
||||
public function Barcode2DDataProvider(): array
|
||||
public function Barcode2DDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['/scan/part/0', Part::class],
|
||||
['/scan/lot/0', PartLot::class],
|
||||
['/scan/location/0', StorageLocation::class],
|
||||
];
|
||||
yield ['/scan/part/0', Part::class];
|
||||
yield ['/scan/lot/0', PartLot::class];
|
||||
yield ['/scan/location/0', StorageLocation::class];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\LabelSystem\Barcodes;
|
||||
|
||||
use App\Entity\LabelSystem\BarcodeType;
|
||||
|
|
|
@ -58,14 +58,12 @@ final class BarcodeRedirectorTest extends KernelTestCase
|
|||
$this->service = self::getContainer()->get(BarcodeRedirector::class);
|
||||
}
|
||||
|
||||
public static function urlDataProvider(): array
|
||||
public static function urlDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
[new BarcodeScanResult(LabelSupportedElement::PART, 1, BarcodeSourceType::INTERNAL), '/en/part/1'],
|
||||
//Part lot redirects to Part info page (Part lot 1 is associated with part 3)
|
||||
[new BarcodeScanResult(LabelSupportedElement::PART_LOT, 1, BarcodeSourceType::INTERNAL), '/en/part/3'],
|
||||
[new BarcodeScanResult(LabelSupportedElement::STORELOCATION, 1, BarcodeSourceType::INTERNAL), '/en/store_location/1/parts'],
|
||||
];
|
||||
yield [new BarcodeScanResult(LabelSupportedElement::PART, 1, BarcodeSourceType::INTERNAL), '/en/part/1'];
|
||||
//Part lot redirects to Part info page (Part lot 1 is associated with part 3)
|
||||
yield [new BarcodeScanResult(LabelSupportedElement::PART_LOT, 1, BarcodeSourceType::INTERNAL), '/en/part/3'];
|
||||
yield [new BarcodeScanResult(LabelSupportedElement::STORELOCATION, 1, BarcodeSourceType::INTERNAL), '/en/store_location/1/parts'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -113,16 +113,19 @@ class BarcodeScanHelperTest extends WebTestCase
|
|||
'lot2_vendor_barcode'];
|
||||
}
|
||||
|
||||
public static function invalidDataProvider(): array
|
||||
public static function invalidDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['https://localhost/part/1'], //Without scan
|
||||
['L-'], //Without number
|
||||
['L-123'], //Too short
|
||||
['X-123456'], //Unknown prefix
|
||||
['XXXWADSDF sdf'], //Garbage
|
||||
[''], //Empty
|
||||
];
|
||||
yield ['https://localhost/part/1'];
|
||||
//Without scan
|
||||
yield ['L-'];
|
||||
//Without number
|
||||
yield ['L-123'];
|
||||
//Too short
|
||||
yield ['X-123456'];
|
||||
//Unknown prefix
|
||||
yield ['XXXWADSDF sdf'];
|
||||
//Garbage
|
||||
yield [''];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,13 +63,11 @@ class LabelGeneratorTest extends WebTestCase
|
|||
$this->service = self::getContainer()->get(LabelGenerator::class);
|
||||
}
|
||||
|
||||
public static function supportsDataProvider(): array
|
||||
public static function supportsDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
[LabelSupportedElement::PART, Part::class],
|
||||
[LabelSupportedElement::PART_LOT, PartLot::class],
|
||||
[LabelSupportedElement::STORELOCATION, StorageLocation::class],
|
||||
];
|
||||
yield [LabelSupportedElement::PART, Part::class];
|
||||
yield [LabelSupportedElement::PART_LOT, PartLot::class];
|
||||
yield [LabelSupportedElement::STORELOCATION, StorageLocation::class];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -70,32 +70,28 @@ class LabelTextReplacerTest extends WebTestCase
|
|||
$this->target->setComment('P Comment');
|
||||
}
|
||||
|
||||
public function handlePlaceholderDataProvider(): array
|
||||
public function handlePlaceholderDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['Part 1', '[[NAME]]'],
|
||||
['P Description', '[[DESCRIPTION]]'],
|
||||
['[[UNKNOWN]]', '[[UNKNOWN]]', '[[UNKNOWN]]'],
|
||||
['[[INVALID', '[[INVALID'],
|
||||
['[[', '[['],
|
||||
['NAME', 'NAME'],
|
||||
['[[NAME', '[[NAME'],
|
||||
['Test [[NAME]]', 'Test [[NAME]]', 'Test [[NAME]]'],
|
||||
];
|
||||
yield ['Part 1', '[[NAME]]'];
|
||||
yield ['P Description', '[[DESCRIPTION]]'];
|
||||
yield ['[[UNKNOWN]]', '[[UNKNOWN]]', '[[UNKNOWN]]'];
|
||||
yield ['[[INVALID', '[[INVALID'];
|
||||
yield ['[[', '[['];
|
||||
yield ['NAME', 'NAME'];
|
||||
yield ['[[NAME', '[[NAME'];
|
||||
yield ['Test [[NAME]]', 'Test [[NAME]]', 'Test [[NAME]]'];
|
||||
}
|
||||
|
||||
public function replaceDataProvider(): array
|
||||
public function replaceDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['Part 1', '[[NAME]]'],
|
||||
['TestPart 1', 'Test[[NAME]]'],
|
||||
["P Description\nPart 1", "[[DESCRIPTION_T]]\n[[NAME]]"],
|
||||
['Part 1 Part 1', '[[NAME]] [[NAME]]'],
|
||||
['[[UNKNOWN]] Test', '[[UNKNOWN]] Test'],
|
||||
["[[NAME\n]] [[NAME ]]", "[[NAME\n]] [[NAME ]]"],
|
||||
['[[]]', '[[]]'],
|
||||
['TEST[[ ]]TEST', 'TEST[[ ]]TEST'],
|
||||
];
|
||||
yield ['Part 1', '[[NAME]]'];
|
||||
yield ['TestPart 1', 'Test[[NAME]]'];
|
||||
yield ["P Description\nPart 1", "[[DESCRIPTION_T]]\n[[NAME]]"];
|
||||
yield ['Part 1 Part 1', '[[NAME]] [[NAME]]'];
|
||||
yield ['[[UNKNOWN]] Test', '[[UNKNOWN]] Test'];
|
||||
yield ["[[NAME\n]] [[NAME ]]", "[[NAME\n]] [[NAME ]]"];
|
||||
yield ['[[]]', '[[]]'];
|
||||
yield ['TEST[[ ]]TEST', 'TEST[[ ]]TEST'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -61,50 +61,46 @@ class SandboxedTwigFactoryTest extends WebTestCase
|
|||
$this->service = self::getContainer()->get(SandboxedTwigFactory::class);
|
||||
}
|
||||
|
||||
public function twigDataProvider(): array
|
||||
public function twigDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
[' {% for i in range(1, 3) %}
|
||||
yield [' {% for i in range(1, 3) %}
|
||||
{{ part.id }}
|
||||
{{ part.name }}
|
||||
{{ part.lastModified | format_datetime }}
|
||||
{% endfor %}
|
||||
'],
|
||||
[' {% if part.category %}
|
||||
'];
|
||||
yield [' {% if part.category %}
|
||||
{{ part.category }}
|
||||
{% endif %}
|
||||
'],
|
||||
[' {% set a = random(1, 3) %}
|
||||
'];
|
||||
yield [' {% set a = random(1, 3) %}
|
||||
{{ 1 + 2 | abs }}
|
||||
{{ "test" | capitalize | escape | lower | raw }}
|
||||
{{ "\n" | nl2br | trim | title | url_encode | reverse }}
|
||||
'],
|
||||
['
|
||||
'];
|
||||
yield ['
|
||||
{{ location.isRoot}} {{ location.isChildOf(location) }} {{ location.comment }} {{ location.level }}
|
||||
{{ location.fullPath }} {% set arr = location.pathArray %} {% set child = location.children %} {{location.childrenNotSelectable}}
|
||||
'],
|
||||
['
|
||||
'];
|
||||
yield ['
|
||||
{{ part.reviewNeeded }} {{ part.tags }} {{ part.mass }}
|
||||
'],
|
||||
['
|
||||
'];
|
||||
yield ['
|
||||
{{ entity_type(part) is object }}
|
||||
'],
|
||||
['
|
||||
'];
|
||||
yield ['
|
||||
{% apply placeholders(part) %}[[NAME]]{% endapply %}</br>
|
||||
{{ placeholder("[[NAME]]", part) }}
|
||||
']
|
||||
];
|
||||
'];
|
||||
}
|
||||
|
||||
public function twigNotAllowedDataProvider(): array
|
||||
public function twigNotAllowedDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['{% block test %} {% endblock %}'],
|
||||
['{% deprecated test %}'],
|
||||
['{% flush %}'],
|
||||
["{{ part.setName('test') }}"],
|
||||
['{{ part.setCategory(null) }}'],
|
||||
];
|
||||
yield ['{% block test %} {% endblock %}'];
|
||||
yield ['{% deprecated test %}'];
|
||||
yield ['{% flush %}'];
|
||||
yield ["{{ part.setName('test') }}"];
|
||||
yield ['{{ part.setCategory(null) }}'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -41,60 +41,58 @@ class FAIconGeneratorTest extends WebTestCase
|
|||
$this->service = self::getContainer()->get(FAIconGenerator::class);
|
||||
}
|
||||
|
||||
public function fileExtensionDataProvider(): array
|
||||
public function fileExtensionDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
['pdf', 'fa-file-pdf'],
|
||||
['jpeg','fa-file-image'],
|
||||
['txt', 'fa-file-lines'],
|
||||
['doc', 'fa-file-word'],
|
||||
['zip', 'fa-file-zipper'],
|
||||
['png', 'fa-file-image'],
|
||||
['jpg', 'fa-file-image'],
|
||||
['gif', 'fa-file-image'],
|
||||
['svg', 'fa-file-image'],
|
||||
['xls', 'fa-file-excel'],
|
||||
['xlsx', 'fa-file-excel'],
|
||||
['ppt', 'fa-file-powerpoint'],
|
||||
['pptx', 'fa-file-powerpoint'],
|
||||
['docx', 'fa-file-word'],
|
||||
['odt', 'fa-file-word'],
|
||||
['ods', 'fa-file-excel'],
|
||||
['odp', 'fa-file-powerpoint'],
|
||||
['py', 'fa-file-code'],
|
||||
['js', 'fa-file-code'],
|
||||
['html', 'fa-file-code'],
|
||||
['css', 'fa-file-code'],
|
||||
['xml', 'fa-file-code'],
|
||||
['json', 'fa-file-code'],
|
||||
['yml', 'fa-file-code'],
|
||||
['yaml', 'fa-file-code'],
|
||||
['csv', 'fa-file-csv'],
|
||||
['sql', 'fa-file-code'],
|
||||
['sh', 'fa-file-code'],
|
||||
['bat', 'fa-file-code'],
|
||||
['exe', 'fa-file-code'],
|
||||
['dll', 'fa-file-code'],
|
||||
['lib', 'fa-file-code'],
|
||||
['so', 'fa-file-code'],
|
||||
['a', 'fa-file-code'],
|
||||
['o', 'fa-file-code'],
|
||||
['class', 'fa-file-code'],
|
||||
['jar', 'fa-file-code'],
|
||||
['rar', 'fa-file-zipper'],
|
||||
['7z', 'fa-file-zipper'],
|
||||
['tar', 'fa-file-zipper'],
|
||||
['gz', 'fa-file-zipper'],
|
||||
['tgz', 'fa-file-zipper'],
|
||||
['bz2', 'fa-file-zipper'],
|
||||
['tbz', 'fa-file-zipper'],
|
||||
['xz', 'fa-file-zipper'],
|
||||
['txz', 'fa-file-zipper'],
|
||||
['zip', 'fa-file-zipper'],
|
||||
['php', 'fa-file-code'],
|
||||
['tmp', 'fa-file'],
|
||||
['fgd', 'fa-file'],
|
||||
];
|
||||
yield ['pdf', 'fa-file-pdf'];
|
||||
yield ['jpeg','fa-file-image'];
|
||||
yield ['txt', 'fa-file-lines'];
|
||||
yield ['doc', 'fa-file-word'];
|
||||
yield ['zip', 'fa-file-zipper'];
|
||||
yield ['png', 'fa-file-image'];
|
||||
yield ['jpg', 'fa-file-image'];
|
||||
yield ['gif', 'fa-file-image'];
|
||||
yield ['svg', 'fa-file-image'];
|
||||
yield ['xls', 'fa-file-excel'];
|
||||
yield ['xlsx', 'fa-file-excel'];
|
||||
yield ['ppt', 'fa-file-powerpoint'];
|
||||
yield ['pptx', 'fa-file-powerpoint'];
|
||||
yield ['docx', 'fa-file-word'];
|
||||
yield ['odt', 'fa-file-word'];
|
||||
yield ['ods', 'fa-file-excel'];
|
||||
yield ['odp', 'fa-file-powerpoint'];
|
||||
yield ['py', 'fa-file-code'];
|
||||
yield ['js', 'fa-file-code'];
|
||||
yield ['html', 'fa-file-code'];
|
||||
yield ['css', 'fa-file-code'];
|
||||
yield ['xml', 'fa-file-code'];
|
||||
yield ['json', 'fa-file-code'];
|
||||
yield ['yml', 'fa-file-code'];
|
||||
yield ['yaml', 'fa-file-code'];
|
||||
yield ['csv', 'fa-file-csv'];
|
||||
yield ['sql', 'fa-file-code'];
|
||||
yield ['sh', 'fa-file-code'];
|
||||
yield ['bat', 'fa-file-code'];
|
||||
yield ['exe', 'fa-file-code'];
|
||||
yield ['dll', 'fa-file-code'];
|
||||
yield ['lib', 'fa-file-code'];
|
||||
yield ['so', 'fa-file-code'];
|
||||
yield ['a', 'fa-file-code'];
|
||||
yield ['o', 'fa-file-code'];
|
||||
yield ['class', 'fa-file-code'];
|
||||
yield ['jar', 'fa-file-code'];
|
||||
yield ['rar', 'fa-file-zipper'];
|
||||
yield ['7z', 'fa-file-zipper'];
|
||||
yield ['tar', 'fa-file-zipper'];
|
||||
yield ['gz', 'fa-file-zipper'];
|
||||
yield ['tgz', 'fa-file-zipper'];
|
||||
yield ['bz2', 'fa-file-zipper'];
|
||||
yield ['tbz', 'fa-file-zipper'];
|
||||
yield ['xz', 'fa-file-zipper'];
|
||||
yield ['txz', 'fa-file-zipper'];
|
||||
yield ['zip', 'fa-file-zipper'];
|
||||
yield ['php', 'fa-file-code'];
|
||||
yield ['tmp', 'fa-file'];
|
||||
yield ['fgd', 'fa-file'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -81,21 +81,19 @@ class RangeParserTest extends WebTestCase
|
|||
yield [[], '1, 2, test', true];
|
||||
}
|
||||
|
||||
public function validDataProvider(): array
|
||||
public function validDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
[true, ''],
|
||||
[true, ' '],
|
||||
[true, '1, 2, 3'],
|
||||
[true, '1-2,3, 4- 5'],
|
||||
[true, '1 -2, 3- 4, 6'],
|
||||
[true, '1--2'],
|
||||
[true, '1- -2'],
|
||||
[true, ',,12,33'],
|
||||
[false, 'test'],
|
||||
[false, '1-2-3'],
|
||||
[false, '1, 2 test'],
|
||||
];
|
||||
yield [true, ''];
|
||||
yield [true, ' '];
|
||||
yield [true, '1, 2, 3'];
|
||||
yield [true, '1-2,3, 4- 5'];
|
||||
yield [true, '1 -2, 3- 4, 6'];
|
||||
yield [true, '1--2'];
|
||||
yield [true, '1- -2'];
|
||||
yield [true, ',,12,33'];
|
||||
yield [false, 'test'];
|
||||
yield [false, '1-2-3'];
|
||||
yield [false, '1, 2 test'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -56,19 +56,17 @@ class ParameterExtractorTest extends WebTestCase
|
|||
$this->service = self::getContainer()->get(ParameterExtractor::class);
|
||||
}
|
||||
|
||||
public function emptyDataProvider(): array
|
||||
public function emptyDataProvider(): \Iterator
|
||||
{
|
||||
return [
|
||||
[''],
|
||||
[' '],
|
||||
["\t\n"],
|
||||
[':;'],
|
||||
['NPN Transistor'],
|
||||
['=BC547 rewr'],
|
||||
['<i>For good</i>, [b]bad[/b], evil'],
|
||||
['Param:; Test'],
|
||||
['A [link](https://demo.part-db.de) should not be matched']
|
||||
];
|
||||
yield [''];
|
||||
yield [' '];
|
||||
yield ["\t\n"];
|
||||
yield [':;'];
|
||||
yield ['NPN Transistor'];
|
||||
yield ['=BC547 rewr'];
|
||||
yield ['<i>For good</i>, [b]bad[/b], evil'];
|
||||
yield ['Param:; Test'];
|
||||
yield ['A [link](https://demo.part-db.de) should not be matched'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -119,15 +119,15 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
|
|||
{
|
||||
//Add 5 to lot 1
|
||||
$this->service->add($this->partLot1, 5, "Test");
|
||||
$this->assertSame(15.0, $this->partLot1->getAmount());
|
||||
$this->assertEqualsWithDelta(15.0, $this->partLot1->getAmount(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//Add 3.2 to lot 2
|
||||
$this->service->add($this->partLot2, 3.2, "Test");
|
||||
$this->assertSame(5.0, $this->partLot2->getAmount());
|
||||
$this->assertEqualsWithDelta(5.0, $this->partLot2->getAmount(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//Add 1.5 to lot 3
|
||||
$this->service->add($this->partLot3, 1.5, "Test");
|
||||
$this->assertSame(2.0, $this->partLot3->getAmount());
|
||||
$this->assertEqualsWithDelta(2.0, $this->partLot3->getAmount(), PHP_FLOAT_EPSILON);
|
||||
|
||||
}
|
||||
|
||||
|
@ -135,23 +135,23 @@ class PartLotWithdrawAddHelperTest extends WebTestCase
|
|||
{
|
||||
//Withdraw 5 from lot 1
|
||||
$this->service->withdraw($this->partLot1, 5, "Test");
|
||||
$this->assertSame(5.0, $this->partLot1->getAmount());
|
||||
$this->assertEqualsWithDelta(5.0, $this->partLot1->getAmount(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//Withdraw 2.2 from lot 2
|
||||
$this->service->withdraw($this->partLot2, 2.2, "Test");
|
||||
$this->assertSame(0.0, $this->partLot2->getAmount());
|
||||
$this->assertEqualsWithDelta(0.0, $this->partLot2->getAmount(), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
|
||||
public function testMove(): void
|
||||
{
|
||||
//Move 5 from lot 1 to lot 2
|
||||
$this->service->move($this->partLot1, $this->partLot2, 5, "Test");
|
||||
$this->assertSame(5.0, $this->partLot1->getAmount());
|
||||
$this->assertSame(7.0, $this->partLot2->getAmount());
|
||||
$this->assertEqualsWithDelta(5.0, $this->partLot1->getAmount(), PHP_FLOAT_EPSILON);
|
||||
$this->assertEqualsWithDelta(7.0, $this->partLot2->getAmount(), PHP_FLOAT_EPSILON);
|
||||
|
||||
//Move 2.2 from lot 2 to lot 3
|
||||
$this->service->move($this->partLot2, $this->partLot3, 2.2, "Test");
|
||||
$this->assertSame(5.0, $this->partLot2->getAmount());
|
||||
$this->assertSame(2.0, $this->partLot3->getAmount());
|
||||
$this->assertEqualsWithDelta(5.0, $this->partLot2->getAmount(), PHP_FLOAT_EPSILON);
|
||||
$this->assertEqualsWithDelta(2.0, $this->partLot3->getAmount(), PHP_FLOAT_EPSILON);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,16 +91,14 @@ class PermissionManagerTest extends WebTestCase
|
|||
$this->group->method('getParent')->willReturn($parent_group);
|
||||
}
|
||||
|
||||
public function getPermissionNames(): array
|
||||
public function getPermissionNames(): \Iterator
|
||||
{
|
||||
//List some permission names
|
||||
return [
|
||||
['parts'],
|
||||
['system'],
|
||||
['footprints'],
|
||||
['suppliers'],
|
||||
['tools']
|
||||
];
|
||||
yield ['parts'];
|
||||
yield ['system'];
|
||||
yield ['footprints'];
|
||||
yield ['suppliers'];
|
||||
yield ['tools'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,9 +46,12 @@ class BackupCodeGeneratorTest extends TestCase
|
|||
new BackupCodeGenerator(4, 10);
|
||||
}
|
||||
|
||||
public function codeLengthDataProvider(): array
|
||||
public function codeLengthDataProvider(): \Iterator
|
||||
{
|
||||
return [[6], [8], [10], [16]];
|
||||
yield [6];
|
||||
yield [8];
|
||||
yield [10];
|
||||
yield [16];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,9 +63,11 @@ class BackupCodeGeneratorTest extends TestCase
|
|||
$this->assertMatchesRegularExpression("/^([a-f0-9]){{$code_length}}\$/", $generator->generateSingleCode());
|
||||
}
|
||||
|
||||
public function codeCountDataProvider(): array
|
||||
public function codeCountDataProvider(): \Iterator
|
||||
{
|
||||
return [[2], [8], [10]];
|
||||
yield [2];
|
||||
yield [8];
|
||||
yield [10];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Services\UserSystem;
|
||||
|
||||
use App\Entity\UserSystem\ApiToken;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Validator\Constraints;
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Validator\Constraints;
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Validator\Constraints;
|
||||
|
||||
use App\Tests\Validator\DummyUniqueValidatableObject;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Validator\Constraints;
|
||||
|
||||
use App\Validator\Constraints\UrlOrBuiltin;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Validator\Constraints;
|
||||
|
||||
use App\Entity\UserSystem\User;
|
||||
|
@ -61,7 +63,7 @@ class ValidGoogleAuthCodeValidatorTest extends ConstraintValidatorTestCase
|
|||
{
|
||||
//Leave empty
|
||||
}
|
||||
public function getUser(): ?\Symfony\Component\Security\Core\User\UserInterface
|
||||
public function getUser(): ?UserInterface
|
||||
{
|
||||
return new class implements TwoFactorInterface, UserInterface {
|
||||
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Validator\Constraints;
|
||||
|
||||
use App\Validator\Constraints\ValidTheme;
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
|
@ -17,7 +20,6 @@
|
|||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\Tests\Validator;
|
||||
|
||||
use App\Validator\UniqueValidatableInterface;
|
||||
|
@ -38,4 +40,4 @@ class DummyUniqueValidatableObject implements UniqueValidatableInterface, \Strin
|
|||
{
|
||||
return 'objectString';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue