Move getSubscribers integration test into specific test file
[MAILPOET-4295]
This commit is contained in:
committed by
Aschepikov
parent
1dac2522c6
commit
09f5790120
@@ -116,24 +116,6 @@ class APITest extends \MailPoetTest {
|
||||
);
|
||||
}
|
||||
|
||||
public function testItGetsSubscriber() {
|
||||
$subscriber = $this->subscriberFactory->create();
|
||||
$segment = $this->getSegment();
|
||||
$this->getApi()->subscribeToList($subscriber->getId(), $segment->getId());
|
||||
|
||||
// successful response
|
||||
$result = $this->getApi()->getSubscriber($subscriber->getEmail());
|
||||
expect($result['email'])->equals($subscriber->getEmail());
|
||||
expect($result['subscriptions'][0]['segment_id'])->equals($segment->getId());
|
||||
|
||||
// error response
|
||||
try {
|
||||
$this->getApi()->getSubscriber('some_fake_email');
|
||||
$this->fail('Subscriber does not exist exception should have been thrown.');
|
||||
} catch (\Exception $e) {
|
||||
expect($e->getMessage())->equals('This subscriber does not exist.');
|
||||
}
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
$this->truncateEntity(SubscriberEntity::class);
|
||||
|
@@ -6,6 +6,7 @@ use Codeception\Stub;
|
||||
use Codeception\Stub\Expected;
|
||||
use MailPoet\API\JSON\ResponseBuilders\SubscribersResponseBuilder;
|
||||
use MailPoet\API\MP\v1\API;
|
||||
use MailPoet\API\MP\v1\APIException;
|
||||
use MailPoet\API\MP\v1\CustomFields;
|
||||
use MailPoet\API\MP\v1\Segments;
|
||||
use MailPoet\API\MP\v1\Subscribers;
|
||||
@@ -704,6 +705,22 @@ class SubscribersTest extends \MailPoetTest {
|
||||
$API->addSubscriber($subscriber, $segments, $options);
|
||||
}
|
||||
|
||||
public function testItGetsSubscriber() {
|
||||
$subscriber = $this->subscriberFactory->create();
|
||||
$segment = $this->getSegment();
|
||||
$this->getApi()->subscribeToList($subscriber->getId(), $segment->getId());
|
||||
|
||||
$result = $this->getApi()->getSubscriber($subscriber->getEmail());
|
||||
expect($result['email'])->equals($subscriber->getEmail());
|
||||
expect($result['subscriptions'][0]['segment_id'])->equals($segment->getId());
|
||||
}
|
||||
|
||||
public function testGetSubscriberThrowsWhenSubscriberDoesntExist() {
|
||||
$this->expectException(APIException::class);
|
||||
$this->expectExceptionMessage('This subscriber does not exist.');
|
||||
$this->getApi()->getSubscriber('some_fake_email');
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
$this->truncateEntity(SubscriberEntity::class);
|
||||
$this->truncateEntity(SegmentEntity::class);
|
||||
|
Reference in New Issue
Block a user