Make clock datetimeimmutable compatible with datetime type in mapping

(cherry picked from commit c1f02dd633)
This commit is contained in:
TheMilek 2026-02-09 22:25:14 +01:00 committed by Grzegorz Sadowski
parent 03bd383c9f
commit 5ded5aaff3
No known key found for this signature in database
GPG key ID: EF87FF4E6E3BD364
182 changed files with 431 additions and 414 deletions

View file

@ -101,6 +101,7 @@
"Payum\\Core\\Security\\TokenInterface",
"Payum\\Core\\Security\\Util\\Random",
"Payum\\Core\\Storage\\AbstractStorage",
"Payum\\Core\\Storage\\IdentityInterface",
"PHPUnit\\Framework\\ExpectationFailedException",
"PHPUnit\\Framework\\MockObject\\MockObject",
"PHPUnit\\Framework\\TestCase",

View file

@ -275,8 +275,8 @@ final readonly class ManagingCatalogPromotionsContext implements Context
public function iMakeCatalogPromotionOperateBetweenYesterdayAndTomorrow(): void
{
$this->client->updateRequestData([
'startDate' => (new \DateTimeImmutable('yesterday'))->format('Y-m-d H:i:s'),
'endDate' => (new \DateTimeImmutable('tomorrow'))->format('Y-m-d H:i:s'),
'startDate' => (new \DateTime('yesterday'))->format('Y-m-d H:i:s'),
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d H:i:s'),
]);
}
@ -902,15 +902,15 @@ final readonly class ManagingCatalogPromotionsContext implements Context
$response,
[
'name' => $catalogPromotion->getName(),
'startDate' => (new \DateTimeImmutable('yesterday'))->format('Y-m-d H:i:s'),
'endDate' => (new \DateTimeImmutable('tomorrow'))->format('Y-m-d H:i:s'),
'startDate' => (new \DateTime('yesterday'))->format('Y-m-d H:i:s'),
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d H:i:s'),
],
),
sprintf(
'Cannot find catalog promotions with name "%s" operating between "%s" and "%s" in the list',
$catalogPromotion->getName(),
(new \DateTimeImmutable('yesterday'))->format('Y-m-d H:i:s'),
(new \DateTimeImmutable('tomorrow'))->format('Y-m-d H:i:s'),
(new \DateTime('yesterday'))->format('Y-m-d H:i:s'),
(new \DateTime('tomorrow'))->format('Y-m-d H:i:s'),
),
);
}

View file

@ -755,7 +755,7 @@ final readonly class ManagingOrdersContext implements Context
Assert::same(
$this->responseChecker->getValue($response, 'shippedAt'),
(new \DateTimeImmutable($dateTime))->format('Y-m-d H:i:s'),
(new \DateTime($dateTime))->format('Y-m-d H:i:s'),
);
}

View file

@ -269,7 +269,7 @@ final readonly class ManagingPromotionCouponsContext implements Context
#[Then('this coupon should be valid until :date')]
public function thisCouponShouldBeValidUntil(\DateTime $date): void
{
$actualDate = \DateTimeImmutable::createFromFormat(
$actualDate = \DateTime::createFromFormat(
'Y-m-d h:i:s',
$this->responseChecker->getValue($this->client->getLastResponse(), 'expiresAt'),
);

View file

@ -174,8 +174,8 @@ final class ManagingShipmentsContext implements Context
public function iShouldSeeTheShippingDateAs(OrderInterface $order, string $dateTime): void
{
Assert::eq(
new \DateTimeImmutable($this->responseChecker->getValue($this->client->show(Resources::SHIPMENTS, (string) $order->getShipments()->first()->getId()), 'shippedAt')),
new \DateTimeImmutable($dateTime),
new \DateTime($this->responseChecker->getValue($this->client->show(Resources::SHIPMENTS, (string) $order->getShipments()->first()->getId()), 'shippedAt')),
new \DateTime($dateTime),
'Shipment was shipped in different date',
);
}

View file

@ -82,7 +82,7 @@ final class ProductAttributeContext implements Context
{
$attribute = $this->getAttributeByName($attributeName);
Assert::true(new \DateTimeImmutable($attribute['value']) == new \DateTimeImmutable($expectedAttribute));
Assert::true(new \DateTime($attribute['value']) == new \DateTime($expectedAttribute));
}
#[Then('I should see :count attributes')]

View file

@ -32,7 +32,7 @@ final class CartContext implements Context
#[Given('/^(?:|he|she) abandoned (the cart) (\d+) (day|days|hour|hours) ago$/')]
public function theyAbandonedTheirCart(OrderInterface $cart, $amount, $time)
{
$cart->setUpdatedAt(new \DateTimeImmutable('-' . $amount . ' ' . $time));
$cart->setUpdatedAt(new \DateTime('-' . $amount . ' ' . $time));
$this->orderManager->flush();
}

View file

@ -106,7 +106,7 @@ final class ManagingOrdersContext implements Context
#[Given('/^(this order) has not been paid for (\d+) (day|days|hour|hours)$/')]
public function thisOrderHasNotBeenPaidForDays(OrderInterface $order, $amount, $time)
{
$order->setCheckoutCompletedAt(new \DateTimeImmutable('-' . $amount . ' ' . $time));
$order->setCheckoutCompletedAt(new \DateTime('-' . $amount . ' ' . $time));
$this->orderManager->flush();
$this->unpaidOrdersStateUpdater->cancel();
@ -115,7 +115,7 @@ final class ManagingOrdersContext implements Context
#[Given('/^the (order "[^"]+") has not been paid for (\d+) (day|days)$/')]
public function orderWithNumberHasNotBeenPaidForDays(OrderInterface $order, int $amount, string $days): void
{
$order->setCheckoutCompletedAt(new \DateTimeImmutable(sprintf('-%d %s', $amount, $days)));
$order->setCheckoutCompletedAt(new \DateTime(sprintf('-%d %s', $amount, $days)));
$this->orderManager->flush();
}

View file

@ -51,7 +51,7 @@ final class ManagingPromotionsContext implements Context
#[When('I archive the :promotion promotion')]
public function iArchiveThePromotion(PromotionInterface $promotion): void
{
$promotion->setArchivedAt(new \DateTimeImmutable());
$promotion->setArchivedAt(new \DateTime());
$this->promotionManager->flush();
}

View file

@ -32,7 +32,7 @@ final class ManagingShippingMethodsContext implements Context
#[When('/^I archive the ("[^"]+" shipping method)$/')]
public function iArchiveTheShippingMethod(ShippingMethodInterface $shippingMethod)
{
$shippingMethod->setArchivedAt(new \DateTimeImmutable());
$shippingMethod->setArchivedAt(new \DateTime());
$this->shippingMethodManager->flush();
}

View file

@ -113,7 +113,7 @@ final class AdminUserContext implements Context
public function iHaveAlreadyReceivedAnAdministratorsPasswordResettingEmail(AdminUserInterface $administrator): void
{
$administrator->setPasswordResetToken('token');
$administrator->setPasswordRequestedAt(new \DateTimeImmutable());
$administrator->setPasswordRequestedAt(new \DateTime());
$this->objectManager->flush();
}
@ -121,7 +121,7 @@ final class AdminUserContext implements Context
#[Given('/^(my) password reset token has already expired$/')]
public function myPasswordResetTokenHasAlreadyExpired(AdminUserInterface $administrator): void
{
$administrator->setPasswordRequestedAt(new \DateTimeImmutable('-1 year'));
$administrator->setPasswordRequestedAt(new \DateTime('-1 year'));
$this->objectManager->flush();
}

View file

@ -635,8 +635,8 @@ final class CatalogPromotionContext implements Context
string $startDate,
string $endDate,
): void {
$catalogPromotion->setStartDate(new \DateTimeImmutable($startDate));
$catalogPromotion->setEndDate(new \DateTimeImmutable($endDate));
$catalogPromotion->setStartDate(new \DateTime($startDate));
$catalogPromotion->setEndDate(new \DateTime($endDate));
$this->entityManager->flush();
$this->eventBus->dispatch(new CatalogPromotionUpdated($catalogPromotion->getCode()));
@ -645,7 +645,7 @@ final class CatalogPromotionContext implements Context
#[Given('the catalog promotion :catalogPromotion starts at :startDate')]
public function theCatalogPromotionStartsAt(CatalogPromotionInterface $catalogPromotion, string $startDate): void
{
$catalogPromotion->setStartDate(new \DateTimeImmutable($startDate));
$catalogPromotion->setStartDate(new \DateTime($startDate));
$this->entityManager->flush();
@ -655,7 +655,7 @@ final class CatalogPromotionContext implements Context
#[Given('the catalog promotion :catalogPromotion ended :endDate')]
public function theCatalogPromotionEndedAt(CatalogPromotionInterface $catalogPromotion, string $endDate): void
{
$catalogPromotion->setEndDate(new \DateTimeImmutable($endDate));
$catalogPromotion->setEndDate(new \DateTime($endDate));
$this->entityManager->flush();
$this->eventBus->dispatch(new CatalogPromotionUpdated($catalogPromotion->getCode()));
@ -666,7 +666,7 @@ final class CatalogPromotionContext implements Context
CatalogPromotionInterface $catalogPromotion,
string $endDate,
): void {
$catalogPromotion->setEndDate(new \DateTimeImmutable($endDate));
$catalogPromotion->setEndDate(new \DateTime($endDate));
$this->entityManager->flush();
$this->eventBus->dispatch(new CatalogPromotionUpdated($catalogPromotion->getCode()));

View file

@ -71,7 +71,7 @@ final class CustomerContext implements Context
public function theStoreHasCustomerWithNameAndRegistrationDate($email, $fullName, $since, $phoneNumber = null)
{
$names = explode(' ', $fullName);
$customer = $this->createCustomer($email, $names[0], $names[1], new \DateTimeImmutable($since), $phoneNumber);
$customer = $this->createCustomer($email, $names[0], $names[1], new \DateTime($since), $phoneNumber);
$this->customerRepository->add($customer);
}
@ -117,7 +117,7 @@ final class CustomerContext implements Context
#[Given('/^(this customer) verified their email$/')]
public function theCustomerVerifiedTheirEmail(CustomerInterface $customer)
{
$customer->getUser()->setVerifiedAt(new \DateTimeImmutable());
$customer->getUser()->setVerifiedAt(new \DateTime());
$this->customerManager->flush();
}

View file

@ -472,7 +472,7 @@ final readonly class OrderContext implements Context
public function thisCustomerHasPlacedAnOrderAtDate(CustomerInterface $customer, string $number, string $checkoutCompletedAt): void
{
$order = $this->createOrder($customer, $number);
$order->setCheckoutCompletedAt(new \DateTimeImmutable($checkoutCompletedAt));
$order->setCheckoutCompletedAt(new \DateTime($checkoutCompletedAt));
$order->setState(BaseOrderInterface::STATE_NEW);
$this->orderRepository->add($order);
@ -816,7 +816,7 @@ final readonly class OrderContext implements Context
$customer->setFirstname('John');
$customer->setLastname('Doe' . $i);
$customer->setCreatedAt($this->clock->now());
$customer->setCreatedAt(\DateTime::createFromImmutable($this->clock->now()));
$customers[] = $customer;
@ -923,7 +923,7 @@ final readonly class OrderContext implements Context
$this->shipOrder($order);
}
$order->setCheckoutCompletedAt($this->clock->now());
$order->setCheckoutCompletedAt(\DateTime::createFromImmutable($this->clock->now()));
$this->objectManager->persist($order);
$this->sharedStorage->set('order', $order);
@ -949,7 +949,7 @@ final readonly class OrderContext implements Context
$this->payOrder($order);
$order->setCheckoutCompletedAt($this->clock->now());
$order->setCheckoutCompletedAt(\DateTime::createFromImmutable($this->clock->now()));
$this->objectManager->persist($order);
$this->sharedStorage->set('order', $order);
@ -985,7 +985,7 @@ final readonly class OrderContext implements Context
$this->shipOrder($order);
}
$order->setCheckoutCompletedAt($this->clock->now());
$order->setCheckoutCompletedAt(\DateTime::createFromImmutable($this->clock->now()));
$this->objectManager->persist($order);
}
@ -1014,7 +1014,7 @@ final readonly class OrderContext implements Context
);
$order->setState($isFulfilled ? BaseOrderInterface::STATE_FULFILLED : BaseOrderInterface::STATE_NEW);
$order->setCheckoutCompletedAt($this->clock->now());
$order->setCheckoutCompletedAt(\DateTime::createFromImmutable($this->clock->now()));
$this->objectManager->persist($order);
}

View file

@ -363,7 +363,7 @@ final class ProductAttributeContext implements Context
$date,
) {
$attribute = $this->provideProductAttribute($productAttributeType, $productAttributeName);
$attributeValue = $this->createProductAttributeValue(new \DateTimeImmutable($date), $attribute);
$attributeValue = $this->createProductAttributeValue(new \DateTime($date), $attribute);
$product->addAttribute($attributeValue);
@ -378,7 +378,7 @@ final class ProductAttributeContext implements Context
$date,
) {
$attribute = $this->provideProductAttribute($productAttributeType, $productAttributeName);
$attributeValue = $this->createProductAttributeValue(new \DateTimeImmutable($date), $attribute, 'en_US', false);
$attributeValue = $this->createProductAttributeValue(new \DateTime($date), $attribute, 'en_US', false);
$product->addAttribute($attributeValue);

View file

@ -196,7 +196,7 @@ final readonly class ProductContext implements Context
public function storeHasProductWithCode($productName, $code, $date = 'now')
{
$product = $this->createProduct($productName);
$product->setCreatedAt(new \DateTimeImmutable($date));
$product->setCreatedAt(new \DateTime($date));
$product->setCode($code);
$this->saveProduct($product);

View file

@ -54,7 +54,7 @@ final class ProductReviewContext implements Context
$review = $this->createProductReview($product, $title, $rating, $title, $customer);
if (null !== $daysSinceCreation) {
$review->setCreatedAt(new \DateTimeImmutable('-' . $daysSinceCreation . ' days'));
$review->setCreatedAt(new \DateTime('-' . $daysSinceCreation . ' days'));
}
$this->productReviewRepository->add($review);
@ -71,7 +71,7 @@ final class ProductReviewContext implements Context
$review = $this->createProductReview($product, $title, $rating, $title, $customer, ProductReviewTransitions::TRANSITION_REJECT);
if (null !== $daysSinceCreation) {
$review->setCreatedAt(new \DateTimeImmutable('-' . $daysSinceCreation . ' days'));
$review->setCreatedAt(new \DateTime('-' . $daysSinceCreation . ' days'));
}
$this->productReviewRepository->add($review);
@ -88,7 +88,7 @@ final class ProductReviewContext implements Context
$review = $this->createProductReview($product, $title, $rating, $title, $customer, null);
if (null !== $daysSinceCreation) {
$review->setCreatedAt(new \DateTimeImmutable('-' . $daysSinceCreation . ' days'));
$review->setCreatedAt(new \DateTime('-' . $daysSinceCreation . ' days'));
}
$this->productReviewRepository->add($review);

View file

@ -69,8 +69,8 @@ final readonly class PromotionContext implements Context
$this->createPromotion(
name: $name,
code: $code,
startsAt: (new \DateTimeImmutable('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTimeImmutable('+3 day'))->format('Y-m-d'),
startsAt: (new \DateTime('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTime('+3 day'))->format('Y-m-d'),
);
}
@ -96,8 +96,8 @@ final readonly class PromotionContext implements Context
'configuration' => ['taxons' => $taxonCodes],
],
],
startsAt: (new \DateTimeImmutable('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTimeImmutable('+3 day'))->format('Y-m-d'),
startsAt: (new \DateTime('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTime('+3 day'))->format('Y-m-d'),
);
}
@ -118,8 +118,8 @@ final readonly class PromotionContext implements Context
'configuration' => [$channel->getCode() => ['taxon' => $taxon->getCode(), 'amount' => $amount]],
],
],
startsAt: (new \DateTimeImmutable('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTimeImmutable('+3 day'))->format('Y-m-d'),
startsAt: (new \DateTime('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTime('+3 day'))->format('Y-m-d'),
);
}
@ -137,8 +137,8 @@ final readonly class PromotionContext implements Context
$this->createPromotion(
name: $name,
rules: $rules,
startsAt: (new \DateTimeImmutable('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTimeImmutable('+3 day'))->format('Y-m-d'),
startsAt: (new \DateTime('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTime('+3 day'))->format('Y-m-d'),
);
}
@ -156,8 +156,8 @@ final readonly class PromotionContext implements Context
$this->createPromotion(
name: $promotionName,
priority: $priority,
startsAt: (new \DateTimeImmutable('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTimeImmutable('+3 day'))->format('Y-m-d'),
startsAt: (new \DateTime('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTime('+3 day'))->format('Y-m-d'),
);
}
@ -168,8 +168,8 @@ final readonly class PromotionContext implements Context
name: $promotionName,
priority: $priority,
exclusive: true,
startsAt: (new \DateTimeImmutable('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTimeImmutable('+3 day'))->format('Y-m-d'),
startsAt: (new \DateTime('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTime('+3 day'))->format('Y-m-d'),
);
}
@ -179,8 +179,8 @@ final readonly class PromotionContext implements Context
$this->createPromotion(
name: $promotionName,
usageLimit: $usageLimit,
startsAt: (new \DateTimeImmutable('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTimeImmutable('+3 day'))->format('Y-m-d'),
startsAt: (new \DateTime('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTime('+3 day'))->format('Y-m-d'),
);
}
@ -197,8 +197,8 @@ final readonly class PromotionContext implements Context
],
],
couponBased: true,
startsAt: (new \DateTimeImmutable('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTimeImmutable('+3 day'))->format('Y-m-d'),
startsAt: (new \DateTime('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTime('+3 day'))->format('Y-m-d'),
);
$this->sharedStorage->set('coupon', $promotion->getCoupons()->first());
@ -210,8 +210,8 @@ final readonly class PromotionContext implements Context
$this->createPromotion(
name: $name,
appliesToDiscounted: false,
startsAt: (new \DateTimeImmutable('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTimeImmutable('+3 day'))->format('Y-m-d'),
startsAt: (new \DateTime('-3 day'))->format('Y-m-d'),
endsAt: (new \DateTime('+3 day'))->format('Y-m-d'),
);
}
@ -239,7 +239,7 @@ final readonly class PromotionContext implements Context
#[Given('/^(this promotion) has already expired$/')]
public function thisPromotionHasExpired(PromotionInterface $promotion): void
{
$promotion->setEndsAt(new \DateTimeImmutable('1 day ago'));
$promotion->setEndsAt(new \DateTime('1 day ago'));
$this->objectManager->flush();
}
@ -247,7 +247,7 @@ final readonly class PromotionContext implements Context
#[Given('/^(this promotion) is valid until tomorrow$/')]
public function thisPromotionIsValidUntilTomorrow(PromotionInterface $promotion): void
{
$promotion->setEndsAt(new \DateTimeImmutable('tomorrow'));
$promotion->setEndsAt(new \DateTime('tomorrow'));
$this->objectManager->flush();
}
@ -255,7 +255,7 @@ final readonly class PromotionContext implements Context
#[Given('/^(this promotion) started yesterday$/')]
public function thisPromotionStartedYesterday(PromotionInterface $promotion): void
{
$promotion->setStartsAt(new \DateTimeImmutable('1 day ago'));
$promotion->setStartsAt(new \DateTime('1 day ago'));
$this->objectManager->flush();
}
@ -263,7 +263,7 @@ final readonly class PromotionContext implements Context
#[Given('/^(this promotion) starts tomorrow$/')]
public function thisPromotionStartsTomorrow(PromotionInterface $promotion): void
{
$promotion->setStartsAt(new \DateTimeImmutable('tomorrow'));
$promotion->setStartsAt(new \DateTime('tomorrow'));
$this->objectManager->flush();
}
@ -271,7 +271,7 @@ final readonly class PromotionContext implements Context
#[Given('the promotion :promotion is archived')]
public function thisPromotionIsArchived(PromotionInterface $promotion): void
{
$promotion->setArchivedAt(new \DateTimeImmutable());
$promotion->setArchivedAt(new \DateTime());
$this->objectManager->flush();
}
@ -279,7 +279,7 @@ final readonly class PromotionContext implements Context
#[Given('/^(this coupon) has already expired$/')]
public function thisCouponHasExpired(PromotionCouponInterface $coupon): void
{
$coupon->setExpiresAt(new \DateTimeImmutable('1 day ago'));
$coupon->setExpiresAt(new \DateTime('1 day ago'));
$this->objectManager->flush();
}
@ -287,7 +287,7 @@ final readonly class PromotionContext implements Context
#[Given('/^(this coupon) is valid until tomorrow$/')]
public function thisCouponIsValidUntilTomorrow(PromotionCouponInterface $coupon): void
{
$coupon->setExpiresAt(new \DateTimeImmutable('tomorrow'));
$coupon->setExpiresAt(new \DateTime('tomorrow'));
$this->objectManager->flush();
}

View file

@ -331,7 +331,7 @@ final readonly class ShippingContext implements Context
'configuration' => $configuration,
],
'channels' => [$this->sharedStorage->get('channel')],
'archived_at' => new \DateTimeImmutable(),
'archived_at' => new \DateTime(),
]));
}
@ -427,7 +427,7 @@ final readonly class ShippingContext implements Context
#[Given('/^the (shipping method "[^"]+") is archival$/')]
public function theShippingMethodIsArchival(ShippingMethodInterface $shippingMethod): void
{
$shippingMethod->setArchivedAt(new \DateTimeImmutable());
$shippingMethod->setArchivedAt(new \DateTime());
$this->shippingMethodManager->flush();
}

View file

@ -59,8 +59,8 @@ final class TaxationContext implements Context
$zone,
$taxRateAmount,
$includedInPrice,
$startDate !== null ? new \DateTimeImmutable($startDate) : null,
$endDate !== null ? new \DateTimeImmutable($endDate) : null,
$startDate !== null ? new \DateTime($startDate) : null,
$endDate !== null ? new \DateTime($endDate) : null,
);
}
@ -72,7 +72,7 @@ final class TaxationContext implements Context
ZoneInterface $zone,
string $endDate,
) {
$this->configureTaxRate($taxCategoryName, null, $taxRateName, $zone, $taxRateAmount, false, null, new \DateTimeImmutable($endDate));
$this->configureTaxRate($taxCategoryName, null, $taxRateName, $zone, $taxRateAmount, false, null, new \DateTime($endDate));
}
#[Given('the store has :taxRateName tax rate of :taxRateAmount% for :taxCategoryName within the :zone zone starting at :startDate')]
@ -83,7 +83,7 @@ final class TaxationContext implements Context
ZoneInterface $zone,
string $startDate,
) {
$this->configureTaxRate($taxCategoryName, StringInflector::nameToCode($taxRateName), $taxRateName, $zone, $taxRateAmount, false, new \DateTimeImmutable($startDate));
$this->configureTaxRate($taxCategoryName, StringInflector::nameToCode($taxRateName), $taxRateName, $zone, $taxRateAmount, false, new \DateTime($startDate));
}
#[Given('the store has included in price :taxRateName tax rate of :taxRateAmount% for :taxCategoryName within the :zone zone')]
@ -134,8 +134,8 @@ final class TaxationContext implements Context
string $startDate,
string $endDate,
): void {
$taxRate->setStartDate(new \DateTimeImmutable($startDate));
$taxRate->setEndDate(new \DateTimeImmutable($endDate));
$taxRate->setStartDate(new \DateTime($startDate));
$taxRate->setEndDate(new \DateTime($endDate));
$this->objectManager->flush();
}

View file

@ -124,7 +124,7 @@ final readonly class UserContext implements Context
#[Given('/^(I) have already verified my account$/')]
public function iHaveAlreadyVerifiedMyAccount(UserInterface $user): void
{
$user->setVerifiedAt(new \DateTimeImmutable());
$user->setVerifiedAt(new \DateTime());
$this->userManager->flush();
}
@ -150,7 +150,7 @@ final readonly class UserContext implements Context
$token = 'itotallyforgotmypassword';
$user->setPasswordResetToken($token);
$user->setPasswordRequestedAt(new \DateTimeImmutable());
$user->setPasswordRequestedAt(new \DateTime());
$this->userManager->flush();
}

View file

@ -24,6 +24,6 @@ final class DateTimeContext implements Context
#[Transform('/^on "([^"]+)"$/')]
public function getDate($date)
{
return new \DateTimeImmutable($date);
return new \DateTime($date);
}
}

View file

@ -147,21 +147,21 @@ final class ManagingCatalogPromotionsContext implements Context
#[When('I make it start at :startDate and ends at :endDate')]
public function iMakeItOperateBetweenDates(string $startDate, string $endDate): void
{
$this->formElement->specifyStartDate(new \DateTimeImmutable($startDate));
$this->formElement->specifyEndDate(new \DateTimeImmutable($endDate));
$this->formElement->specifyStartDate(new \DateTime($startDate));
$this->formElement->specifyEndDate(new \DateTime($endDate));
}
#[When('I make it start yesterday and ends tomorrow')]
public function iMakeItOperateBetweenYesterdayAndTomorrow(): void
{
$this->formElement->specifyStartDate(new \DateTimeImmutable('yesterday'));
$this->formElement->specifyEndDate(new \DateTimeImmutable('tomorrow'));
$this->formElement->specifyStartDate(new \DateTime('yesterday'));
$this->formElement->specifyEndDate(new \DateTime('tomorrow'));
}
#[When('I make it start at :startDate')]
public function iMakeItOperateFromDate(string $startDate): void
{
$this->formElement->specifyStartDate(new \DateTimeImmutable($startDate));
$this->formElement->specifyStartDate(new \DateTime($startDate));
}
#[When('I make it unavailable in channel :channelName')]
@ -173,7 +173,7 @@ final class ManagingCatalogPromotionsContext implements Context
#[When('I( try to) change its end date to :endDate')]
public function iChangeItsEndDateTo(string $endDate): void
{
$this->formElement->specifyEndDate(new \DateTimeImmutable($endDate));
$this->formElement->specifyEndDate(new \DateTime($endDate));
}
#[When('I add a new catalog promotion scope')]
@ -742,8 +742,8 @@ final class ManagingCatalogPromotionsContext implements Context
$this->indexPage->open();
Assert::true($this->indexPage->isSingleResourceOnPage([
'name' => $catalogPromotion->getName(),
'startDate' => (new \DateTimeImmutable('yesterday'))->format('Y-m-d'),
'endDate' => (new \DateTimeImmutable('tomorrow'))->format('Y-m-d'),
'startDate' => (new \DateTime('yesterday'))->format('Y-m-d'),
'endDate' => (new \DateTime('tomorrow'))->format('Y-m-d'),
]));
$this->sharedStorage->set('catalog_promotion', $catalogPromotion);

View file

@ -349,7 +349,7 @@ final class ManagingCustomersContext implements Context
#[Then('he should be registered since :registrationDate')]
public function hisRegistrationDateShouldBe($registrationDate)
{
Assert::eq($this->showPage->getRegistrationDate(), new \DateTimeImmutable($registrationDate));
Assert::eq($this->showPage->getRegistrationDate(), new \DateTime($registrationDate));
}
#[Then('/^(?:their|his) email should be "([^"]+)"$/')]

View file

@ -64,20 +64,20 @@ final class ManagingTaxRateContext implements Context
#[When('I make it start at :startDate and end at :endDate')]
public function iMakeItStartAtAndEndAt(string $startDate, string $endDate): void
{
$this->createPage->specifyStartDate(new \DateTimeImmutable($startDate));
$this->createPage->specifyEndDate(new \DateTimeImmutable($endDate));
$this->createPage->specifyStartDate(new \DateTime($startDate));
$this->createPage->specifyEndDate(new \DateTime($endDate));
}
#[When('I set the start date to :startDate')]
public function iSetTheStartDateTo(string $startDate): void
{
$this->createPage->specifyStartDate(new \DateTimeImmutable($startDate));
$this->createPage->specifyStartDate(new \DateTime($startDate));
}
#[When('I set the end date to :endDate')]
public function iSetTheEndDateTo(string $endDate): void
{
$this->createPage->specifyStartDate(new \DateTimeImmutable($endDate));
$this->createPage->specifyStartDate(new \DateTime($endDate));
}
#[When('I define it for the :zoneName zone')]

View file

@ -53,8 +53,8 @@ final class ProductAttributeContext implements Context
public function iShouldSeeTheProductAttributeWithDate(string $attributeName, string $expectedAttribute): void
{
Assert::eq(
new \DateTimeImmutable($this->showPage->getAttributeByName($attributeName)),
new \DateTimeImmutable($expectedAttribute),
new \DateTime($this->showPage->getAttributeByName($attributeName)),
new \DateTime($expectedAttribute),
);
}

View file

@ -40,7 +40,7 @@ class ShowPage extends SyliusPage implements ShowPageInterface
public function getRegistrationDate(): \DateTimeInterface
{
return \DateTimeImmutable::createFromFormat('d-m-Y H:i:s', $this->getElement('registration_date')->getText());
return \DateTime::createFromFormat('d-m-Y H:i:s', $this->getElement('registration_date')->getText());
}
public function getDefaultAddress(): string

View file

@ -42,10 +42,10 @@
<gedmo:versioned/>
</field>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -18,7 +18,7 @@
</id>
<field name="action" column="action" type="string" />
<field name="loggedAt" column="logged_at" type="datetime_immutable" />
<field name="loggedAt" column="logged_at" type="datetime" />
<field name="objectId" column="object_id" length="64" nullable="true" />
<field name="objectClass" column="object_class" type="string" />
<field name="version" column="version" type="integer" />

View file

@ -184,12 +184,12 @@ class StatisticsComponent
};
}
private function createDateTime(string $datetime): \DateTimeImmutable
private function createDateTime(string $datetime): \DateTime
{
if ($this->clock === null) {
return new \DateTimeImmutable($datetime);
return new \DateTime($datetime);
}
return $this->clock->now()->modify($datetime);
return \DateTime::createFromImmutable($this->clock->now()->modify($datetime));
}
}

View file

@ -24,7 +24,7 @@ final class ArchivingPromotionApplicator implements ArchivingPromotionApplicator
public function archive(PromotionInterface $data): PromotionInterface
{
$data->setArchivedAt($this->calendar->now());
$data->setArchivedAt(\DateTime::createFromImmutable($this->calendar->now()));
return $data;
}

View file

@ -24,7 +24,7 @@ final readonly class ArchivingShippingMethodApplicator implements ArchivingShipp
public function archive(ShippingMethodInterface $data): ShippingMethodInterface
{
$data->setArchivedAt($this->clock->now());
$data->setArchivedAt(\DateTime::createFromImmutable($this->clock->now()));
return $data;
}

View file

@ -41,7 +41,7 @@ final readonly class RequestResetPasswordTokenHandler
}
$user->setPasswordResetToken($this->generator->generate());
$user->setPasswordRequestedAt($this->clock->now());
$user->setPasswordRequestedAt(\DateTime::createFromImmutable($this->clock->now()));
$this->commandBus->dispatch(
new SendResetPasswordEmail(

View file

@ -44,7 +44,7 @@ final readonly class VerifyShopUserHandler
);
}
$user->setVerifiedAt($this->clock->now());
$user->setVerifiedAt(\DateTime::createFromImmutable($this->clock->now()));
$user->setEmailVerificationToken(null);
$user->enable();

View file

@ -72,7 +72,7 @@ final class ProductAttributeValueDenormalizer implements DenormalizerInterface,
private function denormalizeValue(array $data, ProductAttributeInterface $attribute): array
{
if (in_array($attribute->getType(), [DateAttributeType::TYPE, DateTimeAttributeType::TYPE], true)) {
$data['value'] = new \DateTimeImmutable($data['value']);
$data['value'] = new \DateTime($data['value']);
}
return $data;

View file

@ -41,7 +41,7 @@ final class ArchivingPromotionApplicatorTest extends TestCase
$this->clock->expects(self::once())->method('now')->willReturn($now);
$this->promotion->expects(self::once())->method('setArchivedAt')->with($now);
$this->promotion->expects(self::once())->method('setArchivedAt')->with(\DateTime::createFromImmutable($now));
self::assertSame($this->promotion, $this->archivingPromotionApplicator->archive($this->promotion));
}

View file

@ -64,12 +64,13 @@ final class RequestResetPasswordTokenHandlerTest extends TestCase
->method('findOneByEmail')
->with('test@email.com')
->willReturn($shopUser);
$this->clock->expects(self::once())->method('now')->willReturn(new \DateTimeImmutable());
$now = new \DateTimeImmutable();
$this->clock->expects(self::once())->method('now')->willReturn($now);
$this->generator->expects(self::once())->method('generate')->willReturn('TOKEN');
$shopUser->expects(self::once())->method('setPasswordResetToken')->with('TOKEN');
$shopUser->expects(self::once())
->method('setPasswordRequestedAt')
->with(self::isInstanceOf(\DateTimeImmutable::class));
->with(\DateTime::createFromImmutable($now));
$sendResetPasswordEmail = new SendResetPasswordEmail('test@email.com', 'WEB', 'en_US');
$this->messageBus->expects(self::once())
->method('dispatch')

View file

@ -55,11 +55,12 @@ final class VerifyShopUserHandlerTest extends TestCase
->method('findOneBy')
->with(['emailVerificationToken' => 'ToKeN'])
->willReturn($user);
$this->clock->expects(self::once())->method('now')->willReturn(new \DateTimeImmutable());
$now = new \DateTimeImmutable();
$this->clock->expects(self::once())->method('now')->willReturn($now);
$user->expects(self::once())->method('getEmail')->willReturn('shop@example.com');
$user->expects(self::once())
->method('setVerifiedAt')
->with($this->isInstanceOf(\DateTimeImmutable::class));
->with(\DateTime::createFromImmutable($now));
$user->expects(self::once())->method('setEmailVerificationToken')->with(null);
$user->expects(self::once())->method('enable');
$this->commandBus->expects(self::once())

View file

@ -72,9 +72,9 @@ final class GetStatisticsHandlerTest extends TestCase
public function testThrowsChannelNotFoundExceptionWhenChannelIsNull(): void
{
$datePeriod = new \DatePeriod(
new \DateTimeImmutable('2022-01-01'),
new \DateTime('2022-01-01'),
new \DateInterval('P1D'),
new \DateTimeImmutable('2022-12-31'),
new \DateTime('2022-12-31'),
);
$this->channelRepository->expects(self::once())

View file

@ -160,7 +160,7 @@ final class ProductAttributeValueNormalizerTest extends TestCase
)->willReturn([]);
$this->productAttributeValue->method('getType')->willReturn('date');
$this->productAttributeValue->method('getAttribute')->willReturn($this->productAttribute);
$this->productAttributeValue->method('getValue')->willReturn(new \DateTimeImmutable('2022-01-01 14:16:53'));
$this->productAttributeValue->method('getValue')->willReturn(new \DateTime('2022-01-01 14:16:53'));
$this->productAttributeValue->method('getLocaleCode')->willReturn('pl_PL');
$this->localeProvider->method('getDefaultLocaleCode')->willReturn('fr_FR');
$this->productAttributeValueNormalizer->setNormalizer($this->normalizer);

View file

@ -26,10 +26,10 @@
</options>
</field>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -27,8 +27,8 @@
<field name="boolean" column="boolean_value" type="boolean" nullable="true" />
<field name="integer" column="integer_value" type="integer" nullable="true" />
<field name="float" column="float_value" type="float" nullable="true" />
<field name="datetime" column="datetime_value" type="datetime_immutable" nullable="true" />
<field name="date" column="date_value" type="date_immutable" nullable="true" />
<field name="datetime" column="datetime_value" type="datetime" nullable="true" />
<field name="date" column="date_value" type="date" nullable="true" />
<field name="json" column="json_value" type="json" nullable="true">
<options>
<option name="jsonb">true</option>

View file

@ -29,10 +29,10 @@
<field name="enabled" type="boolean" />
<field name="hostname" type="string" nullable="true" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -44,7 +44,7 @@ final class RequestResetPasswordEmailHandler
}
$adminUser->setPasswordResetToken($this->generator->generate());
$adminUser->setPasswordRequestedAt($this->clock->now());
$adminUser->setPasswordRequestedAt(\DateTime::createFromImmutable($this->clock->now()));
$this->commandBus->dispatch(
new SendResetPasswordEmail($adminUser->getEmail(), $adminUser->getLocaleCode()),

View file

@ -65,11 +65,11 @@ class CatalogPromotionExampleFactory extends AbstractExampleFactory implements E
$catalogPromotion->setName($options['name']);
if (isset($options['start_date'])) {
$catalogPromotion->setStartDate(new \DateTimeImmutable($options['start_date']));
$catalogPromotion->setStartDate(new \DateTime($options['start_date']));
}
if (isset($options['end_date'])) {
$catalogPromotion->setEndDate(new \DateTimeImmutable($options['end_date']));
$catalogPromotion->setEndDate(new \DateTime($options['end_date']));
}
$catalogPromotion->setEnabled($options['enabled']);

View file

@ -120,8 +120,8 @@ class OrderExampleFactory extends AbstractExampleFactory implements ExampleFacto
->setAllowedTypes('country', ['null', 'string', CountryInterface::class])
->setNormalizer('country', LazyOption::findOneBy($this->countryRepository, 'code'))
->setDefault('complete_date', fn (Options $options): \DateTimeInterface => \DateTimeImmutable::createFromMutable($this->faker->dateTimeBetween('-1 years')))
->setAllowedTypes('complete_date', ['null', \DateTimeInterface::class])
->setDefault('complete_date', fn (Options $options): \DateTimeInterface => $this->faker->dateTimeBetween('-1 years'))
->setAllowedTypes('complete_date', ['null', \DateTime::class])
->setDefault('fulfilled', false)
->setAllowedTypes('fulfilled', ['bool'])

View file

@ -101,7 +101,7 @@ class ProductExampleFactory extends AbstractExampleFactory implements ExampleFac
$product->setCode($options['code']);
$product->setEnabled($options['enabled']);
$product->setMainTaxon($options['main_taxon']);
$product->setCreatedAt(\DateTimeImmutable::createFromMutable($this->faker->dateTimeBetween('-1 week')));
$product->setCreatedAt($this->faker->dateTimeBetween('-1 week'));
$this->createTranslations($product, $options);
$this->createRelations($product, $options);
@ -319,7 +319,7 @@ class ProductExampleFactory extends AbstractExampleFactory implements ExampleFac
$productAttributeValue->setAttribute($productAttribute);
if ($value !== null && in_array($productAttribute->getStorageType(), [AttributeValueInterface::STORAGE_DATE, AttributeValueInterface::STORAGE_DATETIME], true)) {
$value = new \DateTimeImmutable($value);
$value = new \DateTime($value);
}
$productAttributeValue->setValue($value ?? $this->getRandomValueForProductAttribute($productAttribute));
@ -344,7 +344,7 @@ class ProductExampleFactory extends AbstractExampleFactory implements ExampleFac
return $this->faker->sentence;
case AttributeValueInterface::STORAGE_DATE:
case AttributeValueInterface::STORAGE_DATETIME:
return \DateTimeImmutable::createFromMutable($this->faker->dateTimeThisCentury);
return $this->faker->dateTimeThisCentury;
case AttributeValueInterface::STORAGE_JSON:
if ($productAttribute->getType() === SelectAttributeType::TYPE) {
if ($productAttribute->getConfiguration()['multiple']) {

View file

@ -75,15 +75,15 @@ class PromotionExampleFactory extends AbstractExampleFactory implements ExampleF
$promotion->setAppliesToDiscounted($options['applies_to_discounted']);
if (isset($options['starts_at'])) {
$promotion->setStartsAt(new \DateTimeImmutable($options['starts_at']));
$promotion->setStartsAt(new \DateTime($options['starts_at']));
}
if (isset($options['ends_at'])) {
$promotion->setEndsAt(new \DateTimeImmutable($options['ends_at']));
$promotion->setEndsAt(new \DateTime($options['ends_at']));
}
if (isset($options['archived_at'])) {
$promotion->setArchivedAt(new \DateTimeImmutable($options['archived_at']));
$promotion->setArchivedAt(new \DateTime($options['archived_at']));
}
foreach ($options['channels'] as $channel) {
@ -178,7 +178,7 @@ class PromotionExampleFactory extends AbstractExampleFactory implements ExampleF
$coupon->setUsageLimit($couponDefinition['usage_limit']);
if (null !== ($couponDefinition['expires_at'] ?? null)) {
$coupon->setExpiresAt(new \DateTimeImmutable($couponDefinition['expires_at']));
$coupon->setExpiresAt(new \DateTime($couponDefinition['expires_at']));
}
$coupons[] = $coupon;

View file

@ -90,13 +90,13 @@ class ShopUserExampleFactory extends AbstractExampleFactory implements ExampleFa
[CustomerComponent::UNKNOWN_GENDER, CustomerComponent::MALE_GENDER, CustomerComponent::FEMALE_GENDER],
)
->setDefault('phone_number', fn (Options $options): string => $this->faker->phoneNumber)
->setDefault('birthday', fn (Options $options): \DateTimeImmutable => \DateTimeImmutable::createFromMutable($this->faker->dateTimeThisCentury()))
->setDefault('birthday', fn (Options $options): \DateTime => $this->faker->dateTimeThisCentury())
->setAllowedTypes('birthday', ['null', 'string', \DateTimeInterface::class])
->setNormalizer(
'birthday',
function (Options $options, \DateTimeInterface|string|null $value) {
if (is_string($value)) {
return \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $value);
return \DateTime::createFromFormat('Y-m-d H:i:s', $value);
}
return $value;

View file

@ -72,15 +72,15 @@ class OrderFixture extends AbstractFixture
}
/**
* @return \DateTimeImmutable[]
* @return \DateTimeInterface[]
*/
protected function generateDates(int $amount): array
{
/** @var \DateTimeImmutable[] $dates */
/** @var \DateTimeInterface[] $dates */
$dates = [];
for ($i = 0; $i < $amount; ++$i) {
$dates[] = \DateTimeImmutable::createFromMutable($this->faker->dateTimeBetween('-1 years', 'now'));
$dates[] = $this->faker->dateTimeBetween('-1 years', 'now');
}
sort($dates);

View file

@ -34,7 +34,7 @@ final class PriceChangeLogger implements PriceChangeLoggerInterface
$logEntry = $this->logEntryFactory->create(
$channelPricing,
$this->clock->now(),
\DateTime::createFromImmutable($this->clock->now()),
$channelPricing->getPrice(),
$channelPricing->getOriginalPrice(),
);

View file

@ -23,7 +23,7 @@
<field name="price" column="price" type="integer" />
<field name="originalPrice" column="original_price" type="integer" nullable="true" />
<field name="loggedAt" column="logged_at" type="datetime_immutable" />
<field name="loggedAt" column="logged_at" type="datetime" />
<many-to-one field="channelPricing" target-entity="Sylius\Component\Core\Model\ChannelPricingInterface">
<join-column name="channel_pricing_id" nullable="false" on-delete="CASCADE" />

View file

@ -18,10 +18,10 @@
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sylius\Component\Core\Model\OrderItemUnit" table="sylius_order_item_unit">
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -18,10 +18,10 @@
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<mapped-superclass name="Sylius\Component\Core\Model\Taxon" table="sylius_taxon">
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -13,7 +13,6 @@ declare(strict_types=1);
namespace Tests\Sylius\Bundle\CoreBundle\Calculator;
use DateTimeImmutable;
use PHPUnit\Framework\TestCase;
use Sylius\Bundle\CoreBundle\Calculator\DelayStampCalculator;
use Sylius\Bundle\CoreBundle\Calculator\DelayStampCalculatorInterface;
@ -35,8 +34,8 @@ final class DelayStampCalculatorTest extends TestCase
public function testCalculatesDelayStampFromGivenDates(): void
{
$currentTime = new DateTimeImmutable('2021-11-11 20:20');
$targetTime = new DateTimeImmutable('2021-11-11 20:21');
$currentTime = new \DateTime('2021-11-11 20:20');
$targetTime = new \DateTime('2021-11-11 20:21');
$expectedStamp = new DelayStamp(60000);
@ -47,8 +46,8 @@ final class DelayStampCalculatorTest extends TestCase
public function testReturns0DelayIfDatesTargetTimeIsSmallerThanCurrentTime(): void
{
$currentTime = new DateTimeImmutable('2021-11-11 20:21');
$targetTime = new DateTimeImmutable('2021-11-11 19:05');
$currentTime = new \DateTime('2021-11-11 20:21');
$targetTime = new \DateTime('2021-11-11 19:05');
$expectedStamp = new DelayStamp(0);

View file

@ -54,8 +54,8 @@ final class CatalogPromotionAnnouncerTest extends TestCase
{
$catalogPromotion = $this->createMock(CatalogPromotionInterface::class);
$startDateTime = new \DateTimeImmutable('2021-10-10');
$endDateTime = new \DateTimeImmutable('2021-10-11');
$startDateTime = new \DateTime('2021-10-10');
$endDateTime = new \DateTime('2021-10-11');
$now = new \DateTimeImmutable();
@ -106,7 +106,7 @@ final class CatalogPromotionAnnouncerTest extends TestCase
{
$catalogPromotion = $this->createMock(CatalogPromotionInterface::class);
$startDateTime = new \DateTimeImmutable('2021-10-10');
$startDateTime = new \DateTime('2021-10-10');
$now = new \DateTimeImmutable();
$catalogPromotion->method('getCode')->willReturn('SALE');
@ -151,8 +151,8 @@ final class CatalogPromotionAnnouncerTest extends TestCase
{
$catalogPromotion = $this->createMock(CatalogPromotionInterface::class);
$startDateTime = new \DateTimeImmutable('2021-10-10');
$endDateTime = new \DateTimeImmutable('2021-10-11');
$startDateTime = new \DateTime('2021-10-10');
$endDateTime = new \DateTime('2021-10-11');
$now = new \DateTimeImmutable();
$catalogPromotion->method('getCode')->willReturn('SALE');
@ -203,8 +203,8 @@ final class CatalogPromotionAnnouncerTest extends TestCase
$catalogPromotion = $this->createMock(CatalogPromotionInterface::class);
$now = new \DateTimeImmutable('2021-10-09');
$startDateTime = new \DateTimeImmutable('2021-10-10');
$endDateTime = new \DateTimeImmutable('2021-10-11');
$startDateTime = new \DateTime('2021-10-10');
$endDateTime = new \DateTime('2021-10-11');
$catalogPromotion->method('getCode')->willReturn('SALE');
$catalogPromotion->method('getStartDate')->willReturn($startDateTime);

View file

@ -78,7 +78,7 @@ final class RequestResetPasswordEmailHandlerTest extends TestCase
$adminUser->expects($this->once())->method('getEmail')->willReturn('admin@example.com');
$adminUser->expects($this->once())->method('getLocaleCode')->willReturn('en_US');
$adminUser->expects($this->once())->method('setPasswordResetToken')->with('sometoken');
$adminUser->expects($this->once())->method('setPasswordRequestedAt')->with($now);
$adminUser->expects($this->once())->method('setPasswordRequestedAt')->with(\DateTime::createFromImmutable($now));
$expectedMessage = new SendResetPasswordEmail('admin@example.com', 'en_US');

View file

@ -76,7 +76,7 @@ final class PriceChangeLoggerTest extends TestCase
$this->logEntryFactory
->expects($this->once())
->method('create')
->with($channelPricing, $now, $price, $originalPrice)
->with($channelPricing, \DateTime::createFromImmutable($now), $price, $originalPrice)
->willReturn($logEntry)
;

View file

@ -103,6 +103,6 @@ final class LocalesAwareValidAttributeValueValidatorTest extends TestCase
$this->expectException(\InvalidArgumentException::class);
$constraint = new ValidAttributeValue();
$this->validator->validate(new \DateTimeImmutable(), $constraint);
$this->validator->validate(new \DateTime(), $constraint);
}
}

View file

@ -24,10 +24,10 @@
<field name="code" column="code" type="string" length="3" unique="true"/>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -27,10 +27,10 @@
<field name="ratio" column="ratio" type="decimal" precision="10" scale="5" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -27,17 +27,17 @@
<field name="firstName" column="first_name" type="string" nullable="true" />
<field name="lastName" column="last_name" type="string" nullable="true" />
<field name="birthday" column="birthday" type="datetime_immutable" nullable="true" />
<field name="birthday" column="birthday" type="datetime" nullable="true" />
<field name="gender" column="gender" type="string" length="1">
<options>
<option name="default">u</option>
</options>
</field>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -24,10 +24,10 @@
<field name="code" column="code" type="string" length="12" unique="true"/>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -46,7 +46,7 @@ final class ExpiredCartsRemover implements ExpiredCartsRemoverInterface
/** @return array<OrderInterface> */
private function getBatch(): array
{
$terminalDate = new \DateTimeImmutable(sprintf('-%s', $this->expirationPeriod));
$terminalDate = new \DateTime(sprintf('-%s', $this->expirationPeriod));
return $this->orderRepository->findCartsNotModifiedSince($terminalDate, $this->batchSize);
}

View file

@ -30,10 +30,10 @@
<field name="originCode" column="origin_code" type="string" nullable="true" />
<field name="details" type="json" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -27,7 +27,7 @@
<field name="notes" column="notes" type="text" nullable="true" />
<field name="state" column="state" type="string" />
<field name="checkoutCompletedAt" column="checkout_completed_at" type="datetime_immutable" nullable="true" />
<field name="checkoutCompletedAt" column="checkout_completed_at" type="datetime" nullable="true" />
<one-to-many field="items" target-entity="Sylius\Component\Order\Model\OrderItemInterface" mapped-by="order" orphan-removal="true">
<cascade>
@ -51,10 +51,10 @@
<field name="adjustmentsTotal" column="adjustments_total" type="integer" />
<field name="total" column="total" type="integer" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -34,10 +34,10 @@
<field name="state" column="state" type="string" />
<field name="details" column="details" type="json" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -24,10 +24,10 @@
<field name="position" type="integer">
<gedmo:sortable-position />
</field>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -33,10 +33,10 @@
<field name="payload" column="payload" type="object" />
<field name="responseData" column="response_data" type="json" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -13,15 +13,17 @@ declare(strict_types=1);
namespace Sylius\Bundle\PayumBundle\Model;
use Payum\Core\Model\Identity;
use Payum\Core\Security\Util\Random;
use Payum\Core\Storage\IdentityInterface;
class PaymentSecurityToken implements PaymentSecurityTokenInterface
{
/** @var string */
protected $hash;
/** @var object|null */
protected $details;
/** @var array<string, mixed>|null */
protected ?array $details = null;
/** @var string|null */
protected $afterUrl;
@ -44,11 +46,28 @@ class PaymentSecurityToken implements PaymentSecurityTokenInterface
public function setDetails($details): void
{
if ($details instanceof IdentityInterface) {
$this->details = ['id' => $details->getId(), 'class' => $details->getClass()];
return;
}
if (is_object($details)) {
$this->details = (array) $details;
return;
}
$this->details = $details;
}
public function getDetails()
/** @return IdentityInterface|array<string, mixed>|null */
public function getDetails(): array|IdentityInterface|null
{
if (is_array($this->details) && isset($this->details['id'], $this->details['class'])) {
return new Identity($this->details['id'], $this->details['class']);
}
return $this->details;
}

View file

@ -66,11 +66,11 @@
</order-by>
</one-to-many>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
<field name="enabled" column="enabled" type="boolean" />

View file

@ -23,10 +23,10 @@
<generator strategy="AUTO" />
</id>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -20,10 +20,10 @@
</id>
<field name="code" column="code" type="string" unique="true" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -28,10 +28,10 @@
<field name="position" type="integer">
<gedmo:sortable-position />
</field>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -25,10 +25,10 @@
<field name="code" column="code" type="string" unique="true" nullable="false"/>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -44,7 +44,7 @@ class PromotionRepository extends EntityRepository implements PromotionRepositor
return $queryBuilder
->andWhere('o.startsAt IS NULL OR o.startsAt < :date')
->andWhere('o.endsAt IS NULL OR o.endsAt > :date')
->setParameter('date', $date ?: new \DateTimeImmutable())
->setParameter('date', $date ?: new \DateTime())
;
}
}

View file

@ -19,8 +19,8 @@
<field name="code" unique="true" />
<field name="name" />
<field name="startDate" type="datetime_immutable" column="start_date" nullable="true"/>
<field name="endDate" type="datetime_immutable" column="end_date" nullable="true"/>
<field name="startDate" type="datetime" column="start_date" nullable="true"/>
<field name="endDate" type="datetime" column="end_date" nullable="true"/>
<field name="enabled" type="boolean" />
<field name="priority" type="integer">
<gedmo:sortable-position/>

View file

@ -27,14 +27,14 @@
<field name="usageLimit" column="usage_limit" type="integer" nullable="true" />
<field name="used" type="integer" />
<field name="couponBased" column="coupon_based" type="boolean" />
<field name="startsAt" column="starts_at" type="datetime_immutable" nullable="true"/>
<field name="endsAt" column="ends_at" type="datetime_immutable" nullable="true"/>
<field name="startsAt" column="starts_at" type="datetime" nullable="true"/>
<field name="endsAt" column="ends_at" type="datetime" nullable="true"/>
<field name="appliesToDiscounted" column="applies_to_discounted" type="boolean">
<options>
<option name="default">1</option>
</options>
</field>
<field name="archivedAt" column="archived_at" type="datetime_immutable" nullable="true" />
<field name="archivedAt" column="archived_at" type="datetime" nullable="true" />
<one-to-many field="coupons" target-entity="Sylius\Component\Promotion\Model\PromotionCouponInterface" mapped-by="promotion">
<cascade>
@ -61,10 +61,10 @@
</order-by>
</one-to-many>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -27,11 +27,11 @@
<join-column name="promotion_id" referenced-column-name="id" nullable="true" />
</many-to-one>
<field name="expiresAt" column="expires_at" type="datetime_immutable" nullable="true" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="expiresAt" column="expires_at" type="datetime" nullable="true" />
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -22,10 +22,10 @@
<field name="rating" type="integer" column="rating" />
<field name="comment" type="text" column="comment" nullable="true" />
<field name="status" type="string" column="status" length="255" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create" />
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update" />
</field>
</mapped-superclass>

View file

@ -24,6 +24,6 @@ final class ShippingDateAssigner implements ShippingDateAssignerInterface
public function assign(ShipmentInterface $shipment): void
{
$shipment->setShippedAt($this->clock->now());
$shipment->setShippedAt(\DateTime::createFromImmutable($this->clock->now()));
}
}

View file

@ -35,14 +35,14 @@
</order-by>
</one-to-many>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
<field name="shippedAt" column="shipped_at" type="datetime_immutable" nullable="true" />
<field name="shippedAt" column="shipped_at" type="datetime" nullable="true" />
</mapped-superclass>
</doctrine-mapping>

View file

@ -23,10 +23,10 @@
<join-column name="shipment_id" referenced-column-name="id" nullable="false" />
</many-to-one>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -23,10 +23,10 @@
<field name="name" column="name" type="string" />
<field name="description" column="description" type="text" nullable="true" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -47,11 +47,11 @@
<gedmo:sortable-position />
</field>
<field name="archivedAt" column="archived_at" type="datetime_immutable" nullable="true" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="archivedAt" column="archived_at" type="datetime" nullable="true" />
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -44,7 +44,7 @@ final class ShippingDateAssignerTest extends TestCase
$shipment = $this->createMock(ShipmentInterface::class);
$this->clock->expects($this->once())->method('now')->willReturn(new DateTimeImmutable('20-05-2019 20:20:20'));
$shipment->expects($this->once())->method('setShippedAt')->with(new DateTimeImmutable('20-05-2019 20:20:20'));
$shipment->expects($this->once())->method('setShippedAt')->with(new \DateTime('20-05-2019 20:20:20'));
$this->shippingDateAssigner->assign($shipment);
}

View file

@ -69,7 +69,7 @@ final class NonChannelLocaleListenerTest extends TestCase
$this->router,
$this->localeProvider,
$this->firewallMap,
[new \DateTimeImmutable(), 1, 5.0],
[new \DateTime(), 1, 5.0],
);
}

View file

@ -33,10 +33,10 @@
</order-by>
</one-to-many>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -24,17 +24,17 @@
<field name="amount" column="amount" type="decimal" precision="10" scale="5" />
<field name="includedInPrice" column="included_in_price" type="boolean" />
<field name="calculator" column="calculator" type="string" />
<field name="startDate" column="start_date" type="datetime_immutable" nullable="true"/>
<field name="endDate" column="end_date" type="datetime_immutable" nullable="true"/>
<field name="startDate" column="start_date" type="datetime" nullable="true"/>
<field name="endDate" column="end_date" type="datetime" nullable="true"/>
<many-to-one field="category" target-entity="Sylius\Component\Taxation\Model\TaxCategoryInterface" inversed-by="rates">
<join-column name="category_id" referenced-column-name="id" nullable="false" />
</many-to-one>
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>
</mapped-superclass>

View file

@ -127,7 +127,7 @@ class UserController extends ResourceController
return $this->redirectToRoute($redirectRoute);
}
$user->setVerifiedAt(new \DateTimeImmutable());
$user->setVerifiedAt(new \DateTime());
$user->setEmailVerificationToken(null);
$user->enable();
@ -290,7 +290,7 @@ class UserController extends ResourceController
string $senderEvent,
): void {
$user->setPasswordResetToken($generator->generate());
$user->setPasswordRequestedAt(new \DateTimeImmutable());
$user->setPasswordRequestedAt(new \DateTime());
// I have to use doctrine manager directly, because domain manager functions add a flash messages. I can't get rid of them.
$manager = $this->container->get('doctrine.orm.default_entity_manager');

View file

@ -183,7 +183,6 @@ final class SyliusUserExtension extends AbstractResourceExtension
new Reference($managerServiceId),
$userClass,
$config['login_tracking_interval'] ?? null,
new Reference('clock'),
]);
$lastLoginListenerDefinition->addTag('kernel.event_subscriber');
$container->setDefinition($lastLoginListenerServiceId, $lastLoginListenerDefinition);

View file

@ -14,7 +14,6 @@ declare(strict_types=1);
namespace Sylius\Bundle\UserBundle\EventListener;
use Doctrine\Persistence\ObjectManager;
use Psr\Clock\ClockInterface;
use Sylius\Bundle\UserBundle\Event\UserEvent;
use Sylius\Bundle\UserBundle\UserEvents;
use Sylius\Component\User\Model\UserInterface;
@ -30,7 +29,6 @@ final class UserLastLoginSubscriber implements EventSubscriberInterface
private readonly ObjectManager $userManager,
private readonly string $userClass,
?string $trackInterval,
private readonly ?ClockInterface $clock = null,
) {
$this->trackInterval = null === $trackInterval ? null : new \DateInterval($trackInterval);
}
@ -59,7 +57,7 @@ final class UserLastLoginSubscriber implements EventSubscriberInterface
return;
}
$user->setLastLogin($this->clock?->now() ?? new \DateTimeImmutable());
$user->setLastLogin(new \DateTime());
$this->userManager->persist($user);
$this->userManager->flush();
}
@ -79,6 +77,6 @@ final class UserLastLoginSubscriber implements EventSubscriberInterface
return true;
}
return $lastLoginDate <= ($this->clock?->now() ?? new \DateTimeImmutable())->sub($this->trackInterval);
return $lastLoginDate <= (new \DateTime())->sub($this->trackInterval);
}
}

View file

@ -24,6 +24,6 @@ final class UserVerifiedAtToBooleanTransformer implements DataTransformerInterfa
public function reverseTransform(mixed $value): mixed
{
return $value ? new \DateTimeImmutable() : null;
return $value ? new \DateTime() : null;
}
}

View file

@ -22,11 +22,11 @@
<field name="enabled" column="enabled" type="boolean" nullable="false" />
<field name="password" column="password" type="string" nullable="true" />
<field name="lastLogin" column="last_login" type="datetime_immutable" nullable="true" />
<field name="lastLogin" column="last_login" type="datetime" nullable="true" />
<field name="passwordResetToken" column="password_reset_token" type="string" unique="true" nullable="true" />
<field name="passwordRequestedAt" column="password_requested_at" type="datetime_immutable" nullable="true" />
<field name="passwordRequestedAt" column="password_requested_at" type="datetime" nullable="true" />
<field name="emailVerificationToken" column="email_verification_token" type="string" unique="true" nullable="true" />
<field name="verifiedAt" column="verified_at" type="datetime_immutable" nullable="true" />
<field name="verifiedAt" column="verified_at" type="datetime" nullable="true" />
<field name="roles" column="roles" type="json" nullable="false">
<options>
@ -35,10 +35,10 @@
</field>
<field name="email" column="email" type="string" nullable="true" />
<field name="emailCanonical" column="email_canonical" type="string" nullable="true" />
<field name="createdAt" column="created_at" type="datetime_immutable">
<field name="createdAt" column="created_at" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" column="updated_at" type="datetime_immutable" nullable="true">
<field name="updatedAt" column="updated_at" type="datetime" nullable="true">
<gedmo:timestampable on="update"/>
</field>

View file

@ -179,7 +179,7 @@ final class UserLastLoginSubscriberTest extends TestCase
$this->userLastLoginSubscriber = new UserLastLoginSubscriber($this->userManager, UserInterface::class, 'P1D');
$token->expects($this->once())->method('getUser')->willReturn($user);
$lastLogin = (new \DateTimeImmutable())->modify('-6 hours');
$lastLogin = (new \DateTime())->modify('-6 hours');
$user->expects($this->once())->method('getLastLogin')->willReturn($lastLogin);
$user->expects($this->never())->method('setLastLogin');
$this->userManager->expects($this->never())->method('persist')->with($user);
@ -196,7 +196,7 @@ final class UserLastLoginSubscriberTest extends TestCase
$this->userLastLoginSubscriber = new UserLastLoginSubscriber($this->userManager, UserInterface::class, 'P1D');
$lastLogin = (new \DateTimeImmutable())->modify('-6 hours');
$lastLogin = (new \DateTime())->modify('-6 hours');
$user->expects($this->once())->method('getLastLogin')->willReturn($lastLogin);
$event->expects($this->once())->method('getUser')->willReturn($user);
$user->expects($this->never())->method('setLastLogin');
@ -218,7 +218,7 @@ final class UserLastLoginSubscriberTest extends TestCase
$this->userLastLoginSubscriber = new UserLastLoginSubscriber($this->userManager, UserInterface::class, 'P1D');
$token->expects($this->once())->method('getUser')->willReturn($user);
$lastLogin = (new \DateTimeImmutable())->modify('-3 days');
$lastLogin = (new \DateTime())->modify('-3 days');
$user->expects($this->once())->method('getLastLogin')->willReturn($lastLogin);
$user->expects($this->once())->method('setLastLogin')->with($this->isInstanceOf(\DateTimeInterface::class));
$this->userManager->expects($this->once())->method('persist')->with($user);
@ -236,7 +236,7 @@ final class UserLastLoginSubscriberTest extends TestCase
$this->userLastLoginSubscriber = new UserLastLoginSubscriber($this->userManager, UserInterface::class, 'P1D');
$lastLogin = (new \DateTimeImmutable())->modify('-3 days');
$lastLogin = (new \DateTime())->modify('-3 days');
$user->expects($this->once())->method('getLastLogin')->willReturn($lastLogin);
$event->expects($this->once())->method('getUser')->willReturn($user);
$user->expects($this->once())->method('setLastLogin')->with($this->isInstanceOf(\DateTimeInterface::class));

View file

@ -54,7 +54,7 @@ class Address implements AddressInterface
public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
$this->createdAt = new \DateTime();
}
public function getId()

View file

@ -17,9 +17,4 @@ use Sylius\Resource\Model\ResourceLogEntry;
class AddressLogEntry extends ResourceLogEntry
{
public function setLoggedAt(): void
{
/** @phpstan-ignore assign.propertyType (Gedmo expects DateTime but we use DateTimeImmutable for DBAL 4.x compatibility) */
$this->loggedAt = new \DateTimeImmutable();
}
}

View file

@ -51,7 +51,7 @@ class Attribute implements AttributeInterface, \Stringable
{
$this->initializeTranslationsCollection();
$this->createdAt = new \DateTimeImmutable();
$this->createdAt = new \DateTime();
}
public function __toString(): string

View file

@ -104,7 +104,7 @@ class AttributeTest extends TestCase
public function testCreationDateShouldBeMutable(): void
{
$date = new \DateTimeImmutable();
$date = new \DateTime();
$this->attribute->setCreatedAt($date);
self::assertSame($date, $this->attribute->getCreatedAt());
}
@ -116,7 +116,7 @@ class AttributeTest extends TestCase
public function testLastUpdateDateShouldBeMutable(): void
{
$date = new \DateTimeImmutable();
$date = new \DateTime();
$this->attribute->setUpdatedAt($date);
self::assertSame($date, $this->attribute->getUpdatedAt());
}

View file

@ -90,8 +90,8 @@ class AttributeValueTest extends TestCase
'text' => 'Lorem ipsum',
'integer' => 42,
'float' => 6.66,
'datetime' => new \DateTimeImmutable(),
'date' => new \DateTimeImmutable(),
'datetime' => new \DateTime(),
'date' => new \DateTime(),
'json' => ['foo' => 'bar'],
];

Some files were not shown because too many files have changed in this diff Show more