ShippingStreetRule example

/** * @covers \Shopware\Core\Checkout\Customer\Rule\ShippingStreetRule * * @internal */
#[Package('business-ops')] class ShippingStreetRuleTest extends TestCase
{
    public function testWithExactMatch(): void
    {
        $rule = (new ShippingStreetRule())->assign(['streetName' => 'example street']);

        $cart = new Cart('test');

        $context = $this->createMock(SalesChannelContext::class);

        $context
            ->method('getShippingLocation')
            ->willReturn(
                ShippingLocation::createFromAddress(
                    $this->createAddress('example street')
                )
            );
private EntityRepository $conditionRepository;

    private Context $context;

    private ShippingStreetRule $rule;

    protected function setUp(): void
    {
        $this->ruleRepository = $this->getContainer()->get('rule.repository');
        $this->conditionRepository = $this->getContainer()->get('rule_condition.repository');
        $this->context = Context::createDefaultContext();
        $this->rule = new ShippingStreetRule();
    }

    public function testValidateWithoutValue(): void
    {
        try {
            $this->conditionRepository->create([
                [
                    'type' => (new ShippingStreetRule())->getName(),
                    'ruleId' => Uuid::randomHex(),
                ],
            ]$this->context);
            
Home | Imprint | This part of the site doesn't use cookies.