mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Fixed code style.
This commit is contained in:
parent
b6e88db35f
commit
3671c94844
19 changed files with 55 additions and 60 deletions
|
@ -197,7 +197,7 @@ abstract class BaseAdminController extends AbstractController
|
||||||
//We can not use dynamic form events here, because the parent entity list is build from database!
|
//We can not use dynamic form events here, because the parent entity list is build from database!
|
||||||
$form = $this->createForm($this->form_class, $entity, [
|
$form = $this->createForm($this->form_class, $entity, [
|
||||||
'attachment_class' => $this->attachment_class,
|
'attachment_class' => $this->attachment_class,
|
||||||
'parameter_class' => $this->parameter_class
|
'parameter_class' => $this->parameter_class,
|
||||||
]);
|
]);
|
||||||
} elseif ($form->isSubmitted() && ! $form->isValid()) {
|
} elseif ($form->isSubmitted() && ! $form->isValid()) {
|
||||||
$this->addFlash('error', 'entity.edit_flash.invalid');
|
$this->addFlash('error', 'entity.edit_flash.invalid');
|
||||||
|
|
|
@ -135,7 +135,7 @@ class PartController extends AbstractController
|
||||||
'pictures' => $this->partPreviewGenerator->getPreviewAttachments($part),
|
'pictures' => $this->partPreviewGenerator->getPreviewAttachments($part),
|
||||||
'timeTravel' => $timeTravel_timestamp,
|
'timeTravel' => $timeTravel_timestamp,
|
||||||
'description_params' => $parameterExtractor->extractParameters($part->getDescription()),
|
'description_params' => $parameterExtractor->extractParameters($part->getDescription()),
|
||||||
'comment_params' => $parameterExtractor->extractParameters($part->getComment())
|
'comment_params' => $parameterExtractor->extractParameters($part->getComment()),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,6 @@ declare(strict_types=1);
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\Attachments\UserAttachment;
|
use App\Entity\Attachments\UserAttachment;
|
||||||
use App\Entity\Parameters\PartParameter;
|
|
||||||
use App\Entity\UserSystem\User;
|
use App\Entity\UserSystem\User;
|
||||||
use App\Form\Permissions\PermissionsType;
|
use App\Form\Permissions\PermissionsType;
|
||||||
use App\Form\UserAdminForm;
|
use App\Form\UserAdminForm;
|
||||||
|
@ -69,7 +68,7 @@ class UserController extends AdminPages\BaseAdminController
|
||||||
protected $route_base = 'user';
|
protected $route_base = 'user';
|
||||||
protected $attachment_class = UserAttachment::class;
|
protected $attachment_class = UserAttachment::class;
|
||||||
//Just define a value here to prevent error. It is not used.
|
//Just define a value here to prevent error. It is not used.
|
||||||
protected $parameter_class = "not used";
|
protected $parameter_class = 'not used';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="user_edit")
|
* @Route("/{id}/edit/{timestamp}", requirements={"id"="\d+"}, name="user_edit")
|
||||||
|
|
|
@ -89,16 +89,16 @@ class PartFixtures extends Fixture
|
||||||
|
|
||||||
$orderdetail = new Orderdetail();
|
$orderdetail = new Orderdetail();
|
||||||
$orderdetail->setSupplier($manager->find(Supplier::class, 1));
|
$orderdetail->setSupplier($manager->find(Supplier::class, 1));
|
||||||
$orderdetail->addPricedetail((new Pricedetail())->setPriceRelatedQuantity(1.0)->setPrice("10.0"));
|
$orderdetail->addPricedetail((new Pricedetail())->setPriceRelatedQuantity(1.0)->setPrice('10.0'));
|
||||||
$orderdetail->addPricedetail((new Pricedetail())->setPriceRelatedQuantity(10.0)->setPrice("15.0"));
|
$orderdetail->addPricedetail((new Pricedetail())->setPriceRelatedQuantity(10.0)->setPrice('15.0'));
|
||||||
$part->addOrderdetail($orderdetail);
|
$part->addOrderdetail($orderdetail);
|
||||||
|
|
||||||
$orderdetail = new Orderdetail();
|
$orderdetail = new Orderdetail();
|
||||||
$orderdetail->setSupplierpartnr('BC 547');
|
$orderdetail->setSupplierpartnr('BC 547');
|
||||||
$orderdetail->setObsolete(true);
|
$orderdetail->setObsolete(true);
|
||||||
$orderdetail->setSupplier($manager->find(Supplier::class, 1));
|
$orderdetail->setSupplier($manager->find(Supplier::class, 1));
|
||||||
$orderdetail->addPricedetail((new Pricedetail())->setPriceRelatedQuantity(1.0)->setPrice("10.0"));
|
$orderdetail->addPricedetail((new Pricedetail())->setPriceRelatedQuantity(1.0)->setPrice('10.0'));
|
||||||
$orderdetail->addPricedetail((new Pricedetail())->setPriceRelatedQuantity(10.0)->setPrice("15.1"));
|
$orderdetail->addPricedetail((new Pricedetail())->setPriceRelatedQuantity(10.0)->setPrice('15.1'));
|
||||||
$part->addOrderdetail($orderdetail);
|
$part->addOrderdetail($orderdetail);
|
||||||
|
|
||||||
$attachment = new PartAttachment();
|
$attachment = new PartAttachment();
|
||||||
|
|
|
@ -44,7 +44,6 @@ namespace App\DataTables\Column;
|
||||||
|
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Base\AbstractDBElement;
|
use App\Entity\Base\AbstractDBElement;
|
||||||
use App\Entity\Base\AbstractNamedDBElement;
|
|
||||||
use App\Entity\Contracts\NamedElementInterface;
|
use App\Entity\Contracts\NamedElementInterface;
|
||||||
use App\Entity\LogSystem\AbstractLogEntry;
|
use App\Entity\LogSystem\AbstractLogEntry;
|
||||||
use App\Entity\Parameters\AbstractParameter;
|
use App\Entity\Parameters\AbstractParameter;
|
||||||
|
@ -99,7 +98,7 @@ class LogEntryTargetColumn extends AbstractColumn
|
||||||
$tmp = '';
|
$tmp = '';
|
||||||
|
|
||||||
//The element is existing
|
//The element is existing
|
||||||
if ($target instanceof NamedElementInterface && !empty($target->getName())) {
|
if ($target instanceof NamedElementInterface && ! empty($target->getName())) {
|
||||||
try {
|
try {
|
||||||
$tmp = sprintf(
|
$tmp = sprintf(
|
||||||
'<a href="%s">%s</a>',
|
'<a href="%s">%s</a>',
|
||||||
|
@ -126,15 +125,15 @@ class LogEntryTargetColumn extends AbstractColumn
|
||||||
|
|
||||||
//Add a hint to the associated element if possible
|
//Add a hint to the associated element if possible
|
||||||
if (null !== $target && $this->options['show_associated']) {
|
if (null !== $target && $this->options['show_associated']) {
|
||||||
if ($target instanceof Attachment && $target->getElement() !== null) {
|
if ($target instanceof Attachment && null !== $target->getElement()) {
|
||||||
$on = $target->getElement();
|
$on = $target->getElement();
|
||||||
} elseif ($target instanceof AbstractParameter && $target->getElement() !== null) {
|
} elseif ($target instanceof AbstractParameter && null !== $target->getElement()) {
|
||||||
$on = $target->getElement();
|
$on = $target->getElement();
|
||||||
} elseif ($target instanceof PartLot && $target->getPart() !== null) {
|
} elseif ($target instanceof PartLot && null !== $target->getPart()) {
|
||||||
$on = $target->getPart();
|
$on = $target->getPart();
|
||||||
} elseif ($target instanceof Orderdetail && $target->getPart() !== null) {
|
} elseif ($target instanceof Orderdetail && null !== $target->getPart()) {
|
||||||
$on = $target->getPart();
|
$on = $target->getPart();
|
||||||
} elseif ($target instanceof Pricedetail && $target->getOrderdetail() !== null && $target->getOrderdetail()->getPart() !== null) {
|
} elseif ($target instanceof Pricedetail && null !== $target->getOrderdetail() && null !== $target->getOrderdetail()->getPart()) {
|
||||||
$on = $target->getOrderdetail()->getPart();
|
$on = $target->getOrderdetail()->getPart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +145,7 @@ class LogEntryTargetColumn extends AbstractColumn
|
||||||
$this->elementTypeNameGenerator->getTypeNameCombination($on, true)
|
$this->elementTypeNameGenerator->getTypeNameCombination($on, true)
|
||||||
);
|
);
|
||||||
} catch (EntityNotSupportedException $exception) {
|
} catch (EntityNotSupportedException $exception) {
|
||||||
$tmp .= ' (' . $this->elementTypeNameGenerator->getTypeNameCombination($target, true) .')';
|
$tmp .= ' ('.$this->elementTypeNameGenerator->getTypeNameCombination($target, true).')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,7 +212,7 @@ class LogDataTable implements DataTableTypeInterface
|
||||||
|
|
||||||
$dataTable->add('target', LogEntryTargetColumn::class, [
|
$dataTable->add('target', LogEntryTargetColumn::class, [
|
||||||
'label' => $this->translator->trans('log.target'),
|
'label' => $this->translator->trans('log.target'),
|
||||||
'show_associated' => $options['mode'] !== 'element_history',
|
'show_associated' => 'element_history' !== $options['mode'],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$dataTable->add('extra', LogEntryExtraColumn::class, [
|
$dataTable->add('extra', LogEntryExtraColumn::class, [
|
||||||
|
|
|
@ -28,7 +28,6 @@ use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use LogicException;
|
use LogicException;
|
||||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -213,7 +212,8 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the group this parameter is associated to (e.g. Technical Parameters)
|
* Returns the name of the group this parameter is associated to (e.g. Technical Parameters).
|
||||||
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getGroup(): string
|
public function getGroup(): string
|
||||||
|
@ -223,12 +223,13 @@ abstract class AbstractParameter extends AbstractNamedDBElement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the name of the group this parameter is associated to.
|
* Sets the name of the group this parameter is associated to.
|
||||||
* @param string $group
|
*
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setGroup(string $group): self
|
public function setGroup(string $group): self
|
||||||
{
|
{
|
||||||
$this->group = $group;
|
$this->group = $group;
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ trait ParametersTrait
|
||||||
foreach ($this->parameters as $parameter) {
|
foreach ($this->parameters as $parameter) {
|
||||||
$tmp[$parameter->getGroup()][] = $parameter;
|
$tmp[$parameter->getGroup()][] = $parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -328,9 +328,6 @@ class PartLot extends AbstractDBElement implements TimeStampableInterface, Named
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return $this->description;
|
return $this->description;
|
||||||
|
|
|
@ -361,9 +361,6 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @inheritDoc
|
|
||||||
*/
|
|
||||||
public function getName(): string
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return $this->getSupplierPartNr();
|
return $this->getSupplierPartNr();
|
||||||
|
|
|
@ -60,7 +60,7 @@ class EventLoggerSubscriber implements EventSubscriber
|
||||||
Orderdetail::class => ['part'],
|
Orderdetail::class => ['part'],
|
||||||
Pricedetail::class => ['orderdetail'],
|
Pricedetail::class => ['orderdetail'],
|
||||||
Attachment::class => ['element'],
|
Attachment::class => ['element'],
|
||||||
AbstractParameter::class => ['element']
|
AbstractParameter::class => ['element'],
|
||||||
];
|
];
|
||||||
|
|
||||||
protected const MAX_STRING_LENGTH = 2000;
|
protected const MAX_STRING_LENGTH = 2000;
|
||||||
|
|
|
@ -45,7 +45,6 @@ namespace App\Form\AdminPages;
|
||||||
use App\Entity\Attachments\Attachment;
|
use App\Entity\Attachments\Attachment;
|
||||||
use App\Entity\Base\AbstractNamedDBElement;
|
use App\Entity\Base\AbstractNamedDBElement;
|
||||||
use App\Entity\Base\AbstractStructuralDBElement;
|
use App\Entity\Base\AbstractStructuralDBElement;
|
||||||
use App\Entity\Parameters\PartParameter;
|
|
||||||
use App\Form\AttachmentFormType;
|
use App\Form\AttachmentFormType;
|
||||||
use App\Form\ParameterType;
|
use App\Form\ParameterType;
|
||||||
use App\Form\Type\MasterPictureAttachmentType;
|
use App\Form\Type\MasterPictureAttachmentType;
|
||||||
|
|
|
@ -113,14 +113,14 @@ class ParameterType extends AbstractType
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'placeholder' => 'parameter.group.placeholder',
|
'placeholder' => 'parameter.group.placeholder',
|
||||||
'class' => 'form-control-sm',
|
'class' => 'form-control-sm',
|
||||||
]
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver): void
|
public function configureOptions(OptionsResolver $resolver): void
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => AbstractParameter::class,
|
'data_class' => AbstractParameter::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,6 @@ use App\Entity\Parts\MeasurementUnit;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Entity\PriceInformations\Orderdetail;
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
use App\Form\AttachmentFormType;
|
use App\Form\AttachmentFormType;
|
||||||
use App\Form\ParameterGroupType;
|
|
||||||
use App\Form\ParameterType;
|
use App\Form\ParameterType;
|
||||||
use App\Form\Type\MasterPictureAttachmentType;
|
use App\Form\Type\MasterPictureAttachmentType;
|
||||||
use App\Form\Type\SIUnitType;
|
use App\Form\Type\SIUnitType;
|
||||||
|
|
|
@ -49,7 +49,6 @@ use App\Form\Type\SIUnitType;
|
||||||
use App\Form\Type\StructuralEntityType;
|
use App\Form\Type\StructuralEntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
|
|
@ -27,11 +27,11 @@ final class Version20200311204104 extends AbstractMigration
|
||||||
$this->addSql('ALTER TABLE `users` ADD perms_parts_parameters SMALLINT NOT NULL');
|
$this->addSql('ALTER TABLE `users` ADD perms_parts_parameters SMALLINT NOT NULL');
|
||||||
$this->addSql('ALTER TABLE log CHANGE level level TINYINT');
|
$this->addSql('ALTER TABLE log CHANGE level level TINYINT');
|
||||||
|
|
||||||
$sql = 'UPDATE `groups`' .
|
$sql = 'UPDATE `groups`'.
|
||||||
'SET perms_parts_parameters = 341 WHERE (id = 1 AND name = "admins") OR (id = 3 AND name = "users");';
|
'SET perms_parts_parameters = 341 WHERE (id = 1 AND name = "admins") OR (id = 3 AND name = "users");';
|
||||||
$this->addSql($sql);
|
$this->addSql($sql);
|
||||||
|
|
||||||
$sql = 'UPDATE `groups`' .
|
$sql = 'UPDATE `groups`'.
|
||||||
'SET perms_parts_parameters = 681 WHERE (id = 2 AND name = "readonly");';
|
'SET perms_parts_parameters = 681 WHERE (id = 2 AND name = "readonly");';
|
||||||
$this->addSql($sql);
|
$this->addSql($sql);
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,10 @@ class GitVersionInfo
|
||||||
$git = file($this->project_dir.'/.git/HEAD');
|
$git = file($this->project_dir.'/.git/HEAD');
|
||||||
$head = explode('/', $git[0], 3);
|
$head = explode('/', $git[0], 3);
|
||||||
|
|
||||||
if (!isset($head[2])) {
|
if (! isset($head[2])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return trim($head[2]);
|
return trim($head[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +89,7 @@ class GitVersionInfo
|
||||||
if (file_exists($filename)) {
|
if (file_exists($filename)) {
|
||||||
$head = file($filename);
|
$head = file($filename);
|
||||||
|
|
||||||
if (!isset($head[0])) {
|
if (! isset($head[0])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -20,31 +23,29 @@
|
||||||
|
|
||||||
namespace App\Services\Parameters;
|
namespace App\Services\Parameters;
|
||||||
|
|
||||||
|
|
||||||
use App\Entity\Parameters\AbstractParameter;
|
use App\Entity\Parameters\AbstractParameter;
|
||||||
use App\Entity\Parameters\PartParameter;
|
use App\Entity\Parameters\PartParameter;
|
||||||
|
|
||||||
class ParameterExtractor
|
class ParameterExtractor
|
||||||
{
|
{
|
||||||
protected const ALLOWED_PARAM_SEPARATORS = [", ", "\n"];
|
protected const ALLOWED_PARAM_SEPARATORS = [', ', "\n"];
|
||||||
|
|
||||||
protected const CHAR_LIMIT = 1000;
|
protected const CHAR_LIMIT = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tries to extract parameters from the given string.
|
* Tries to extract parameters from the given string.
|
||||||
* Useful for extraction from part description and comment.
|
* Useful for extraction from part description and comment.
|
||||||
* @param string $input
|
*
|
||||||
* @param string $class
|
|
||||||
* @return AbstractParameter[]
|
* @return AbstractParameter[]
|
||||||
*/
|
*/
|
||||||
public function extractParameters(string $input, string $class = PartParameter::class): array
|
public function extractParameters(string $input, string $class = PartParameter::class): array
|
||||||
{
|
{
|
||||||
if (!is_a($class, AbstractParameter::class, true)) {
|
if (! is_a($class, AbstractParameter::class, true)) {
|
||||||
throw new \InvalidArgumentException('$class must be a child class of AbstractParameter!');
|
throw new \InvalidArgumentException('$class must be a child class of AbstractParameter!');
|
||||||
}
|
}
|
||||||
|
|
||||||
//Restrict search length
|
//Restrict search length
|
||||||
$input = mb_strimwidth($input,0,self::CHAR_LIMIT);
|
$input = mb_strimwidth($input, 0, self::CHAR_LIMIT);
|
||||||
|
|
||||||
$parameters = [];
|
$parameters = [];
|
||||||
|
|
||||||
|
@ -52,7 +53,7 @@ class ParameterExtractor
|
||||||
$split = $this->splitString($input);
|
$split = $this->splitString($input);
|
||||||
foreach ($split as $param_string) {
|
foreach ($split as $param_string) {
|
||||||
$tmp = $this->stringToParam($param_string, $class);
|
$tmp = $this->stringToParam($param_string, $class);
|
||||||
if ($tmp !== null) {
|
if (null !== $tmp) {
|
||||||
$parameters[] = $tmp;
|
$parameters[] = $tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +68,7 @@ class ParameterExtractor
|
||||||
|
|
||||||
$matches = [];
|
$matches = [];
|
||||||
\preg_match($regex, $input, $matches);
|
\preg_match($regex, $input, $matches);
|
||||||
if (!empty($matches)) {
|
if (! empty($matches)) {
|
||||||
[$raw, $name, $value] = $matches;
|
[$raw, $name, $value] = $matches;
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
|
|
||||||
|
@ -90,7 +91,8 @@ class ParameterExtractor
|
||||||
protected function splitString(string $input): array
|
protected function splitString(string $input): array
|
||||||
{
|
{
|
||||||
//Allow comma as limiter (include space, to prevent splitting in german style numbers)
|
//Allow comma as limiter (include space, to prevent splitting in german style numbers)
|
||||||
$input = str_replace(static::ALLOWED_PARAM_SEPARATORS, ";", $input);
|
$input = str_replace(static::ALLOWED_PARAM_SEPARATORS, ';', $input);
|
||||||
return explode(";", $input);
|
|
||||||
|
return explode(';', $input);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||||
*
|
*
|
||||||
|
@ -26,10 +29,9 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
|
||||||
class ParameterExtractorTest extends WebTestCase
|
class ParameterExtractorTest extends WebTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $service;
|
protected $service;
|
||||||
|
|
||||||
public function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
//Get an service instance.
|
//Get an service instance.
|
||||||
|
@ -40,26 +42,26 @@ class ParameterExtractorTest extends WebTestCase
|
||||||
public function emptyDataProvider(): array
|
public function emptyDataProvider(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[""],
|
[''],
|
||||||
[" "],
|
[' '],
|
||||||
["\t\n"],
|
["\t\n"],
|
||||||
[":;"],
|
[':;'],
|
||||||
["NPN Transistor"],
|
['NPN Transistor'],
|
||||||
["=BC547 rewr"],
|
['=BC547 rewr'],
|
||||||
["<i>For good</i>, [b]bad[/b], evil"],
|
['<i>For good</i>, [b]bad[/b], evil'],
|
||||||
["Param:; Test"]
|
['Param:; Test'],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider emptyDataProvider
|
* @dataProvider emptyDataProvider
|
||||||
*/
|
*/
|
||||||
public function testShouldReturnEmpty(string $input)
|
public function testShouldReturnEmpty(string $input): void
|
||||||
{
|
{
|
||||||
$this->assertEmpty($this->service->extractParameters($input));
|
$this->assertEmpty($this->service->extractParameters($input));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtract()
|
public function testExtract(): void
|
||||||
{
|
{
|
||||||
$parameters = $this->service->extractParameters(' Operating Voltage: 10 V; Property : Value, Ström=1A (Test)');
|
$parameters = $this->service->extractParameters(' Operating Voltage: 10 V; Property : Value, Ström=1A (Test)');
|
||||||
$this->assertContainsOnly(AbstractParameter::class, $parameters);
|
$this->assertContainsOnly(AbstractParameter::class, $parameters);
|
||||||
|
@ -70,6 +72,5 @@ class ParameterExtractorTest extends WebTestCase
|
||||||
$this->assertSame('Value', $parameters[1]->getValueText());
|
$this->assertSame('Value', $parameters[1]->getValueText());
|
||||||
$this->assertSame('Ström', $parameters[2]->getName());
|
$this->assertSame('Ström', $parameters[2]->getName());
|
||||||
$this->assertSame('1A (Test)', $parameters[2]->getValueText());
|
$this->assertSame('1A (Test)', $parameters[2]->getValueText());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue