diff --git a/src/Sylius/Bundle/ApiBundle/Controller/GetStatisticsAction.php b/src/Sylius/Bundle/ApiBundle/Controller/GetStatisticsAction.php index 28987ffe48..2933485e58 100644 --- a/src/Sylius/Bundle/ApiBundle/Controller/GetStatisticsAction.php +++ b/src/Sylius/Bundle/ApiBundle/Controller/GetStatisticsAction.php @@ -90,19 +90,21 @@ final class GetStatisticsAction private function createInputDataConstraints(): array { return [ - new SymfonyConstraints\Collection([ - 'channelCode' => new Constraints\Code(), - 'startDate' => [ - new SymfonyConstraints\NotBlank(), - new SymfonyConstraints\DateTime('Y-m-d\TH:i:s', message: 'sylius.date_time.invalid'), - ], - 'interval' => new SymfonyConstraints\Choice(choices: array_keys($this->intervalsMap), multiple: false), - 'endDate' => [ - new SymfonyConstraints\NotBlank(), - new SymfonyConstraints\DateTime('Y-m-d\TH:i:s', message: 'sylius.date_time.invalid'), - ], + new SymfonyConstraints\Sequentially([ + new SymfonyConstraints\Collection([ + 'channelCode' => new Constraints\Code(), + 'startDate' => [ + new SymfonyConstraints\NotBlank(), + new SymfonyConstraints\DateTime('Y-m-d\TH:i:s', message: 'sylius.date_time.invalid'), + ], + 'interval' => new SymfonyConstraints\Choice(choices: array_keys($this->intervalsMap), multiple: false), + 'endDate' => [ + new SymfonyConstraints\NotBlank(), + new SymfonyConstraints\DateTime('Y-m-d\TH:i:s', message: 'sylius.date_time.invalid'), + ], + ]), + new SymfonyConstraints\Expression(expression: 'value["startDate"] < value["endDate"]', message: 'sylius.statistics.end_date.invalid'), ]), - new SymfonyConstraints\Expression(expression: 'value["startDate"] < value["endDate"]', message: 'sylius.statistics.end_date.invalid'), ]; } diff --git a/tests/Api/Admin/StatisticsTest.php b/tests/Api/Admin/StatisticsTest.php index 5b8e725b29..6600efaa59 100644 --- a/tests/Api/Admin/StatisticsTest.php +++ b/tests/Api/Admin/StatisticsTest.php @@ -262,10 +262,6 @@ final class StatisticsTest extends JsonApiTestCase 'propertyPath' => '[endDate]', 'message' => 'This field is missing.', ], - [ - 'propertyPath' => '', - 'message' => 'The start date must be earlier than the end date.', - ], ], ]; @@ -288,10 +284,6 @@ final class StatisticsTest extends JsonApiTestCase 'propertyPath' => '[endDate]', 'message' => 'This field is missing.', ], - [ - 'propertyPath' => '', - 'message' => 'The start date must be earlier than the end date.', - ], ], ]; } @@ -355,10 +347,6 @@ final class StatisticsTest extends JsonApiTestCase 'propertyPath' => '[endDate]', 'message' => 'This value should not be blank.', ], - [ - 'propertyPath' => '', - 'message' => 'The start date must be earlier than the end date.', - ], ], ]; } @@ -392,10 +380,6 @@ final class StatisticsTest extends JsonApiTestCase 'propertyPath' => '[startDate]', 'message' => 'The date time is not valid ISO 8601 date time in Y-m-d\TH:i:s format.', ], - [ - 'propertyPath' => '', - 'message' => 'The start date must be earlier than the end date.', - ], ], ]; diff --git a/tests/Model/OrderAdjustmentsRecalculationTest.php b/tests/Model/OrderAdjustmentsRecalculationTest.php index 0fb0e645c5..f2755eb568 100644 --- a/tests/Model/OrderAdjustmentsRecalculationTest.php +++ b/tests/Model/OrderAdjustmentsRecalculationTest.php @@ -26,6 +26,10 @@ final class OrderAdjustmentsRecalculationTest extends TestCase private OrderItemInterface $item; + private OrderItemUnit $unitNumberOne; + + private OrderItemUnit $unitNumberTwo; + protected function setUp(): void { $neutralAdjustment = $this->createAdjustment(AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT, -150, true);