getTestTimestamp example

 void {
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $customer = new CustomerEntity();
        $customer->setFirstLogin($day);

        if ($noCustomer) {
            $customer = null;
        }
        $salesChannelContext->method('getCustomer')->willReturn($customer);
        $scope = $this->createMock(CheckoutRuleScope::class);
        $scope->method('getSalesChannelContext')->willReturn($salesChannelContext);
        $scope->method('getCurrentTime')->willReturn(self::getTestTimestamp());

        $this->rule->assign([
            'operator' => $operator,
            'daysPassed' => $daysPassed,
        ]);

        $match = $this->rule->match($scope);

        if ($isMatching) {
            static::assertTrue($match);
        } else {
            
$result = $rule->match($this->getMockForAbstractClass(RuleScope::class));

        static::assertFalse($result);
    }

    public function testRuleMatchesWithDayBefore(): void
    {
        $checkoutContext = $this->createMock(SalesChannelContext::class);
        $customer = new CustomerEntity();

        $datetime = self::getTestTimestamp();

        $checkoutContext->method('getCustomer')
            ->willReturn($customer);
        $customer->setLastOrderDate($datetime->modify('-1 day'));

        $scope = $this->createMock(CheckoutRuleScope::class);
        $scope->method('getCurrentTime')->willReturn(self::getTestTimestamp());
        $scope->method('getSalesChannelContext')->willReturn($checkoutContext);

        $rule = new DaysSinceLastOrderRule();
        $rule->assign(['daysPassed' => 1, 'operator' => Rule::OPERATOR_EQ]);

        
 void {
        $salesChannelContext = $this->createMock(SalesChannelContext::class);
        $customer = new CustomerEntity();
        $customer->setLastLogin($day);

        if ($noCustomer) {
            $customer = null;
        }
        $salesChannelContext->method('getCustomer')->willReturn($customer);
        $scope = $this->createMock(CheckoutRuleScope::class);
        $scope->method('getSalesChannelContext')->willReturn($salesChannelContext);
        $scope->method('getCurrentTime')->willReturn(self::getTestTimestamp());

        $this->rule->assign([
            'operator' => $operator,
            'daysPassed' => $daysPassed,
        ]);

        $match = $this->rule->match($scope);

        if ($isMatching) {
            static::assertTrue($match);
        } else {
            
Home | Imprint | This part of the site doesn't use cookies.