From aac40e2a24d2ce21282d1b36634be9b88f0a2f07 Mon Sep 17 00:00:00 2001 From: John Oleksowicz Date: Fri, 4 Aug 2023 16:16:55 -0500 Subject: [PATCH] Add mapping test for used coupon code data MAILPOET-5007 --- .../DynamicSegments/FilterDataMapperTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/mailpoet/tests/integration/Segments/DynamicSegments/FilterDataMapperTest.php b/mailpoet/tests/integration/Segments/DynamicSegments/FilterDataMapperTest.php index 678c2a2e85..d98e0e45b2 100644 --- a/mailpoet/tests/integration/Segments/DynamicSegments/FilterDataMapperTest.php +++ b/mailpoet/tests/integration/Segments/DynamicSegments/FilterDataMapperTest.php @@ -905,6 +905,32 @@ class FilterDataMapperTest extends \MailPoetTest { ]); } + public function testItMapsWooUsedCouponCodes(): void { + $data = ['filters' => [[ + 'segmentType' => DynamicSegmentFilterData::TYPE_WOOCOMMERCE, + 'action' => 'usedCouponCode', + 'operator' => 'all', + 'days' => '10', + 'timeframe' => 'inTheLast', + 'coupon_code_ids' => ['1', '5'], + ]]]; + $filters = $this->mapper->map($data); + expect($filters)->array(); + expect($filters)->count(1); + $filter = reset($filters); + $this->assertInstanceOf(DynamicSegmentFilterData::class, $filter); + expect($filter)->isInstanceOf(DynamicSegmentFilterData::class); + expect($filter->getFilterType())->equals(DynamicSegmentFilterData::TYPE_WOOCOMMERCE); + expect($filter->getAction())->equals('usedCouponCode'); + expect($filter->getData())->equals([ + 'connect' => 'and', + 'operator' => 'all', + 'days' => '10', + 'timeframe' => 'inTheLast', + 'coupon_code_ids' => ['1', '5'], + ]); + } + /** * @dataProvider dateFieldActions */