mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-15 12:54:30 +02:00
Added tests for DTOConverter
This commit is contained in:
parent
de82249d8d
commit
8ea92ef330
11 changed files with 429 additions and 11 deletions
|
@ -23,12 +23,20 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\InfoProviderSystem\DTOs;
|
||||
|
||||
/**
|
||||
* This DTO represents a file that can be downloaded from a URL.
|
||||
* This could be a datasheet, a 3D model, a picture or similar.
|
||||
*/
|
||||
class FileDTO
|
||||
{
|
||||
/**
|
||||
* @param string $url The URL where to get this file
|
||||
* @param string|null $name Optionally the name of this file
|
||||
*/
|
||||
public function __construct(
|
||||
/** The URL where to get this file */
|
||||
public readonly string $url,
|
||||
/** Optionally the name of this file */
|
||||
public readonly ?string $name = null,
|
||||
) {}
|
||||
|
||||
|
||||
}
|
|
@ -23,6 +23,10 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\InfoProviderSystem\DTOs;
|
||||
|
||||
/**
|
||||
* This DTO represents a parameter of a part (similar to the AbstractParameter entity).
|
||||
* This could be a voltage, a current, a temperature or similar.
|
||||
*/
|
||||
class ParameterDTO
|
||||
{
|
||||
public function __construct(
|
||||
|
|
|
@ -24,8 +24,10 @@ declare(strict_types=1);
|
|||
namespace App\Services\InfoProviderSystem\DTOs;
|
||||
|
||||
use App\Entity\Parts\ManufacturingStatus;
|
||||
use Hoa\Zformat\Parameter;
|
||||
|
||||
/**
|
||||
* This DTO represents a part with all its details.
|
||||
*/
|
||||
class PartDetailDTO extends SearchResultDTO
|
||||
{
|
||||
public function __construct(
|
||||
|
@ -43,6 +45,8 @@ class PartDetailDTO extends SearchResultDTO
|
|||
public readonly ?string $notes = null,
|
||||
/** @var FileDTO[]|null */
|
||||
public readonly ?array $datasheets = null,
|
||||
/** @var FileDTO[]|null */
|
||||
public readonly ?array $images = null,
|
||||
/** @var ParameterDTO[]|null */
|
||||
public readonly ?array $parameters = null,
|
||||
/** @var PurchaseInfoDTO[]|null */
|
||||
|
|
|
@ -46,6 +46,10 @@ class PriceDTO
|
|||
$this->price_as_big_decimal = BigDecimal::of($this->price);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the price as BigDecimal
|
||||
* @return BigDecimal
|
||||
*/
|
||||
public function getPriceAsBigDecimal(): BigDecimal
|
||||
{
|
||||
return $this->price_as_big_decimal;
|
||||
|
|
|
@ -23,6 +23,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\InfoProviderSystem\DTOs;
|
||||
|
||||
/**
|
||||
* This DTO represents a purchase information for a part (supplier name, order number and prices).
|
||||
*/
|
||||
class PurchaseInfoDTO
|
||||
{
|
||||
public function __construct(
|
||||
|
|
|
@ -25,6 +25,9 @@ namespace App\Services\InfoProviderSystem\DTOs;
|
|||
|
||||
use App\Entity\Parts\ManufacturingStatus;
|
||||
|
||||
/**
|
||||
* This DTO represents a search result for a part.
|
||||
*/
|
||||
class SearchResultDTO
|
||||
{
|
||||
public function __construct(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue