mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-12-21 02:19:30 +00:00
Applied rector suggestions
This commit is contained in:
parent
4106bcef5f
commit
20f32c7f12
170 changed files with 808 additions and 761 deletions
|
|
@ -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) }}'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue