fix: 🐛 resolve some tests
This commit is contained in:
parent
f45bb119e0
commit
7265d2fa5f
12 changed files with 35 additions and 57 deletions
|
|
@ -14,6 +14,7 @@ final readonly class CampaignRequestListItem
|
|||
{
|
||||
public function __construct(
|
||||
public BrandCode $brandCode,
|
||||
public CampaignName $name,
|
||||
public Applicant $applicant,
|
||||
public CampaignRequestType $campaignType,
|
||||
public CampaignRequestStatus $status
|
||||
|
|
|
|||
|
|
@ -4,18 +4,18 @@ declare(strict_types=1);
|
|||
|
||||
namespace Domain\Models\ValueObjects\Campaign;
|
||||
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponQuantity;
|
||||
use Domain\Models\ValueObjects\PrintRules;
|
||||
use Domain\Models\ValueObjects\ProcessingCode;
|
||||
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
||||
use Shared\Enums\Country;
|
||||
|
||||
final readonly class CampaignCoupon
|
||||
{
|
||||
public function __construct(
|
||||
public ProcessingCode $processingCode,
|
||||
public CouponQuantity $quantity,
|
||||
public CountryAuthorized $availableIn,
|
||||
public Country $availableIn,
|
||||
public ?WarningThresholdQuantity $warningThresholdQuantity = null,
|
||||
public ?PrintRules $printRules = null,
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -4,13 +4,13 @@ declare(strict_types=1);
|
|||
|
||||
namespace Domain\Models\ValueObjects\Coupon;
|
||||
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Shared\Enums\Country;
|
||||
|
||||
final readonly class CouponValidityInformation
|
||||
{
|
||||
public function __construct(
|
||||
public string $validityText,
|
||||
public CountryAuthorized $forLocale
|
||||
public Country $forLocale
|
||||
) {
|
||||
if (mb_trim($this->validityText) === '') {
|
||||
throw new \DomainException('Validity text cannot be empty.');
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ use Application\UseCases\CampaignRequest\Find\Output\CampaignRequestNotFound;
|
|||
use Application\UseCases\CampaignRequest\Find\Output\Output;
|
||||
use DateTime;
|
||||
use Domain\Enums\BarcodeFormat;
|
||||
use Domain\Enums\Country;
|
||||
use Domain\Exceptions\BrandNotFoundException;
|
||||
use Domain\Models\Entities\Brand;
|
||||
use Domain\Models\Entities\CampaignRequest;
|
||||
|
|
@ -41,6 +40,7 @@ use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
|||
use Domain\Ports\Repositories\BrandRepository;
|
||||
use Domain\Ports\Repositories\CampaignRequestRepository;
|
||||
use Shared\DDD\UseCases\Input as BaseInput;
|
||||
use Shared\Enums\Country;
|
||||
use Shared\Enums\Currency;
|
||||
use Shared\ValueObjects\Email;
|
||||
use Shared\ValueObjects\Money;
|
||||
|
|
@ -62,7 +62,7 @@ describe('find campaign request use case', function (): void {
|
|||
new PicturePath('coupons/inactive_thumbnail.jpg')
|
||||
),
|
||||
new CouponValidity(30, new DateTime('2026-02-01')),
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', new CountryAuthorized(Country::FRANCE))],
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE)],
|
||||
[new IncoCode(35784), new IncoCode(15522)],
|
||||
new PrintRules(maxPerCustomer: 3),
|
||||
new GS1('01234567890128', BarcodeFormat::EAN13),
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@ namespace Application\UseCases\CampaignRequest\List;
|
|||
|
||||
use DateTime;
|
||||
use Domain\Enums\BarcodeFormat;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestStatus;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestType;
|
||||
use Domain\Models\Entities\CampaignRequest;
|
||||
use Domain\Models\ValueObjects\Brand\BrandCode;
|
||||
use Domain\Models\ValueObjects\Campaign\CampaignName;
|
||||
|
|
@ -17,6 +15,8 @@ use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestId;
|
|||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestSortClause;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestSortCriteria;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestSortField;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestStatus;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestType;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidity;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidityInformation;
|
||||
use Domain\Models\ValueObjects\CouponName;
|
||||
|
|
@ -32,6 +32,7 @@ use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon;
|
|||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity;
|
||||
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
||||
use Domain\Ports\Repositories\CampaignRequestRepository;
|
||||
use Shared\Enums\Country;
|
||||
use Shared\Enums\Currency;
|
||||
use Shared\ValueObjects\Email;
|
||||
use Shared\ValueObjects\Money;
|
||||
|
|
@ -54,7 +55,7 @@ describe('list campaigns request use case', function (): void {
|
|||
new PicturePath('coupons/inactive_thumbnail.jpg')
|
||||
),
|
||||
new CouponValidity(30, new DateTime('2026-02-01')),
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', new CountryAuthorized(Country::FRANCE))],
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE)],
|
||||
[new IncoCode(35784), new IncoCode(15522)],
|
||||
new PrintRules(maxPerCustomer: 3),
|
||||
new GS1('01234567890128', BarcodeFormat::EAN13),
|
||||
|
|
@ -73,7 +74,7 @@ describe('list campaigns request use case', function (): void {
|
|||
new PicturePath('coupons/inactive_thumbnail.jpg')
|
||||
),
|
||||
new CouponValidity(30, new DateTime('2026-02-01')),
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', new CountryAuthorized(Country::FRANCE))],
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE)],
|
||||
[new IncoCode(24514), new IncoCode(46259)],
|
||||
new PrintRules(maxPerCustomer: 3),
|
||||
new GS1('01234567890128', BarcodeFormat::EAN13),
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use Application\UseCases\CampaignRequest\Reject\RejectCampaignRequest;
|
|||
use Carbon\CarbonImmutable;
|
||||
use DateTime;
|
||||
use Domain\Enums\BarcodeFormat;
|
||||
use Domain\Enums\Country;
|
||||
use Domain\Models\Entities\CampaignRequest;
|
||||
use Domain\Models\ValueObjects\Brand\BrandCode;
|
||||
use Domain\Models\ValueObjects\Campaign\CampaignName;
|
||||
|
|
@ -36,6 +35,7 @@ use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon;
|
|||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity;
|
||||
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
||||
use Domain\Ports\Repositories\CampaignRequestRepository;
|
||||
use Shared\Enums\Country;
|
||||
use Shared\Enums\Currency;
|
||||
use Shared\ValueObjects\Email;
|
||||
use Shared\ValueObjects\Money;
|
||||
|
|
@ -56,7 +56,7 @@ describe('reject campaign request use case', function (): void {
|
|||
new PicturePath('coupons/inactive_thumbnail.jpg')
|
||||
),
|
||||
new CouponValidity(30, new DateTime('2026-02-01')),
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', new CountryAuthorized(Country::FRANCE))],
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE)],
|
||||
[new IncoCode(35784), new IncoCode(15522)],
|
||||
new PrintRules(maxPerCustomer: 3),
|
||||
new GS1('01234567890128', BarcodeFormat::EAN13),
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ namespace Tests\Unit\Domain\Models\Entities;
|
|||
use Carbon\CarbonImmutable;
|
||||
use DateTime;
|
||||
use Domain\Enums\BarcodeFormat;
|
||||
use Domain\Enums\Country;
|
||||
use Domain\Models\Entities\CampaignRequest;
|
||||
use Domain\Models\ValueObjects\Brand\BrandCode;
|
||||
use Domain\Models\ValueObjects\Campaign\CampaignName;
|
||||
|
|
@ -16,7 +15,6 @@ use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestId;
|
|||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestStatus;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestType;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\RejectionReason;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidity;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidityInformation;
|
||||
use Domain\Models\ValueObjects\CouponName;
|
||||
|
|
@ -32,6 +30,7 @@ use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon;
|
|||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity;
|
||||
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Shared\Enums\Country;
|
||||
use Shared\Enums\Currency;
|
||||
use Shared\ValueObjects\Email;
|
||||
use Shared\ValueObjects\Money;
|
||||
|
|
@ -56,7 +55,7 @@ describe('campaign request', function (): void {
|
|||
new PicturePath('coupons/inactive_thumbnail.jpg')
|
||||
),
|
||||
new CouponValidity(30, new DateTime('2026-02-01')),
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', new CountryAuthorized(Country::FRANCE))],
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE)],
|
||||
[new IncoCode(35784), new IncoCode(15522)],
|
||||
new PrintRules(maxPerCustomer: 3),
|
||||
new GS1('01234567890128', BarcodeFormat::EAN13),
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ use Domain\Models\ValueObjects\Campaign\CampaignCode;
|
|||
use Domain\Models\ValueObjects\Campaign\CampaignCoupon;
|
||||
use Domain\Models\ValueObjects\Campaign\CampaignId;
|
||||
use Domain\Models\ValueObjects\Campaign\CampaignName;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponQuantity;
|
||||
use Domain\Models\ValueObjects\PrintRules;
|
||||
use Domain\Models\ValueObjects\ProcessingCode;
|
||||
|
|
@ -37,7 +36,7 @@ describe('campaign', function (): void {
|
|||
new CampaignCoupon(
|
||||
new ProcessingCode('PC1'),
|
||||
new CouponQuantity(100),
|
||||
new CountryAuthorized(Country::FRANCE),
|
||||
Country::FRANCE,
|
||||
new WarningThresholdQuantity(100),
|
||||
new PrintRules(maxPerCustomer: 3)
|
||||
)
|
||||
|
|
@ -103,7 +102,7 @@ describe('campaign', function (): void {
|
|||
new CampaignCoupon(
|
||||
new ProcessingCode('PC1'),
|
||||
new CouponQuantity(100),
|
||||
new CountryAuthorized(Country::FRANCE),
|
||||
Country::FRANCE,
|
||||
new WarningThresholdQuantity(100),
|
||||
new PrintRules(maxPerCustomer: 3)
|
||||
)
|
||||
|
|
@ -138,7 +137,7 @@ describe('campaign', function (): void {
|
|||
new CampaignCoupon(
|
||||
new ProcessingCode('PC1'),
|
||||
new CouponQuantity(100),
|
||||
new CountryAuthorized(Country::FRANCE),
|
||||
Country::FRANCE,
|
||||
new WarningThresholdQuantity(100),
|
||||
new PrintRules(maxPerCustomer: 3)
|
||||
)
|
||||
|
|
@ -177,7 +176,7 @@ describe('campaign', function (): void {
|
|||
new CampaignCoupon(
|
||||
new ProcessingCode('PC1'),
|
||||
new CouponQuantity(100),
|
||||
new CountryAuthorized(Country::FRANCE),
|
||||
Country::FRANCE,
|
||||
new WarningThresholdQuantity(100),
|
||||
new PrintRules(maxPerCustomer: 3)
|
||||
)
|
||||
|
|
@ -220,7 +219,7 @@ describe('campaign', function (): void {
|
|||
new CampaignCoupon(
|
||||
new ProcessingCode('PC1'),
|
||||
new CouponQuantity(100),
|
||||
new CountryAuthorized(Country::FRANCE),
|
||||
Country::FRANCE,
|
||||
new WarningThresholdQuantity(100),
|
||||
new PrintRules(maxPerCustomer: 3)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -47,13 +47,13 @@ describe('coupon', function (): void {
|
|||
$this->couponValidityInformation = [
|
||||
new CouponValidityInformation(
|
||||
'Lorem ipsum dolor sit amet consectetur adipiscing elit.',
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
)
|
||||
];
|
||||
$this->couponLegalInformation = [
|
||||
new CouponLegalInformation(
|
||||
'Lorem ipsum dolor sit amet consectetur adipiscing elit.',
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
)
|
||||
];
|
||||
$this->processingCode = new ProcessingCode('5425003944130');
|
||||
|
|
@ -424,8 +424,8 @@ describe('coupon', function (): void {
|
|||
),
|
||||
new CouponDiffusion([new Period(new DateTime('2026-01-01'), new DateTime('2026-02-01'))]),
|
||||
new CouponValidity(30, new DateTime('2026-02-01')),
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', new CountryAuthorized(Country::FRANCE))],
|
||||
[new CouponLegalInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', new CountryAuthorized(Country::FRANCE))],
|
||||
[new CouponValidityInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE)],
|
||||
[new CouponLegalInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE)],
|
||||
new ProcessingCode('5425003944130'),
|
||||
new BrandCode('AAA01'),
|
||||
ActorId::generate(),
|
||||
|
|
|
|||
|
|
@ -4,13 +4,12 @@ declare(strict_types=1);
|
|||
|
||||
namespace Tests\Unit\Domain\Models\ValueObjects\Campaign;
|
||||
|
||||
use Domain\Enums\Country;
|
||||
use Domain\Models\ValueObjects\Campaign\CampaignCoupon;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponQuantity;
|
||||
use Domain\Models\ValueObjects\PrintRules;
|
||||
use Domain\Models\ValueObjects\ProcessingCode;
|
||||
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
||||
use Shared\Enums\Country;
|
||||
|
||||
covers(CampaignCoupon::class);
|
||||
|
||||
|
|
@ -19,7 +18,7 @@ describe('campaign coupon', function (): void {
|
|||
// GIVEN
|
||||
$processingCode = new ProcessingCode('PC1');
|
||||
$quantity = new CouponQuantity(10);
|
||||
$availableIn = new CountryAuthorized(Country::FRANCE);
|
||||
$availableIn = Country::FRANCE;
|
||||
$warningThresholdQuantity = new WarningThresholdQuantity(100);
|
||||
$printRules = new PrintRules(maxPerCustomer: 3);
|
||||
|
||||
|
|
@ -38,7 +37,7 @@ describe('campaign coupon', function (): void {
|
|||
// GIVEN
|
||||
$processingCode = new ProcessingCode('PC1');
|
||||
$quantity = new CouponQuantity(10);
|
||||
$availableIn = new CountryAuthorized(Country::FRANCE);
|
||||
$availableIn = Country::FRANCE;
|
||||
$printRules = new PrintRules(maxPerCustomer: 3);
|
||||
|
||||
// WHEN
|
||||
|
|
@ -60,7 +59,7 @@ describe('campaign coupon', function (): void {
|
|||
// GIVEN
|
||||
$processingCode = new ProcessingCode('PC1');
|
||||
$quantity = new CouponQuantity(10);
|
||||
$availableIn = new CountryAuthorized(Country::FRANCE);
|
||||
$availableIn = Country::FRANCE;
|
||||
$warningThresholdQuantity = new WarningThresholdQuantity(100);
|
||||
|
||||
// WHEN
|
||||
|
|
@ -82,7 +81,7 @@ describe('campaign coupon', function (): void {
|
|||
// GIVEN
|
||||
$processingCode = new ProcessingCode('PC1');
|
||||
$quantity = new CouponQuantity(10);
|
||||
$availableIn = new CountryAuthorized(Country::FRANCE);
|
||||
$availableIn = Country::FRANCE;
|
||||
|
||||
// WHEN
|
||||
$campaignCoupon = new CampaignCoupon(processingCode: $processingCode, quantity: $quantity, availableIn: $availableIn);
|
||||
|
|
|
|||
|
|
@ -4,9 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Tests\Unit\Domain\Models\ValueObjects\Coupon;
|
||||
|
||||
use Domain\Enums\Country;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidityInformation;
|
||||
use Shared\Enums\Country;
|
||||
|
||||
covers(CouponValidityInformation::class);
|
||||
|
||||
|
|
@ -14,7 +13,7 @@ describe('coupon validity information', function (): void {
|
|||
it('creates a valid coupon validity information', function (): void {
|
||||
// GIVEN
|
||||
$validityText = 'Lorem ipsum dolor sit amet consectetur adipiscing elit.';
|
||||
$forLocale = new CountryAuthorized(Country::FRANCE);
|
||||
$forLocale = Country::FRANCE;
|
||||
|
||||
// WHEN
|
||||
$couponValidityInformation = new CouponValidityInformation($validityText, $forLocale);
|
||||
|
|
@ -27,7 +26,7 @@ describe('coupon validity information', function (): void {
|
|||
it('rejects invalid coupon validity information', function (): void {
|
||||
// GIVEN
|
||||
$validityText = '';
|
||||
$forLocale = new CountryAuthorized(Country::FRANCE);
|
||||
$forLocale = Country::FRANCE;
|
||||
|
||||
// GIVEN / THEN
|
||||
expect(fn (): CouponValidityInformation => new CouponValidityInformation($validityText, $forLocale))->toThrow(\DomainException::class);
|
||||
|
|
|
|||
|
|
@ -7,8 +7,6 @@ namespace Tests\Unit\Domain\Models\ValueObjects\RequestedCoupon;
|
|||
use Carbon\CarbonImmutable;
|
||||
use DateTime;
|
||||
use Domain\Enums\BarcodeFormat;
|
||||
use Domain\Enums\Country;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidity;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidityInformation;
|
||||
use Domain\Models\ValueObjects\CouponName;
|
||||
|
|
@ -23,6 +21,7 @@ use Domain\Models\ValueObjects\ProcessingCode;
|
|||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon;
|
||||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity;
|
||||
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
||||
use Shared\Enums\Country;
|
||||
use Shared\Enums\Currency;
|
||||
use Shared\ValueObjects\Money;
|
||||
|
||||
|
|
@ -44,7 +43,7 @@ describe('requested coupon', function (): void {
|
|||
$this->couponValidityInformation = [
|
||||
new CouponValidityInformation(
|
||||
'Lorem ipsum dolor sit amet consectetur adipiscing elit.',
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
),
|
||||
];
|
||||
$this->products = [new IncoCode(35784), new IncoCode(15522)];
|
||||
|
|
@ -239,23 +238,4 @@ describe('requested coupon', function (): void {
|
|||
$this->warningThresholdQuantity
|
||||
))->toThrow(\DomainException::class, 'Coupon validity information must be CouponValidityInformation instances.');
|
||||
});
|
||||
|
||||
it('hydrates a requested coupon without a GS1', function (): void {
|
||||
// WHEN
|
||||
$coupon = new RequestedCoupon(
|
||||
new CouponName('Coupon A'),
|
||||
new CouponProductName('Product A'),
|
||||
new RequestedCouponQuantity(100),
|
||||
new WarningThresholdQuantity(10),
|
||||
new Period(new DateTime('2026-01-01'), new DateTime('2026-02-01')),
|
||||
new MoneyAmount(new Money(Currency::EUR, 300)),
|
||||
new ProcessingCode('PC1'),
|
||||
new CouponPicture(new PicturePath('coupons/product.jpg'), new PicturePath('coupons/thumbnail.jpg')),
|
||||
null,
|
||||
new CouponValidity(30, new DateTime()),
|
||||
);
|
||||
|
||||
// THEN
|
||||
expect($coupon->gs1)->toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue