can reset subscription from subscriber entity
This commit is contained in:
bovenliggende
1ea3941210
commit
d7b24bb81c
@ -368,6 +368,32 @@ class Subscriber extends Entity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $listId
|
||||||
|
* @param string|null $tagId
|
||||||
|
* @param array|null $fields
|
||||||
|
* @param string|null $smsNumber
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws CommunicationException
|
||||||
|
*/
|
||||||
|
public function resubscribe(
|
||||||
|
string $listId,
|
||||||
|
?string $tagId = null,
|
||||||
|
?array $fields = null,
|
||||||
|
?string $smsNumber = null
|
||||||
|
): void {
|
||||||
|
if (!$this->isSubscribed()) {
|
||||||
|
$this->endpoint->subscribe(
|
||||||
|
$this->getEmailAddress(),
|
||||||
|
$listId,
|
||||||
|
$tagId,
|
||||||
|
$fields,
|
||||||
|
$smsNumber
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// missing getters (return is timestamp list)
|
// missing getters (return is timestamp list)
|
||||||
|
|
||||||
// smart_links SmartLinks
|
// smart_links SmartLinks
|
||||||
|
@ -978,4 +978,44 @@ class SubscriberTest extends TestCase
|
|||||||
yield ['getStartedCampaignTime', 'getStartedCampaigns'];
|
yield ['getStartedCampaignTime', 'getStartedCampaigns'];
|
||||||
yield ['getFinishedCampaignTime', 'getFinishedCampaigns'];
|
yield ['getFinishedCampaignTime', 'getFinishedCampaigns'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @throws ReflectionException
|
||||||
|
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::resubscribe
|
||||||
|
* @dataProvider resubscribeDataProvider
|
||||||
|
*/
|
||||||
|
public function testReSubscribe(
|
||||||
|
bool $endpointSet,
|
||||||
|
InvokedCount $subscribeExpections,
|
||||||
|
bool $isSubscribed
|
||||||
|
): void
|
||||||
|
{
|
||||||
|
$endpointMock = $this->getMockBuilder(SubscriberEndpoint::class)
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->onlyMethods(['subscribe'])
|
||||||
|
->getMock();
|
||||||
|
$endpointMock->expects($subscribeExpections)->method('subscribe');
|
||||||
|
|
||||||
|
$sut = $this->getMockBuilder(Subscriber::class)
|
||||||
|
->setConstructorArgs([[], $endpointSet ? $endpointMock : null])
|
||||||
|
->onlyMethods(['isSubscribed', 'getEmailAddress'])
|
||||||
|
->getMock();
|
||||||
|
$sut->method('isSubscribed')->willReturn($isSubscribed);
|
||||||
|
$sut->method('getEmailAddress')->willReturn('mail@mydomain.tld');
|
||||||
|
|
||||||
|
$this->callMethod(
|
||||||
|
$sut,
|
||||||
|
'resubscribe',
|
||||||
|
['listId', 'tagid']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function resubscribeDataProvider(): Generator
|
||||||
|
{
|
||||||
|
yield 'already subscribed, has endpoint' => [true, self::never(), true];
|
||||||
|
yield 'unsubscribed, has endpoint' => [true, self::once(), false];
|
||||||
|
yield 'already subscribed, no endpoint' => [false, self::never(), true];
|
||||||
|
yield 'unsubscribed, no endpoint' => [false, self::never(), false];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
x
Verwijs in nieuw issue
Block a user