Change order of MP API subscribe/unsubscribe calls checks to be backward compatible

In the previous version we checked the lists parameter before the subscriber.
[MAILPOET-4291]
This commit is contained in:
Rostislav Wolny
2022-08-10 10:56:38 +02:00
committed by Veljko V
parent 877fd9d7da
commit 5d3c851d02
2 changed files with 30 additions and 5 deletions

View File

@ -374,6 +374,24 @@ class SubscribersTest extends \MailPoetTest {
expect($result['subscriptions'][0]['status'])->equals(SubscriberEntity::STATUS_UNSUBSCRIBED);
}
public function testItChecksEmptyParamsInCorrectOrder() {
// test if segments are specified
try {
$this->getApi()->unsubscribeFromLists(null, []);
$this->fail('Segments are required exception should have been thrown.');
} catch (\Exception $e) {
expect($e->getMessage())->equals('At least one segment ID is required.');
}
// test if segments are specified
try {
$this->getApi()->unsubscribeFromLists(null, [1]);
$this->fail('Subscriber is required exception should have been thrown.');
} catch (\Exception $e) {
expect($e->getMessage())->equals('A subscriber is required.');
}
}
public function _after() {
$this->truncateEntity(SubscriberEntity::class);
$this->truncateEntity(SegmentEntity::class);