fix: 🐛 change country and country authorized
This commit is contained in:
parent
592728eb51
commit
c8d775fef6
19 changed files with 45 additions and 814 deletions
|
|
@ -9,7 +9,6 @@ use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestType;
|
|||
use Domain\Models\Entities\Brand;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\Applicant;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\RejectionReason;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\PrintRules;
|
||||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ 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 Shared\DDD\Models\AggregateRoot;
|
||||
use Shared\DDD\Models\HasTimestampIdentifier;
|
||||
use Shared\Enums\Country;
|
||||
|
||||
/**
|
||||
* @implements \Shared\DDD\Models\AggregateRoot<\Domain\Models\ValueObjects\Campaign\CampaignId>
|
||||
|
|
@ -25,7 +25,7 @@ final readonly class Campaign implements AggregateRoot, HasTimestampIdentifier
|
|||
public CampaignName $name,
|
||||
public bool $publication,
|
||||
public bool $printAllAtOnce,
|
||||
public CountryAuthorized $availableIn,
|
||||
public Country $availableIn,
|
||||
/** @var array<int, CampaignCoupon> $coupons */
|
||||
public array $coupons,
|
||||
public BrandCode $brand,
|
||||
|
|
@ -62,7 +62,7 @@ final readonly class Campaign implements AggregateRoot, HasTimestampIdentifier
|
|||
CampaignName $name,
|
||||
bool $publication,
|
||||
bool $printAllAtOnce,
|
||||
CountryAuthorized $availableIn,
|
||||
Country $availableIn,
|
||||
/** @var array<int, CampaignCoupon> $coupons */
|
||||
array $coupons,
|
||||
BrandCode $brand,
|
||||
|
|
@ -92,7 +92,7 @@ final readonly class Campaign implements AggregateRoot, HasTimestampIdentifier
|
|||
CampaignName $name,
|
||||
bool $publication,
|
||||
bool $printAllAtOnce,
|
||||
CountryAuthorized $availableIn,
|
||||
Country $availableIn,
|
||||
array $coupons,
|
||||
BrandCode $brand,
|
||||
?\DateTimeInterface $updatedAt = null,
|
||||
|
|
|
|||
|
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Domain\Models\ValueObjects;
|
||||
|
||||
use Override;
|
||||
use Shared\DDD\Models\Equatable;
|
||||
use Shared\Enums\Country;
|
||||
|
||||
final readonly class CountryAuthorized implements \Stringable, Equatable
|
||||
{
|
||||
/** @var list<Country> */
|
||||
private static function authorized(): array
|
||||
{
|
||||
return [
|
||||
Country::FRANCE,
|
||||
...Country::benelux(),
|
||||
];
|
||||
}
|
||||
|
||||
public function __construct(
|
||||
public Country $country,
|
||||
) {
|
||||
if (! in_array($this->country, self::authorized(), true)) {
|
||||
throw new \DomainException(
|
||||
sprintf('Country "%s" is not authorized.', $this->country->name)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<Country>
|
||||
*/
|
||||
public static function authorizedCountries(): array
|
||||
{
|
||||
return [
|
||||
Country::FRANCE,
|
||||
...Country::benelux(),
|
||||
];
|
||||
}
|
||||
|
||||
#[Override]
|
||||
public function equals(mixed $other): bool
|
||||
{
|
||||
return $other instanceof self && $this->country === $other->country;
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->country->value;
|
||||
}
|
||||
}
|
||||
|
|
@ -4,14 +4,14 @@ declare(strict_types=1);
|
|||
|
||||
namespace Domain\Models\ValueObjects\Coupon;
|
||||
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Shared\DDD\Models\Equatable;
|
||||
use Shared\Enums\Country;
|
||||
|
||||
final readonly class CouponLegalInformation implements Equatable
|
||||
{
|
||||
public function __construct(
|
||||
public string $legalText,
|
||||
public CountryAuthorized $forLocale
|
||||
public Country $forLocale
|
||||
) {
|
||||
if (mb_trim($this->legalText) === '') {
|
||||
throw new \DomainException('Legal text cannot be empty.');
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Domain\Models\ValueObjects\Coupon;
|
||||
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Shared\DDD\Models\Equatable;
|
||||
use Shared\Enums\Country;
|
||||
|
||||
final readonly class CouponProductInfo implements Equatable
|
||||
{
|
||||
|
|
@ -13,7 +13,7 @@ final readonly class CouponProductInfo implements Equatable
|
|||
public string $name,
|
||||
public string $range,
|
||||
public string $validityText,
|
||||
public CountryAuthorized $forLocale
|
||||
public Country $forLocale
|
||||
) {
|
||||
$trimmedName = mb_trim($this->name);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ declare(strict_types=1);
|
|||
|
||||
namespace Domain\Models\ValueObjects\RequestedCoupon;
|
||||
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidity;
|
||||
use Domain\Models\ValueObjects\CouponName;
|
||||
use Domain\Models\ValueObjects\CouponPicture;
|
||||
|
|
@ -14,9 +13,11 @@ use Domain\Models\ValueObjects\MoneyAmount;
|
|||
use Domain\Models\ValueObjects\Period;
|
||||
use Domain\Models\ValueObjects\ProcessingCode;
|
||||
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
||||
use Shared\Enums\Country;
|
||||
|
||||
final readonly class RequestedCoupon
|
||||
{
|
||||
/** @var array<Country> $country */
|
||||
public function __construct(
|
||||
public CouponName $name,
|
||||
public CouponProductName $productName,
|
||||
|
|
@ -26,9 +27,16 @@ final readonly class RequestedCoupon
|
|||
public MoneyAmount $moneyAmount,
|
||||
public ProcessingCode $processingCode,
|
||||
public CouponPicture $couponPicture,
|
||||
public GS1 $gs1,
|
||||
public ?GS1 $gs1,
|
||||
public CouponValidity $couponValidity,
|
||||
public CountryAuthorized $country,
|
||||
public array $country,
|
||||
) {
|
||||
// TODO: règle de validation ici pour Country
|
||||
// Par défaut dans le tableau country il y aura Country::FRANCE
|
||||
// Si GS1 est non null alors il ya aura aussi Country::BENELUX
|
||||
// ça se passera au moment de la création donc peut être plutôt dans l'entité associée ?
|
||||
|
||||
|
||||
// JE viens de passer GS1 en nullable, donc il faudra peut être tester
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,591 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace Shared\Enums;
|
||||
|
||||
use Shared\DDD\Exceptions\UnknownCountryIsoCodeException;
|
||||
|
||||
enum Country: string
|
||||
{
|
||||
case AFGHANISTAN = 'afghanistan';
|
||||
case ALAND_ISLANDS = 'alandIslands';
|
||||
case ALBANIA = 'albania';
|
||||
case ALGERIA = 'algeria';
|
||||
case AMERICAN_SAMOA = 'americanSamoa';
|
||||
case ANDORRA = 'andorra';
|
||||
case ANGOLA = 'angola';
|
||||
case ANGUILLA = 'anguilla';
|
||||
case ANTARCTICA = 'antarctica';
|
||||
case ANTIGUA_AND_BARBUDA = 'antiguaAndBarbuda';
|
||||
case ARGENTINA = 'argentina';
|
||||
case ARMENIA = 'armenia';
|
||||
case ARUBA = 'aruba';
|
||||
case AUSTRALIA = 'australia';
|
||||
case AUSTRIA = 'austria';
|
||||
case AZERBAIJAN = 'azerbaijan';
|
||||
case BAHRAIN = 'bahrain';
|
||||
case BAHAMAS = 'bahamas';
|
||||
case BANGLADESH = 'bangladesh';
|
||||
case BARBADOS = 'barbados';
|
||||
case BELARUS = 'belarus';
|
||||
case BELGIUM = 'belgium';
|
||||
case BELIZE = 'belize';
|
||||
case BENIN = 'benin';
|
||||
case BERMUDA = 'bermuda';
|
||||
case BHUTAN = 'bhutan';
|
||||
case BOLIVIA_PLURINATIONAL_STATE_OF = 'boliviaPlurinationalStateOf';
|
||||
case BONAIRE_SINT_EUSTATIUS_AND_SABA = 'bonaireSintEustatiusAndSaba';
|
||||
case BOSNIA_AND_HERZEGOVINA = 'bosniaAndHerzegovina';
|
||||
case BOTSWANA = 'botswana';
|
||||
case BOUVET_ISLAND = 'bouvetIsland';
|
||||
case BRAZIL = 'brazil';
|
||||
case BRITISH_INDIAN_OCEAN_TERRITORY = 'britishIndianOceanTerritory';
|
||||
case BRUNEI_DARUSSALAM = 'bruneiDarussalam';
|
||||
case BULGARIA = 'bulgaria';
|
||||
case BURKINA_FASO = 'burkinaFaso';
|
||||
case BURUNDI = 'burundi';
|
||||
case CAMBODIA = 'cambodia';
|
||||
case CAMEROON = 'cameroon';
|
||||
case CANADA = 'canada';
|
||||
case CAPE_VERDE = 'capeVerde';
|
||||
case CAYMAN_ISLANDS = 'caymanIslands';
|
||||
case CENTRAL_AFRICAN_REPUBLIC = 'centralAfricanRepublic';
|
||||
case CHAD = 'chad';
|
||||
case CHILE = 'chile';
|
||||
case CHINA = 'china';
|
||||
case CHRISTMAS_ISLAND = 'christmasIsland';
|
||||
case COCOS_KEELING_ISLANDS = 'cocosKeelingIslands';
|
||||
case COLOMBIA = 'colombia';
|
||||
case COMOROS = 'comoros';
|
||||
case CONGO = 'congo';
|
||||
case CONGO_THE_DEMOCRATIC_REPUBLIC_OF_THE = 'congoTheDemocraticRepublicOfThe';
|
||||
case COOK_ISLANDS = 'cookIslands';
|
||||
case COSTA_RICA = 'costaRica';
|
||||
case COTE_DIVOIRE = 'coteDivoire';
|
||||
case CROATIA = 'croatia';
|
||||
case CUBA = 'cuba';
|
||||
case CURACAO = 'curacao';
|
||||
case CYPRUS = 'cyprus';
|
||||
case CZECH_REPUBLIC = 'czechRepublic';
|
||||
case DENMARK = 'denmark';
|
||||
case DJIBOUTI = 'djibouti';
|
||||
case DOMINICA = 'dominica';
|
||||
case DOMINICAN_REPUBLIC = 'dominicanRepublic';
|
||||
case ECUADOR = 'ecuador';
|
||||
case EGYPT = 'egypt';
|
||||
case EL_SALVADOR = 'elSalvador';
|
||||
case EQUATORIAL_GUINEA = 'equatorialGuinea';
|
||||
case ERITREA = 'eritrea';
|
||||
case ESTONIA = 'estonia';
|
||||
case ETHIOPIA = 'ethiopia';
|
||||
case FALKLAND_ISLANDS_MALVINAS = 'falklandIslandsMalvinas';
|
||||
case FAROE_ISLANDS = 'faroeIslands';
|
||||
case FIJI = 'fiji';
|
||||
case FINLAND = 'finland';
|
||||
case FRANCE = 'france';
|
||||
case FRENCH_GUIANA = 'frenchGuiana';
|
||||
case FRENCH_POLYNESIA = 'frenchPolynesia';
|
||||
case FRENCH_SOUTHERN_TERRITORIES = 'frenchSouthernTerritories';
|
||||
case GABON = 'gabon';
|
||||
case GAMBIA = 'gambia';
|
||||
case GEORGIA = 'georgia';
|
||||
case GERMANY = 'germany';
|
||||
case GHANA = 'ghana';
|
||||
case GIBRALTAR = 'gibraltar';
|
||||
case GREECE = 'greece';
|
||||
case GREENLAND = 'greenland';
|
||||
case GRENADA = 'grenada';
|
||||
case GUADELOUPE = 'guadeloupe';
|
||||
case GUAM = 'guam';
|
||||
case GUATEMALA = 'guatemala';
|
||||
case GUERNSEY = 'guernsey';
|
||||
case GUINEA = 'guinea';
|
||||
case GUINEA_BISSAU = 'guineaBissau';
|
||||
case GUYANA = 'guyana';
|
||||
case HAITI = 'haiti';
|
||||
case HEARD_ISLAND_AND_MCDONALD_ISLANDS = 'heardIslandAndMcdonaldIslands';
|
||||
case HOLY_SEE_VATICAN_CITY_STATE = 'holySeeVaticanCityState';
|
||||
case HONDURAS = 'honduras';
|
||||
case HONG_KONG = 'hongKong';
|
||||
case HUNGARY = 'hungary';
|
||||
case ICELAND = 'iceland';
|
||||
case INDIA = 'india';
|
||||
case INDONESIA = 'indonesia';
|
||||
case IRAN_ISLAMIC_REPUBLIC_OF = 'iranIslamicRepublicOf';
|
||||
case IRAQ = 'iraq';
|
||||
case IRELAND = 'ireland';
|
||||
case ISLE_OF_MAN = 'isleOfMan';
|
||||
case ISRAEL = 'israel';
|
||||
case ITALY = 'italy';
|
||||
case JAMAICA = 'jamaica';
|
||||
case JAPAN = 'japan';
|
||||
case JERSEY = 'jersey';
|
||||
case JORDAN = 'jordan';
|
||||
case KAZAKHSTAN = 'kazakhstan';
|
||||
case KENYA = 'kenya';
|
||||
case KIRIBATI = 'kiribati';
|
||||
case KOREA_DEMOCRATIC_PEOPLES_REPUBLIC_OF = 'koreaDemocraticPeoplesRepublicOf';
|
||||
case KOREA_REPUBLIC_OF = 'koreaRepublicOf';
|
||||
case KUWAIT = 'kuwait';
|
||||
case KYRGYZSTAN = 'kyrgyzstan';
|
||||
case LAO_PEOPLES_DEMOCRATIC_REPUBLIC = 'laoPeoplesDemocraticRepublic';
|
||||
case LATVIA = 'latvia';
|
||||
case LEBANON = 'lebanon';
|
||||
case LESOTHO = 'lesotho';
|
||||
case LIBERIA = 'liberia';
|
||||
case LIBYA = 'libya';
|
||||
case LIECHTENSTEIN = 'liechtenstein';
|
||||
case LITHUANIA = 'lithuania';
|
||||
case LUXEMBOURG = 'luxembourg';
|
||||
case MACAO = 'macao';
|
||||
case MACEDONIA_THE_FORMER_YUGOSLAV_REPUBLIC_OF = 'macedoniaTheFormerYugoslavRepublicOf';
|
||||
case MADAGASCAR = 'madagascar';
|
||||
case MALAWI = 'malawi';
|
||||
case MALAYSIA = 'malaysia';
|
||||
case MALDIVES = 'maldives';
|
||||
case MALI = 'mali';
|
||||
case MALTA = 'malta';
|
||||
case MARSHALL_ISLANDS = 'marshallIslands';
|
||||
case MARTINIQUE = 'martinique';
|
||||
case MAURITANIA = 'mauritania';
|
||||
case MAURITIUS = 'mauritius';
|
||||
case MAYOTTE = 'mayotte';
|
||||
case MEXICO = 'mexico';
|
||||
case MICRONESIA_FEDERATED_STATES_OF = 'micronesiaFederatedStatesOf';
|
||||
case MOLDOVA_REPUBLIC_OF = 'moldovaRepublicOf';
|
||||
case MONACO = 'monaco';
|
||||
case MONGOLIA = 'mongolia';
|
||||
case MONTENEGRO = 'montenegro';
|
||||
case MONTSERRAT = 'montserrat';
|
||||
case MOROCCO = 'morocco';
|
||||
case MOZAMBIQUE = 'mozambique';
|
||||
case MYANMAR = 'myanmar';
|
||||
case NAMIBIA = 'namibia';
|
||||
case NAURU = 'nauru';
|
||||
case NEPAL = 'nepal';
|
||||
case NETHERLANDS = 'netherlands';
|
||||
case NEW_CALEDONIA = 'newCaledonia';
|
||||
case NEW_ZEALAND = 'newZealand';
|
||||
case NICARAGUA = 'nicaragua';
|
||||
case NIGER = 'niger';
|
||||
case NIGERIA = 'nigeria';
|
||||
case NIUE = 'niue';
|
||||
case NORFOLK_ISLAND = 'norfolkIsland';
|
||||
case NORTHERN_MARIANA_ISLANDS = 'northernMarianaIslands';
|
||||
case NORWAY = 'norway';
|
||||
case OMAN = 'oman';
|
||||
case PAKISTAN = 'pakistan';
|
||||
case PALAU = 'palau';
|
||||
case PALESTINE_STATE_OF = 'palestineStateOf';
|
||||
case PANAMA = 'panama';
|
||||
case PAPUA_NEW_GUINEA = 'papuaNewGuinea';
|
||||
case PARAGUAY = 'paraguay';
|
||||
case PERU = 'peru';
|
||||
case PHILIPPINES = 'philippines';
|
||||
case PITCAIRN = 'pitcairn';
|
||||
case POLAND = 'poland';
|
||||
case PORTUGAL = 'portugal';
|
||||
case PUERTO_RICO = 'puertoRico';
|
||||
case QATAR = 'qatar';
|
||||
case REUNION = 'reunion';
|
||||
case ROMANIA = 'romania';
|
||||
case RUSSIAN_FEDERATION = 'russianFederation';
|
||||
case RWANDA = 'rwanda';
|
||||
case SAINT_BARTHELEMY = 'saintBarthelemy';
|
||||
case SAINT_HELENA_ASCENSION_AND_TRISTAN_DA_CUNHA = 'saintHelenaAscensionAndTristanDaCunha';
|
||||
case SAINT_KITTS_AND_NEVIS = 'saintKittsAndNevis';
|
||||
case SAINT_LUCIA = 'saintLucia';
|
||||
case SAINT_MARTIN_FRENCH_PART = 'saintMartinFrenchPart';
|
||||
case SAINT_PIERRE_AND_MIQUELON = 'saintPierreAndMiquelon';
|
||||
case SAINT_VINCENT_AND_THE_GRENADINES = 'saintVincentAndTheGrenadines';
|
||||
case SAMOA = 'samoa';
|
||||
case SAN_MARINO = 'sanMarino';
|
||||
case SAO_TOME_AND_PRINCIPE = 'saoTomeAndPrincipe';
|
||||
case SAUDI_ARABIA = 'saudiArabia';
|
||||
case SENEGAL = 'senegal';
|
||||
case SERBIA = 'serbia';
|
||||
case SEYCHELLES = 'seychelles';
|
||||
case SIERRA_LEONE = 'sierraLeone';
|
||||
case SINGAPORE = 'singapore';
|
||||
case SINT_MAARTEN_DUTCH_PART = 'sintMaartenDutchPart';
|
||||
case SLOVAKIA = 'slovakia';
|
||||
case SLOVENIA = 'slovenia';
|
||||
case SOLOMON_ISLANDS = 'solomonIslands';
|
||||
case SOMALIA = 'somalia';
|
||||
case SOUTH_AFRICA = 'southAfrica';
|
||||
case SOUTH_GEORGIA_AND_THE_SOUTH_SANDWICH_ISLANDS = 'southGeorgiaAndTheSouthSandwichIslands';
|
||||
case SOUTH_SUDAN = 'southSudan';
|
||||
case SPAIN = 'spain';
|
||||
case SRI_LANKA = 'sriLanka';
|
||||
case SUDAN = 'sudan';
|
||||
case SURINAME = 'suriname';
|
||||
case SVALBARD_AND_JAN_MAYEN = 'svalbardAndJanMayen';
|
||||
case SWAZILAND = 'swaziland';
|
||||
case SWEDEN = 'sweden';
|
||||
case SWITZERLAND = 'switzerland';
|
||||
case SYRIAN_ARAB_REPUBLIC = 'syrianArabRepublic';
|
||||
case TAIWAN_PROVINCE_OF_CHINA = 'taiwanProvinceOfChina';
|
||||
case TAJIKISTAN = 'tajikistan';
|
||||
case TANZANIA_UNITED_REPUBLIC_OF = 'tanzaniaUnitedRepublicOf';
|
||||
case THAILAND = 'thailand';
|
||||
case TIMOR_LESTE = 'timorLeste';
|
||||
case TOGO = 'togo';
|
||||
case TOKELAU = 'tokelau';
|
||||
case TONGA = 'tonga';
|
||||
case TRINIDAD_AND_TOBAGO = 'trinidadAndTobago';
|
||||
case TUNISIA = 'tunisia';
|
||||
case TURKEY = 'turkey';
|
||||
case TURKMENISTAN = 'turkmenistan';
|
||||
case TURKS_AND_CAICOS_ISLANDS = 'turksAndCaicosIslands';
|
||||
case TUVALU = 'tuvalu';
|
||||
case UGANDA = 'uganda';
|
||||
case UKRAINE = 'ukraine';
|
||||
case UNITED_ARAB_EMIRATES = 'unitedArabEmirates';
|
||||
case UNITED_KINGDOM = 'unitedKingdom';
|
||||
case UNITED_STATES = 'unitedStates';
|
||||
case UNITED_STATES_MINOR_OUTLYING_ISLANDS = 'unitedStatesMinorOutlyingIslands';
|
||||
case URUGUAY = 'uruguay';
|
||||
case UZBEKISTAN = 'uzbekistan';
|
||||
case VANUATU = 'vanuatu';
|
||||
case VENEZUELA_BOLIVARIAN_REPUBLIC_OF = 'venezuelaBolivarianRepublicOf';
|
||||
case VIET_NAM = 'vietNam';
|
||||
case VIRGIN_ISLANDS_BRITISH = 'virginIslandsBritish';
|
||||
case VIRGIN_ISLANDS_US = 'virginIslandsUs';
|
||||
case WALLIS_AND_FUTUNA = 'wallisAndFutuna';
|
||||
case WESTERN_SAHARA = 'westernSahara';
|
||||
case YEMEN = 'yemen';
|
||||
case ZAMBIA = 'zambia';
|
||||
case ZIMBABWE = 'zimbabwe';
|
||||
|
||||
/**
|
||||
* Optionnal labels definition
|
||||
*
|
||||
* @phpstan-ignore-next-line
|
||||
*/
|
||||
private const LABELS = [
|
||||
self::AFGHANISTAN->value => 'Afghanistan',
|
||||
self::ALAND_ISLANDS->value => 'Åland Islands',
|
||||
self::ALBANIA->value => 'Albania',
|
||||
self::ALGERIA->value => 'Algeria',
|
||||
self::AMERICAN_SAMOA->value => 'American Samoa',
|
||||
self::ANDORRA->value => 'Andorra',
|
||||
self::ANGOLA->value => 'Angola',
|
||||
self::ANGUILLA->value => 'Anguilla',
|
||||
self::ANTARCTICA->value => 'Antarctica',
|
||||
self::ANTIGUA_AND_BARBUDA->value => 'Antigua and Barbuda',
|
||||
self::ARGENTINA->value => 'Argentina',
|
||||
self::ARMENIA->value => 'Armenia',
|
||||
self::ARUBA->value => 'Aruba',
|
||||
self::AUSTRALIA->value => 'Australia',
|
||||
self::AUSTRIA->value => 'Austria',
|
||||
self::AZERBAIJAN->value => 'Azerbaijan',
|
||||
self::BAHRAIN->value => 'Bahrain',
|
||||
self::BAHAMAS->value => 'Bahamas',
|
||||
self::BANGLADESH->value => 'Bangladesh',
|
||||
self::BARBADOS->value => 'Barbados',
|
||||
self::BELARUS->value => 'Belarus',
|
||||
self::BELGIUM->value => 'Belgium',
|
||||
self::BELIZE->value => 'Belize',
|
||||
self::BENIN->value => 'Benin',
|
||||
self::BERMUDA->value => 'Bermuda',
|
||||
self::BHUTAN->value => 'Bhutan',
|
||||
self::BOLIVIA_PLURINATIONAL_STATE_OF->value => 'Bolivia, Plurinational State of',
|
||||
self::BONAIRE_SINT_EUSTATIUS_AND_SABA->value => 'Bonaire, Sint Eustatius and Saba',
|
||||
self::BOSNIA_AND_HERZEGOVINA->value => 'Bosnia and Herzegovina',
|
||||
self::BOTSWANA->value => 'Botswana',
|
||||
self::BOUVET_ISLAND->value => 'Bouvet Island',
|
||||
self::BRAZIL->value => 'Brazil',
|
||||
self::BRITISH_INDIAN_OCEAN_TERRITORY->value => 'British Indian Ocean Territory',
|
||||
self::BRUNEI_DARUSSALAM->value => 'Brunei Darussalam',
|
||||
self::BULGARIA->value => 'Bulgaria',
|
||||
self::BURKINA_FASO->value => 'Burkina Faso',
|
||||
self::BURUNDI->value => 'Burundi',
|
||||
self::CAMBODIA->value => 'Cambodia',
|
||||
self::CAMEROON->value => 'Cameroon',
|
||||
self::CANADA->value => 'Canada',
|
||||
self::CAPE_VERDE->value => 'Cape Verde',
|
||||
self::CAYMAN_ISLANDS->value => 'Cayman Islands',
|
||||
self::CENTRAL_AFRICAN_REPUBLIC->value => 'Central African Republic',
|
||||
self::CHAD->value => 'Chad',
|
||||
self::CHILE->value => 'Chile',
|
||||
self::CHINA->value => 'China',
|
||||
self::CHRISTMAS_ISLAND->value => 'Christmas Island',
|
||||
self::COCOS_KEELING_ISLANDS->value => 'Cocos (Keeling) Islands',
|
||||
self::COLOMBIA->value => 'Colombia',
|
||||
self::COMOROS->value => 'Comoros',
|
||||
self::CONGO->value => 'Congo',
|
||||
self::CONGO_THE_DEMOCRATIC_REPUBLIC_OF_THE->value => 'Congo, the Democratic Republic of the',
|
||||
self::COOK_ISLANDS->value => 'Cook Islands',
|
||||
self::COSTA_RICA->value => 'Costa Rica',
|
||||
self::COTE_DIVOIRE->value => 'Côte d\'Ivoire',
|
||||
self::CROATIA->value => 'Croatia',
|
||||
self::CUBA->value => 'Cuba',
|
||||
self::CURACAO->value => 'Curaçao',
|
||||
self::CYPRUS->value => 'Cyprus',
|
||||
self::CZECH_REPUBLIC->value => 'Czech Republic',
|
||||
self::DENMARK->value => 'Denmark',
|
||||
self::DJIBOUTI->value => 'Djibouti',
|
||||
self::DOMINICA->value => 'Dominica',
|
||||
self::DOMINICAN_REPUBLIC->value => 'Dominican Republic',
|
||||
self::ECUADOR->value => 'Ecuador',
|
||||
self::EGYPT->value => 'Egypt',
|
||||
self::EL_SALVADOR->value => 'El Salvador',
|
||||
self::EQUATORIAL_GUINEA->value => 'Equatorial Guinea',
|
||||
self::ERITREA->value => 'Eritrea',
|
||||
self::ESTONIA->value => 'Estonia',
|
||||
self::ETHIOPIA->value => 'Ethiopia',
|
||||
self::FALKLAND_ISLANDS_MALVINAS->value => 'Falkland Islands (Malvinas)',
|
||||
self::FAROE_ISLANDS->value => 'Faroe Islands',
|
||||
self::FIJI->value => 'Fiji',
|
||||
self::FINLAND->value => 'Finland',
|
||||
self::FRANCE->value => 'France',
|
||||
self::FRENCH_GUIANA->value => 'French Guiana',
|
||||
self::FRENCH_POLYNESIA->value => 'French Polynesia',
|
||||
self::FRENCH_SOUTHERN_TERRITORIES->value => 'French Southern Territories',
|
||||
self::GABON->value => 'Gabon',
|
||||
self::GAMBIA->value => 'Gambia',
|
||||
self::GEORGIA->value => 'Georgia',
|
||||
self::GERMANY->value => 'Germany',
|
||||
self::GHANA->value => 'Ghana',
|
||||
self::GIBRALTAR->value => 'Gibraltar',
|
||||
self::GREECE->value => 'Greece',
|
||||
self::GREENLAND->value => 'Greenland',
|
||||
self::GRENADA->value => 'Grenada',
|
||||
self::GUADELOUPE->value => 'Guadeloupe',
|
||||
self::GUAM->value => 'Guam',
|
||||
self::GUATEMALA->value => 'Guatemala',
|
||||
self::GUERNSEY->value => 'Guernsey',
|
||||
self::GUINEA->value => 'Guinea',
|
||||
self::GUINEA_BISSAU->value => 'GuineaBissau',
|
||||
self::GUYANA->value => 'Guyana',
|
||||
self::HAITI->value => 'Haiti',
|
||||
self::HEARD_ISLAND_AND_MCDONALD_ISLANDS->value => 'Heard Island and McDonald Islands',
|
||||
self::HOLY_SEE_VATICAN_CITY_STATE->value => 'Holy See (Vatican City State)',
|
||||
self::HONDURAS->value => 'Honduras',
|
||||
self::HONG_KONG->value => 'Hong Kong',
|
||||
self::HUNGARY->value => 'Hungary',
|
||||
self::ICELAND->value => 'Iceland',
|
||||
self::INDIA->value => 'India',
|
||||
self::INDONESIA->value => 'Indonesia',
|
||||
self::IRAN_ISLAMIC_REPUBLIC_OF->value => 'Iran, Islamic Republic of',
|
||||
self::IRAQ->value => 'Iraq',
|
||||
self::IRELAND->value => 'Ireland',
|
||||
self::ISLE_OF_MAN->value => 'Isle of Man',
|
||||
self::ISRAEL->value => 'Israel',
|
||||
self::ITALY->value => 'Italy',
|
||||
self::JAMAICA->value => 'Jamaica',
|
||||
self::JAPAN->value => 'Japan',
|
||||
self::JERSEY->value => 'Jersey',
|
||||
self::JORDAN->value => 'Jordan',
|
||||
self::KAZAKHSTAN->value => 'Kazakhstan',
|
||||
self::KENYA->value => 'Kenya',
|
||||
self::KIRIBATI->value => 'Kiribati',
|
||||
self::KOREA_DEMOCRATIC_PEOPLES_REPUBLIC_OF->value => 'Korea, Democratic People\'s Republic of',
|
||||
self::KOREA_REPUBLIC_OF->value => 'Korea, Republic of',
|
||||
self::KUWAIT->value => 'Kuwait',
|
||||
self::KYRGYZSTAN->value => 'Kyrgyzstan',
|
||||
self::LAO_PEOPLES_DEMOCRATIC_REPUBLIC->value => 'Lao People\'s Democratic Republic',
|
||||
self::LATVIA->value => 'Latvia',
|
||||
self::LEBANON->value => 'Lebanon',
|
||||
self::LESOTHO->value => 'Lesotho',
|
||||
self::LIBERIA->value => 'Liberia',
|
||||
self::LIBYA->value => 'Libya',
|
||||
self::LIECHTENSTEIN->value => 'Liechtenstein',
|
||||
self::LITHUANIA->value => 'Lithuania',
|
||||
self::LUXEMBOURG->value => 'Luxembourg',
|
||||
self::MACAO->value => 'Macao',
|
||||
self::MACEDONIA_THE_FORMER_YUGOSLAV_REPUBLIC_OF->value => 'Macedonia, the Former Yugoslav Republic of',
|
||||
self::MADAGASCAR->value => 'Madagascar',
|
||||
self::MALAWI->value => 'Malawi',
|
||||
self::MALAYSIA->value => 'Malaysia',
|
||||
self::MALDIVES->value => 'Maldives',
|
||||
self::MALI->value => 'Mali',
|
||||
self::MALTA->value => 'Malta',
|
||||
self::MARSHALL_ISLANDS->value => 'Marshall Islands',
|
||||
self::MARTINIQUE->value => 'Martinique',
|
||||
self::MAURITANIA->value => 'Mauritania',
|
||||
self::MAURITIUS->value => 'Mauritius',
|
||||
self::MAYOTTE->value => 'Mayotte',
|
||||
self::MEXICO->value => 'Mexico',
|
||||
self::MICRONESIA_FEDERATED_STATES_OF->value => 'Micronesia, Federated States of',
|
||||
self::MOLDOVA_REPUBLIC_OF->value => 'Moldova, Republic of',
|
||||
self::MONACO->value => 'Monaco',
|
||||
self::MONGOLIA->value => 'Mongolia',
|
||||
self::MONTENEGRO->value => 'Montenegro',
|
||||
self::MONTSERRAT->value => 'Montserrat',
|
||||
self::MOROCCO->value => 'Morocco',
|
||||
self::MOZAMBIQUE->value => 'Mozambique',
|
||||
self::MYANMAR->value => 'Myanmar',
|
||||
self::NAMIBIA->value => 'Namibia',
|
||||
self::NAURU->value => 'Nauru',
|
||||
self::NEPAL->value => 'Nepal',
|
||||
self::NETHERLANDS->value => 'Netherlands',
|
||||
self::NEW_CALEDONIA->value => 'New Caledonia',
|
||||
self::NEW_ZEALAND->value => 'New Zealand',
|
||||
self::NICARAGUA->value => 'Nicaragua',
|
||||
self::NIGER->value => 'Niger',
|
||||
self::NIGERIA->value => 'Nigeria',
|
||||
self::NIUE->value => 'Niue',
|
||||
self::NORFOLK_ISLAND->value => 'Norfolk Island',
|
||||
self::NORTHERN_MARIANA_ISLANDS->value => 'Northern Mariana Islands',
|
||||
self::NORWAY->value => 'Norway',
|
||||
self::OMAN->value => 'Oman',
|
||||
self::PAKISTAN->value => 'Pakistan',
|
||||
self::PALAU->value => 'Palau',
|
||||
self::PALESTINE_STATE_OF->value => 'Palestine, State of',
|
||||
self::PANAMA->value => 'Panama',
|
||||
self::PAPUA_NEW_GUINEA->value => 'Papua New Guinea',
|
||||
self::PARAGUAY->value => 'Paraguay',
|
||||
self::PERU->value => 'Peru',
|
||||
self::PHILIPPINES->value => 'Philippines',
|
||||
self::PITCAIRN->value => 'Pitcairn',
|
||||
self::POLAND->value => 'Poland',
|
||||
self::PORTUGAL->value => 'Portugal',
|
||||
self::PUERTO_RICO->value => 'Puerto Rico',
|
||||
self::QATAR->value => 'Qatar',
|
||||
self::REUNION->value => 'Réunion',
|
||||
self::ROMANIA->value => 'Romania',
|
||||
self::RUSSIAN_FEDERATION->value => 'Russian Federation',
|
||||
self::RWANDA->value => 'Rwanda',
|
||||
self::SAINT_BARTHELEMY->value => 'Saint Barthélemy',
|
||||
self::SAINT_HELENA_ASCENSION_AND_TRISTAN_DA_CUNHA->value => 'Saint Helena, Ascension and Tristan da Cunha',
|
||||
self::SAINT_KITTS_AND_NEVIS->value => 'Saint Kitts and Nevis',
|
||||
self::SAINT_LUCIA->value => 'Saint Lucia',
|
||||
self::SAINT_MARTIN_FRENCH_PART->value => 'Saint Martin (French part)',
|
||||
self::SAINT_PIERRE_AND_MIQUELON->value => 'Saint Pierre and Miquelon',
|
||||
self::SAINT_VINCENT_AND_THE_GRENADINES->value => 'Saint Vincent and the Grenadines',
|
||||
self::SAMOA->value => 'Samoa',
|
||||
self::SAN_MARINO->value => 'San Marino',
|
||||
self::SAO_TOME_AND_PRINCIPE->value => 'Sao Tome and Principe',
|
||||
self::SAUDI_ARABIA->value => 'Saudi Arabia',
|
||||
self::SENEGAL->value => 'Senegal',
|
||||
self::SERBIA->value => 'Serbia',
|
||||
self::SEYCHELLES->value => 'Seychelles',
|
||||
self::SIERRA_LEONE->value => 'Sierra Leone',
|
||||
self::SINGAPORE->value => 'Singapore',
|
||||
self::SINT_MAARTEN_DUTCH_PART->value => 'Sint Maarten (Dutch part)',
|
||||
self::SLOVAKIA->value => 'Slovakia',
|
||||
self::SLOVENIA->value => 'Slovenia',
|
||||
self::SOLOMON_ISLANDS->value => 'Solomon Islands',
|
||||
self::SOMALIA->value => 'Somalia',
|
||||
self::SOUTH_AFRICA->value => 'South Africa',
|
||||
self::SOUTH_GEORGIA_AND_THE_SOUTH_SANDWICH_ISLANDS->value => 'South Georgia and the South Sandwich Islands',
|
||||
self::SOUTH_SUDAN->value => 'South Sudan',
|
||||
self::SPAIN->value => 'Spain',
|
||||
self::SRI_LANKA->value => 'Sri Lanka',
|
||||
self::SUDAN->value => 'Sudan',
|
||||
self::SURINAME->value => 'Suriname',
|
||||
self::SVALBARD_AND_JAN_MAYEN->value => 'Svalbard and Jan Mayen',
|
||||
self::SWAZILAND->value => 'Swaziland',
|
||||
self::SWEDEN->value => 'Sweden',
|
||||
self::SWITZERLAND->value => 'Switzerland',
|
||||
self::SYRIAN_ARAB_REPUBLIC->value => 'Syrian Arab Republic',
|
||||
self::TAIWAN_PROVINCE_OF_CHINA->value => 'Taiwan, Province of China',
|
||||
self::TAJIKISTAN->value => 'Tajikistan',
|
||||
self::TANZANIA_UNITED_REPUBLIC_OF->value => 'Tanzania, United Republic of',
|
||||
self::THAILAND->value => 'Thailand',
|
||||
self::TIMOR_LESTE->value => 'TimorLeste',
|
||||
self::TOGO->value => 'Togo',
|
||||
self::TOKELAU->value => 'Tokelau',
|
||||
self::TONGA->value => 'Tonga',
|
||||
self::TRINIDAD_AND_TOBAGO->value => 'Trinidad and Tobago',
|
||||
self::TUNISIA->value => 'Tunisia',
|
||||
self::TURKEY->value => 'Turkey',
|
||||
self::TURKMENISTAN->value => 'Turkmenistan',
|
||||
self::TURKS_AND_CAICOS_ISLANDS->value => 'Turks and Caicos Islands',
|
||||
self::TUVALU->value => 'Tuvalu',
|
||||
self::UGANDA->value => 'Uganda',
|
||||
self::UKRAINE->value => 'Ukraine',
|
||||
self::UNITED_ARAB_EMIRATES->value => 'United Arab Emirates',
|
||||
self::UNITED_KINGDOM->value => 'United Kingdom',
|
||||
self::UNITED_STATES->value => 'United States',
|
||||
self::UNITED_STATES_MINOR_OUTLYING_ISLANDS->value => 'United States Minor Outlying Islands',
|
||||
self::URUGUAY->value => 'Uruguay',
|
||||
self::UZBEKISTAN->value => 'Uzbekistan',
|
||||
self::VANUATU->value => 'Vanuatu',
|
||||
self::VENEZUELA_BOLIVARIAN_REPUBLIC_OF->value => 'Venezuela, Bolivarian Republic of',
|
||||
self::VIET_NAM->value => 'Viet Nam',
|
||||
self::VIRGIN_ISLANDS_BRITISH->value => 'Virgin Islands, British',
|
||||
self::VIRGIN_ISLANDS_US->value => 'Virgin Islands, U.S.',
|
||||
self::WALLIS_AND_FUTUNA->value => 'Wallis and Futuna',
|
||||
self::WESTERN_SAHARA->value => 'Western Sahara',
|
||||
self::YEMEN->value => 'Yemen',
|
||||
self::ZAMBIA->value => 'Zambia',
|
||||
self::ZIMBABWE->value => 'Zimbabwe',
|
||||
];
|
||||
/**
|
||||
* Custom added ISOCODES definition
|
||||
*/
|
||||
private const ISOCODES = [
|
||||
self::FRANCE->name => 'FR',
|
||||
self::GUADELOUPE->name => 'GSP',
|
||||
self::MARTINIQUE->name => 'MQ',
|
||||
self::FRENCH_GUIANA->name => 'GF',
|
||||
self::REUNION->name => 'RE',
|
||||
self::SAINT_PIERRE_AND_MIQUELON->name => 'PM',
|
||||
self::MAYOTTE->name => 'YT',
|
||||
self::SAINT_BARTHELEMY->name => 'BL',
|
||||
self::SAINT_MARTIN_FRENCH_PART->name => 'MF',
|
||||
self::WALLIS_AND_FUTUNA->name => 'WF',
|
||||
self::FRENCH_POLYNESIA->name => 'PF',
|
||||
self::NEW_CALEDONIA->name => 'NC',
|
||||
];
|
||||
|
||||
/**
|
||||
* Custom added Numerical ISOCODES definition
|
||||
*/
|
||||
private const ISOCODES_NUM = [
|
||||
self::FRANCE->name => 250,
|
||||
self::GUADELOUPE->name => 312,
|
||||
self::MARTINIQUE->name => 474,
|
||||
self::FRENCH_GUIANA->name => 254,
|
||||
self::REUNION->name => 638,
|
||||
self::SAINT_PIERRE_AND_MIQUELON->name => 666,
|
||||
self::MAYOTTE->name => 175,
|
||||
self::SAINT_BARTHELEMY->name => 652,
|
||||
self::SAINT_MARTIN_FRENCH_PART->name => 663,
|
||||
self::WALLIS_AND_FUTUNA->name => 876,
|
||||
self::FRENCH_POLYNESIA->name => 258,
|
||||
self::NEW_CALEDONIA->name => 540,
|
||||
];
|
||||
|
||||
/**
|
||||
* Get ISOCODE
|
||||
*/
|
||||
public function iso(): string
|
||||
{
|
||||
return self::ISOCODES[$this->name] ?? throw UnknownCountryIsoCodeException::fromCountry($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ISOCODE NUM
|
||||
*/
|
||||
public function isoNum(): int
|
||||
{
|
||||
return self::ISOCODES_NUM[$this->name] ?? throw UnknownCountryIsoCodeException::fromCountry($this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ISOCODE
|
||||
*/
|
||||
public function isoCode(): ?string
|
||||
{
|
||||
return self::ISOCODES[$this->name] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get enum ISOCODES
|
||||
*
|
||||
* @return array<string,string>
|
||||
*/
|
||||
public static function toIsoCodes(): array
|
||||
{
|
||||
return self::ISOCODES;
|
||||
}
|
||||
|
||||
public static function benelux(): array
|
||||
{
|
||||
return [
|
||||
self::BELGIUM,
|
||||
self::LUXEMBOURG
|
||||
];
|
||||
}
|
||||
case FRANCE = 'france';
|
||||
case BENELUX = 'benelux';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ use Domain\Models\ValueObjects\Brand\BrandName;
|
|||
use Domain\Models\ValueObjects\CampaignRequest\Applicant;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestId;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\RejectionReason;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidity;
|
||||
use Domain\Models\ValueObjects\CouponName;
|
||||
use Domain\Models\ValueObjects\CouponPicture;
|
||||
|
|
@ -60,7 +59,7 @@ describe('find campaign request use case', function (): void {
|
|||
new CouponPicture(new PicturePath('coupons/product.jpg'), new PicturePath('coupons/thumbnail.jpg')),
|
||||
new GS1('01234567890128', BarcodeFormat::EAN13),
|
||||
new CouponValidity(30, new DateTime()),
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ 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\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidity;
|
||||
use Domain\Models\ValueObjects\CouponName;
|
||||
use Domain\Models\ValueObjects\CouponPicture;
|
||||
|
|
@ -53,7 +52,7 @@ describe('list campaigns request use case', function (): void {
|
|||
new CouponPicture(new PicturePath('coupons/product.jpg'), new PicturePath('coupons/thumbnail.jpg')),
|
||||
new GS1('01234567890128', BarcodeFormat::EAN13),
|
||||
new CouponValidity(30, new DateTime()),
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
);
|
||||
|
||||
$this->couponB = new RequestedCoupon(
|
||||
|
|
@ -67,7 +66,7 @@ describe('list campaigns request use case', function (): void {
|
|||
new CouponPicture(new PicturePath('coupons/product.jpg'), new PicturePath('coupons/thumbnail.jpg')),
|
||||
new GS1('01234567890128', BarcodeFormat::EAN13),
|
||||
new CouponValidity(30, new DateTime()),
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ use Domain\Models\ValueObjects\Brand\BrandCode;
|
|||
use Domain\Models\ValueObjects\CampaignRequest\Applicant;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\CampaignRequestId;
|
||||
use Domain\Models\ValueObjects\CampaignRequest\RejectionReason;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponValidity;
|
||||
use Domain\Models\ValueObjects\CouponName;
|
||||
use Domain\Models\ValueObjects\CouponPicture;
|
||||
|
|
@ -58,7 +57,7 @@ describe('reject campaign request use case', function (): void {
|
|||
new CouponPicture(new PicturePath('coupons/product.jpg'), new PicturePath('coupons/thumbnail.jpg')),
|
||||
new GS1('01234567890128', BarcodeFormat::EAN13),
|
||||
new CouponValidity(30, new DateTime()),
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@ describe('country', function (): void {
|
|||
it('has the expected cases with their backing values', function (): void {
|
||||
// THEN
|
||||
expect(Country::FRANCE->value)->toBe('france')
|
||||
->and(Country::BELGIUM->value)->toBe('belgium')
|
||||
->and(Country::LUXEMBOURG->value)->toBe('luxembourg');
|
||||
->and(Country::BENELUX->value)->toBe('benelux');
|
||||
});
|
||||
|
||||
it('exposes its case name', function (): void {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ use DateTime;
|
|||
use Shared\ValueObjects\Email;
|
||||
use Shared\ValueObjects\Money;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon;
|
||||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity;
|
||||
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
||||
|
|
@ -53,7 +52,7 @@ describe('campaign request', function (): void {
|
|||
new CouponPicture(new PicturePath('coupons/product.jpg'), new PicturePath('coupons/thumbnail.jpg')),
|
||||
new GS1('01234567890128', BarcodeFormat::EAN13),
|
||||
new CouponValidity(30, new DateTime()),
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,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\PrintRules;
|
||||
use Domain\Models\ValueObjects\ProcessingCode;
|
||||
use Domain\Models\ValueObjects\Stock\StockId;
|
||||
|
|
@ -43,7 +42,7 @@ describe('campaign', function (): void {
|
|||
$name = new CampaignName('Name');
|
||||
$publication = \boolval(0);
|
||||
$printAllAtOnce = \boolval(1);
|
||||
$availableIn = new CountryAuthorized(Country::FRANCE);
|
||||
$availableIn = Country::FRANCE;
|
||||
$coupons = [
|
||||
new CampaignCoupon(
|
||||
new ProcessingCode('PC1'),
|
||||
|
|
@ -88,7 +87,7 @@ describe('campaign', function (): void {
|
|||
$name = new CampaignName('Name');
|
||||
$publication = \boolval(0);
|
||||
$printAllAtOnce = \boolval(1);
|
||||
$availableIn = new CountryAuthorized(Country::FRANCE);
|
||||
$availableIn = Country::FRANCE;
|
||||
$coupons = [];
|
||||
$brand = new BrandCode('AAA01');
|
||||
|
||||
|
|
@ -116,7 +115,7 @@ describe('campaign', function (): void {
|
|||
$name = new CampaignName('Name');
|
||||
$publication = \boolval(0);
|
||||
$printAllAtOnce = \boolval(1);
|
||||
$availableIn = new CountryAuthorized(Country::FRANCE);
|
||||
$availableIn = Country::FRANCE;
|
||||
$coupons = [
|
||||
new CampaignCoupon(
|
||||
new ProcessingCode('PC1'),
|
||||
|
|
@ -153,7 +152,7 @@ describe('campaign', function (): void {
|
|||
$name = new CampaignName('Name');
|
||||
$publication = \boolval(0);
|
||||
$printAllAtOnce = \boolval(1);
|
||||
$availableIn = new CountryAuthorized(Country::FRANCE);
|
||||
$availableIn = Country::FRANCE;
|
||||
$coupons = [
|
||||
new CampaignCoupon(
|
||||
new ProcessingCode('PC1'),
|
||||
|
|
@ -196,7 +195,7 @@ describe('campaign', function (): void {
|
|||
$name = new CampaignName('Name');
|
||||
$publication = \boolval(0);
|
||||
$printAllAtOnce = \boolval(1);
|
||||
$availableIn = new CountryAuthorized(Country::FRANCE);
|
||||
$availableIn = Country::FRANCE;
|
||||
$coupons = [
|
||||
new CampaignCoupon(
|
||||
new ProcessingCode('PC1'),
|
||||
|
|
@ -244,7 +243,7 @@ describe('campaign', function (): void {
|
|||
new CampaignName('Name'),
|
||||
\boolval(0),
|
||||
\boolval(1),
|
||||
new CountryAuthorized(Country::FRANCE),
|
||||
Country::FRANCE,
|
||||
[
|
||||
new CampaignCoupon(
|
||||
new ProcessingCode('PC1'),
|
||||
|
|
@ -270,7 +269,7 @@ describe('campaign', function (): void {
|
|||
$name = new CampaignName('Name');
|
||||
$publication = \boolval(0);
|
||||
$printAllAtOnce = \boolval(1);
|
||||
$availableIn = new CountryAuthorized(Country::FRANCE);
|
||||
$availableIn = Country::FRANCE;
|
||||
$coupons = ['PC1'];
|
||||
$brand = new BrandCode('AAA01');
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ use Shared\Enums\Country;
|
|||
use Domain\Models\Entities\Coupon;
|
||||
use Domain\Models\ValueObjects\Actor\ActorId;
|
||||
use Domain\Models\ValueObjects\Brand\BrandCode;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponAvailabilityCalendar;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponDiffusion;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponId;
|
||||
|
|
@ -52,7 +51,7 @@ describe('coupon', function (): void {
|
|||
$legalInformation = [
|
||||
new CouponLegalInformation(
|
||||
'Lorem ipsum dolor sit amet consectetur adipiscing elit.',
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
)
|
||||
];
|
||||
$code = new ProcessingCode('5425003944130');
|
||||
|
|
@ -114,7 +113,7 @@ describe('coupon', function (): void {
|
|||
$legalInformation = [
|
||||
new CouponLegalInformation(
|
||||
'Lorem ipsum dolor sit amet consectetur adipiscing elit.',
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
)
|
||||
];
|
||||
$code = new ProcessingCode('5425003944130');
|
||||
|
|
@ -173,7 +172,7 @@ describe('coupon', function (): void {
|
|||
$legalInformation = [
|
||||
new CouponLegalInformation(
|
||||
'Lorem ipsum dolor sit amet consectetur adipiscing elit.',
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
)
|
||||
];
|
||||
$code = new ProcessingCode('5425003944130');
|
||||
|
|
@ -221,7 +220,7 @@ describe('coupon', function (): void {
|
|||
$legalInformation = [
|
||||
new CouponLegalInformation(
|
||||
'Lorem ipsum dolor sit amet consectetur adipiscing elit.',
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
)
|
||||
];
|
||||
$code = new ProcessingCode('5425003944130');
|
||||
|
|
@ -281,7 +280,7 @@ describe('coupon', function (): void {
|
|||
$legalInformation = [
|
||||
new CouponLegalInformation(
|
||||
'Lorem ipsum dolor sit amet consectetur adipiscing elit.',
|
||||
new CountryAuthorized(Country::FRANCE)
|
||||
Country::FRANCE
|
||||
)
|
||||
];
|
||||
$code = new ProcessingCode('5425003944130');
|
||||
|
|
@ -342,7 +341,7 @@ describe('coupon', function (): void {
|
|||
new CouponDiffusion([new Period(new DateTime('2026-01-01'), new DateTime('2026-02-01'))]),
|
||||
new CouponAvailabilityCalendar([new Period(new DateTime('2026-08-25'), new DateTime('2026-10-31'))]),
|
||||
new CouponValidity(30, new DateTime('2026-11-30')),
|
||||
[new CouponLegalInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', new CountryAuthorized(Country::FRANCE))],
|
||||
[new CouponLegalInformation('Lorem ipsum dolor sit amet consectetur adipiscing elit.', Country::FRANCE)],
|
||||
new ProcessingCode('5425003944130'),
|
||||
new BrandCode('AAA01'),
|
||||
ActorId::generate(),
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Domain\Models\ValueObjects;
|
||||
|
||||
use Shared\Enums\Country;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
|
||||
covers(CountryAuthorized::class);
|
||||
|
||||
describe('country authorized', function (): void {
|
||||
it('creates a valid authorized country', function (string $case): void {
|
||||
// GIVEN
|
||||
$country = Country::from($case);
|
||||
|
||||
// WHEN
|
||||
$authorized = new CountryAuthorized($country);
|
||||
|
||||
// THEN
|
||||
expect($authorized)->toBeInstanceOf(CountryAuthorized::class)
|
||||
->and($authorized->country)->toBe($country);
|
||||
})->with([
|
||||
'france' => 'france',
|
||||
'belgium' => 'belgium',
|
||||
'luxembourg' => 'luxembourg',
|
||||
]);
|
||||
|
||||
it('rejects a country that is not authorized', function (): void {
|
||||
// WHEN
|
||||
$action = fn (): CountryAuthorized => new CountryAuthorized(Country::GERMANY);
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(\DomainException::class, 'Country "GERMANY" is not authorized.');
|
||||
});
|
||||
|
||||
it('lists the authorized countries', function (): void {
|
||||
// THEN
|
||||
expect(CountryAuthorized::authorizedCountries())->toBe([
|
||||
Country::FRANCE,
|
||||
Country::BELGIUM,
|
||||
Country::LUXEMBOURG,
|
||||
]);
|
||||
});
|
||||
|
||||
it('implements equals correctly', function (): void {
|
||||
// GIVEN
|
||||
$france1 = new CountryAuthorized(Country::FRANCE);
|
||||
$france2 = new CountryAuthorized(Country::FRANCE);
|
||||
$belgium = new CountryAuthorized(Country::BELGIUM);
|
||||
|
||||
// THEN
|
||||
expect($france1->equals($france2))->toBeTrue()
|
||||
->and($france1->equals($belgium))->toBeFalse()
|
||||
->and($france1->equals(null))->toBeFalse();
|
||||
});
|
||||
|
||||
it('converts to string as the country backing value', function (): void {
|
||||
// GIVEN
|
||||
$authorized = new CountryAuthorized(Country::FRANCE);
|
||||
|
||||
// THEN
|
||||
expect((string) $authorized)->toBe('france');
|
||||
});
|
||||
});
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Unit\Domain\Models\ValueObjects;
|
||||
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Shared\Enums\Country;
|
||||
|
||||
covers(CountryAuthorized::class);
|
||||
|
||||
describe('country authorized', function (): void {
|
||||
it('creates a valid authorized country', function (string $case): void {
|
||||
// GIVEN
|
||||
$country = Country::from($case);
|
||||
|
||||
// WHEN
|
||||
$authorized = new CountryAuthorized($country);
|
||||
|
||||
// THEN
|
||||
expect($authorized)->toBeInstanceOf(CountryAuthorized::class)
|
||||
->and($authorized->country)->toBe($country);
|
||||
})->with([
|
||||
'france' => 'france',
|
||||
'belgium' => 'belgium',
|
||||
'luxembourg' => 'luxembourg',
|
||||
]);
|
||||
|
||||
it('rejects a country that is not authorized', function (): void {
|
||||
// WHEN
|
||||
$action = fn (): CountryAuthorized => new CountryAuthorized(Country::GERMANY);
|
||||
|
||||
// THEN
|
||||
expect($action)->toThrow(\DomainException::class, 'Country "GERMANY" is not authorized.');
|
||||
});
|
||||
|
||||
it('lists the authorized countries', function (): void {
|
||||
// THEN
|
||||
expect(CountryAuthorized::authorizedCountries())->toBe([
|
||||
Country::FRANCE,
|
||||
Country::BELGIUM,
|
||||
Country::LUXEMBOURG,
|
||||
]);
|
||||
});
|
||||
|
||||
it('implements equals correctly', function (): void {
|
||||
// GIVEN
|
||||
$france1 = new CountryAuthorized(Country::FRANCE);
|
||||
$france2 = new CountryAuthorized(Country::FRANCE);
|
||||
$belgium = new CountryAuthorized(Country::BELGIUM);
|
||||
|
||||
// THEN
|
||||
expect($france1->equals($france2))->toBeTrue()
|
||||
->and($france1->equals($belgium))->toBeFalse()
|
||||
->and($france1->equals(null))->toBeFalse();
|
||||
});
|
||||
|
||||
it('converts to string as the country backing value', function (): void {
|
||||
// GIVEN
|
||||
$authorized = new CountryAuthorized(Country::FRANCE);
|
||||
|
||||
// THEN
|
||||
expect((string) $authorized)->toBe('france');
|
||||
});
|
||||
});
|
||||
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Tests\Unit\Domain\Models\ValueObjects;
|
||||
|
||||
use Shared\Enums\Country;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponLegalInformation;
|
||||
|
||||
covers(CouponLegalInformation::class);
|
||||
|
|
@ -14,7 +13,7 @@ describe('coupon legal information', function (): void {
|
|||
it('creates a valid coupon legal information', function (): void {
|
||||
// GIVEN
|
||||
$legalText = 'Lorem ipsum dolor sit amet consectetur adipiscing elit.';
|
||||
$forLocale = new CountryAuthorized(Country::FRANCE);
|
||||
$forLocale = Country::FRANCE;
|
||||
|
||||
// WHEN
|
||||
$couponLegalInformation = new CouponLegalInformation($legalText, $forLocale);
|
||||
|
|
@ -27,7 +26,7 @@ describe('coupon legal information', function (): void {
|
|||
it('rejects invalid coupon legal information', function (): void {
|
||||
// GIVEN
|
||||
$legalText = '';
|
||||
$forLocale = new CountryAuthorized(Country::FRANCE);
|
||||
$forLocale = Country::FRANCE;
|
||||
|
||||
// GIVEN / THEN
|
||||
expect(fn (): CouponLegalInformation => new CouponLegalInformation($legalText, $forLocale))->toThrow(\DomainException::class);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ declare(strict_types=1);
|
|||
namespace Tests\Unit\Domain\Models\ValueObjects;
|
||||
|
||||
use Shared\Enums\Country;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\Coupon\CouponProductInfo;
|
||||
|
||||
covers(CouponProductInfo::class);
|
||||
|
|
@ -16,7 +15,7 @@ describe('coupon product info', function (): void {
|
|||
$name = 'Lorem ipsum';
|
||||
$range = 'Lorem';
|
||||
$validityText = 'Lorem ipsum dolor sit amet consectetur adipiscing elit.';
|
||||
$forLocale = new CountryAuthorized(Country::FRANCE);
|
||||
$forLocale = Country::FRANCE;
|
||||
|
||||
// WHEN
|
||||
$couponProductInfo = new CouponProductInfo($name, $range, $validityText, $forLocale);
|
||||
|
|
@ -33,7 +32,7 @@ describe('coupon product info', function (): void {
|
|||
$name = '';
|
||||
$range = '';
|
||||
$validityText = '';
|
||||
$forLocale = new CountryAuthorized(Country::FRANCE);
|
||||
$forLocale = Country::FRANCE;
|
||||
|
||||
// GIVEN / THEN
|
||||
expect(fn (): CouponProductInfo => new CouponProductInfo($name, $range, $validityText, $forLocale))->toThrow(\DomainException::class);
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ use Domain\Models\ValueObjects\RequestedCoupon\RequestedCouponQuantity;
|
|||
use Domain\Models\ValueObjects\WarningThresholdQuantity;
|
||||
use Shared\Enums\Currency;
|
||||
use DateTime;
|
||||
use Domain\Models\ValueObjects\CountryAuthorized;
|
||||
use Domain\Models\ValueObjects\RequestedCoupon\RequestedCoupon;
|
||||
use Shared\Enums\Country;
|
||||
use Shared\ValueObjects\Money;
|
||||
|
|
@ -43,7 +42,7 @@ describe('requested coupon', function (): void {
|
|||
$couponPicture = new CouponPicture(new PicturePath('coupons/product.jpg'), new PicturePath('coupons/thumbnail.jpg'));
|
||||
$gs1 = new GS1('01234567890128', BarcodeFormat::EAN13);
|
||||
$couponValidity = new CouponValidity(30, new DateTime());
|
||||
$country = new CountryAuthorized(Country::FRANCE);
|
||||
$country = Country::FRANCE;
|
||||
// WHEN
|
||||
$coupon = new RequestedCoupon(
|
||||
$name,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue