Add check on list type when deleting list

[MAILPOET-4752]
This commit is contained in:
Jan Lysý
2022-10-31 15:16:56 +01:00
committed by Aschepikov
parent ad46d05c6b
commit 8161b83ded
3 changed files with 17 additions and 1 deletions

View File

@@ -229,6 +229,18 @@ class SegmentsTest extends \MailPoetTest {
}
}
public function testItDoesNotAllowDeletingWPSegment(): void {
$wpSegment = $this->segmentsRepository->getWPUsersSegment();
$this->assertInstanceOf(SegmentEntity::class, $wpSegment);
try {
$this->getApi()->deleteList((string)$wpSegment->getId());
$this->fail('WP list cannot be updated.');
} catch (\Exception $e) {
expect($e->getMessage())->equals('List of the type \'' . $wpSegment->getType() . '\' is not supported for this action.');
expect($e->getCode())->equals(APIException::LIST_TYPE_IS_NOT_SUPPORTED);
}
}
public function testItDeletesList(): void {
$segment = $this->createOrUpdateSegment('Test Segment');
$subscriber = (new Subscriber())