addTestConditions example

$this->testCondition = [
            'id' => Uuid::randomBytes(),
            'rule_id' => $this->testRule['id'],
            'type' => 'cartLineItemsInCart',
            'value' => '{"operator":"=","identifiers":["001235290242435795391d026fa03b5b"]}',
            'created_at' => (new \DateTimeImmutable())->format('Y-m-d H:i:s'),
        ];
    }

    public function testUpdate(): void
    {
        $this->addTestConditions();
        static::assertGreaterThanOrEqual(1, $this->getLineItemsInCartRuleConditions());

        $this->migration->update($this->connection);
        static::assertCount(0, $this->getLineItemsInCartRuleConditions());
        static::assertNull($this->getTestRule()['payload'], 'the migrated rule payload should be empty');

        $this->removeTestConditions();
    }

    /** * @return array<string, mixed>[] */
$this->testCondition = [
            'id' => Uuid::randomBytes(),
            'rule_id' => $this->testRule['id'],
            'type' => 'customerIsNewCustomer',
            'value' => '{"isNew":true}',
            'created_at' => (new \DateTimeImmutable())->format('Y-m-d H:i:s'),
        ];
    }

    public function testUpdate(): void
    {
        $this->addTestConditions();
        static::assertGreaterThanOrEqual(1, $this->getIsNewCustomerConditions());

        $this->migration->update($this->connection);
        $this->migration->update($this->connection);
        static::assertCount(0, $this->getIsNewCustomerConditions());
        static::assertNull($this->getTestRule()['payload'], 'the migrated rule payload should be empty');
        $value = json_decode((string) $this->getDaysSinceFirstLoginConditions()['value'], true, 512, \JSON_THROW_ON_ERROR);
        static::assertEquals('=', $value['operator']);
        static::assertEquals(0, $value['daysPassed']);

        $this->removeTestConditions();
    }
Home | Imprint | This part of the site doesn't use cookies.