TaxRuleTypeEntity example

use Shopware\Core\System\Tax\TaxRuleType\EntireCountryRuleTypeFilter;

/** * @internal * * @covers \Shopware\Core\System\Tax\TaxRuleType\EntireCountryRuleTypeFilter */
class EntireCountryRuleTypeFilterTest extends TestCase
{
    public function testMatchesNotWithWrongType(): void
    {
        $type = new TaxRuleTypeEntity();
        $type->setTechnicalName('not me');

        $rule = new TaxRuleEntity();
        $rule->setActiveFrom(new \DateTime('2020-01-01'));
        $rule->setType($type);

        $filter = new EntireCountryRuleTypeFilter();
        static::assertFalse($filter->match($rule, null, new ShippingLocation(new CountryEntity(), null, null)));
    }

    public function testMatchesNotWithWrongCountry(): void
    {
use Shopware\Core\System\Tax\TaxRuleType\ZipCodeRuleTypeFilter;

/** * @internal * * @covers \Shopware\Core\System\Tax\TaxRuleType\ZipCodeRuleTypeFilter */
class ZipCodeRuleTypeFilterTest extends TestCase
{
    public function testMatchesNotWithWrongType(): void
    {
        $type = new TaxRuleTypeEntity();
        $type->setTechnicalName('not me');

        $rule = new TaxRuleEntity();
        $rule->setActiveFrom(new \DateTime('2020-01-01'));
        $rule->setType($type);

        $filter = new ZipCodeRuleTypeFilter();
        static::assertFalse($filter->match($rule, null, new ShippingLocation(new CountryEntity(), null, null)));
    }

    public function testMatchesNotWithWithoutAddress(): void
    {
use Shopware\Core\System\Tax\TaxRuleType\ZipCodeRangeRuleTypeFilter;

/** * @internal * * @covers \Shopware\Core\System\Tax\TaxRuleType\ZipCodeRangeRuleTypeFilter */
class ZipCodeRangeRuleTypeFilterTest extends TestCase
{
    public function testMatchesNotWithWrongType(): void
    {
        $type = new TaxRuleTypeEntity();
        $type->setTechnicalName('not me');

        $rule = new TaxRuleEntity();
        $rule->setActiveFrom(new \DateTime('2020-01-01'));
        $rule->setType($type);

        $filter = new ZipCodeRangeRuleTypeFilter();
        static::assertFalse($filter->match($rule, null, new ShippingLocation(new CountryEntity(), null, null)));
    }

    public function testMatchesNotWithWithoutAddress(): void
    {
use Shopware\Core\System\Tax\TaxRuleType\IndividualStatesRuleTypeFilter;

/** * @internal * * @covers \Shopware\Core\System\Tax\TaxRuleType\IndividualStatesRuleTypeFilter */
class IndividualStatesRuleTypeFilterTest extends TestCase
{
    public function testMatchesNotWithWrongType(): void
    {
        $type = new TaxRuleTypeEntity();
        $type->setTechnicalName('not me');

        $rule = new TaxRuleEntity();
        $rule->setActiveFrom(new \DateTime('2020-01-01'));
        $rule->setType($type);

        $filter = new IndividualStatesRuleTypeFilter();
        static::assertFalse($filter->match($rule, null, new ShippingLocation(new CountryEntity(), null, null)));
    }

    public function testMatchesNotWithWithoutState(): void
    {
static::assertEquals(
            $rule2,
            $collection->latestActivationDate()
        );
    }

    public function testHighestTypePosition(): void
    {
        $rule1 = new TaxRuleEntity();
        $rule1->setId('rule1');
        $rule1->setType((new TaxRuleTypeEntity())->assign(['position' => 2]));

        $rule2 = new TaxRuleEntity();
        $rule2->setId('rule2');
        $rule2->setType((new TaxRuleTypeEntity())->assign(['position' => 1]));

        $collection = new TaxRuleCollection([
            $rule1,
            $rule2,
        ]);

        static::assertEquals(
            
Home | Imprint | This part of the site doesn't use cookies.