default services conflit ?

This commit is contained in:
armansansd
2022-04-27 11:30:43 +02:00
parent 28190a5749
commit 8bb1064a3b
8132 changed files with 900138 additions and 426 deletions

View File

@@ -0,0 +1,58 @@
<?php
namespace CommerceGuys\Addressing\Tests\Zone;
use CommerceGuys\Addressing\Address;
use CommerceGuys\Addressing\Zone\ZoneTerritory;
use PHPUnit\Framework\TestCase;
/**
* @coversDefaultClass \CommerceGuys\Addressing\Zone\ZoneTerritory
*/
final class ZoneTerritoryTest extends TestCase
{
/**
* @covers ::__construct
*
* @expectedException \InvalidArgumentException
*/
public function testMissingProperty()
{
$territory = new ZoneTerritory([]);
}
/**
* @covers ::__construct
* @covers ::getCountryCode
* @covers ::getAdministrativeArea
* @covers ::getLocality
* @covers ::getDependentLocality
* @covers ::getIncludedPostalCodes
* @covers ::getExcludedPostalCodes
* @covers ::match
*/
public function testValid()
{
$definition = [
'country_code' => 'BR',
'administrative_area' => 'RJ',
'locality' => 'Areal',
'dependent_locality' => 'Random',
'included_postal_codes' => '123456',
'excluded_postal_codes' => '789',
];
$territory = new ZoneTerritory($definition);
$this->assertEquals($definition['country_code'], $territory->getCountryCode());
$this->assertEquals($definition['administrative_area'], $territory->getAdministrativeArea());
$this->assertEquals($definition['locality'], $territory->getLocality());
$this->assertEquals($definition['dependent_locality'], $territory->getDependentLocality());
$this->assertEquals($definition['included_postal_codes'], $territory->getIncludedPostalCodes());
$this->assertEquals($definition['excluded_postal_codes'], $territory->getExcludedPostalCodes());
$brazilian_address = new Address('BR', 'RJ', 'Areal', 'Random', '123456');
$serbian_address = new Address('RS');
$this->assertTrue($territory->match($brazilian_address));
$this->assertFalse($territory->match($serbian_address));
}
}

View File

@@ -0,0 +1,72 @@
<?php
namespace CommerceGuys\Addressing\Tests\Zone;
use CommerceGuys\Addressing\Address;
use CommerceGuys\Addressing\Zone\Zone;
use PHPUnit\Framework\TestCase;
/**
* @coversDefaultClass \CommerceGuys\Addressing\Zone\Zone
*/
final class ZoneTest extends TestCase
{
/**
* @covers ::__construct
*
* @expectedException \InvalidArgumentException
*/
public function testMissingProperty()
{
$definition = [
'id' => 'test',
];
$zone = new Zone($definition);
}
/**
* @covers ::__construct
*
* @expectedException \InvalidArgumentException
*/
public function testInvalidTerritories()
{
$definition = [
'id' => 'test',
'label' => 'Test',
'territories' => 'WRONG',
];
$zone = new Zone($definition);
}
/**
* @covers ::__construct
* @covers ::getId
* @covers ::getLabel
* @covers ::getTerritories
* @covers ::match
*/
public function testValid()
{
$definition = [
'id' => 'de_fr',
'label' => 'Germany and France',
'territories' => [
['country_code' => 'DE'],
['country_code' => 'FR'],
],
];
$zone = new Zone($definition);
$this->assertEquals($definition['id'], $zone->getId());
$this->assertEquals($definition['label'], $zone->getLabel());
$this->assertCount(2, $zone->getTerritories());
$this->assertEquals($definition['territories'][0]['country_code'], $zone->getTerritories()[0]->getCountryCode());
$this->assertEquals($definition['territories'][1]['country_code'], $zone->getTerritories()[1]->getCountryCode());
$german_address = new Address('DE');
$serbian_address = new Address('RS');
$this->assertTrue($zone->match($german_address));
$this->assertFalse($zone->match($serbian_address));
}
}