BillingStreetRule example

private EntityRepository $conditionRepository;

    private Context $context;

    private BillingStreetRule $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 BillingStreetRule();
    }

    public function testValidationWithMissingStreetName(): void
    {
        try {
            $this->conditionRepository->create([
                [
                    'type' => (new BillingStreetRule())->getName(),
                    'ruleId' => Uuid::randomHex(),
                ],
            ]$this->context);
            
/** * @covers \Shopware\Core\Checkout\Customer\Rule\BillingStreetRule * * @internal */
#[Package('business-ops')] class BillingStreetRuleTest extends TestCase
{
    public function testWithExactMatch(): void
    {
        $rule = (new BillingStreetRule())->assign(['streetName' => 'example street']);

        $cart = new Cart('test');

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

        $billing = new CustomerAddressEntity();
        $billing->setStreet('example street');

        $customer = new CustomerEntity();
        $customer->setDefaultBillingAddress($billing);

        
Home | Imprint | This part of the site doesn't use cookies.