diff --git a/lib/API/JSON/v1/DynamicSegments.php b/lib/API/JSON/v1/DynamicSegments.php index 809b306d89..c8bbac99c6 100644 --- a/lib/API/JSON/v1/DynamicSegments.php +++ b/lib/API/JSON/v1/DynamicSegments.php @@ -1,4 +1,4 @@ -__('Please select a type for the comparison, a number of orders and a number of days.', 'mailpoet'); case InvalidFilterException::MISSING_TOTAL_SPENT_FIELDS: return WPFunctions::get()->__('Please select a type for the comparison, an amount and a number of days.', 'mailpoet'); + case InvalidFilterException::MISSING_FILTER: + return WPFunctions::get()->__('Please add at least one condition for filtering.', 'mailpoet'); default: return WPFunctions::get()->__('An error occurred while saving data.', 'mailpoet'); } diff --git a/tests/integration/API/JSON/v1/DynamicSegmentsTest.php b/tests/integration/API/JSON/v1/DynamicSegmentsTest.php index 4c370cffb3..cff150ca28 100644 --- a/tests/integration/API/JSON/v1/DynamicSegmentsTest.php +++ b/tests/integration/API/JSON/v1/DynamicSegmentsTest.php @@ -1,4 +1,4 @@ -endpoint->save([ 'name' => 'Test dynamic', 'description' => 'description dynamic', - 'segmentType' => DynamicSegmentFilterData::TYPE_USER_ROLE, - 'wordpressRole' => 'editor', + 'filters' => [[ + 'segmentType' => DynamicSegmentFilterData::TYPE_USER_ROLE, + 'wordpressRole' => 'editor', + 'action' => UserRole::TYPE, + ]], ]); expect($response)->isInstanceOf('\MailPoet\API\JSON\SuccessResponse'); expect($response->status)->equals(self::SUCCESS_RESPONSE_CODE); @@ -56,7 +60,7 @@ class DynamicSegmentsTest extends \MailPoetTest { ]); expect($response)->isInstanceOf('\MailPoet\API\JSON\ErrorResponse'); expect($response->status)->equals(self::INVALID_DATA_RESPONSE_CODE); - expect($response->errors[0]['message'])->equals('The segment type is missing.'); + expect($response->errors[0]['message'])->equals('Please add at least one condition for filtering.'); } public function testSaverReturnsErrorOnDuplicateRecord() {