assert right return types in Subscriber entity
This commit is contained in:
parent
7ebf6f9844
commit
2ea023d412
@ -21,9 +21,8 @@ use D3\KlicktippPhpClient\Exceptions\BaseException;
|
||||
use D3\KlicktippPhpClient\Resources\Subscriber as SubscriberEndpoint;
|
||||
use DateTime;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Exception;
|
||||
|
||||
class Subscriber extends ArrayCollection
|
||||
class Subscriber extends Entity
|
||||
{
|
||||
public const STATUS_SUBSCRIBED = 'subscribed';
|
||||
public const BOUNCE_NOTBOUNCED = 'Not Bounced';
|
||||
@ -38,12 +37,12 @@ class Subscriber extends ArrayCollection
|
||||
|
||||
public function getId(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::ID);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::ID));
|
||||
}
|
||||
|
||||
public function getListId(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::LISTID);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::LISTID));
|
||||
}
|
||||
|
||||
public function getOptinTime(): ?DateTime
|
||||
@ -60,12 +59,12 @@ class Subscriber extends ArrayCollection
|
||||
|
||||
public function getOptinIp(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::OPTIN_IP);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::OPTIN_IP));
|
||||
}
|
||||
|
||||
public function getEmailAddress(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::EMAIL);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::EMAIL));
|
||||
}
|
||||
|
||||
public function changeEmailAddress(string $emailAddress): void
|
||||
@ -77,7 +76,7 @@ class Subscriber extends ArrayCollection
|
||||
|
||||
public function getStatus(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::STATUS);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::STATUS));
|
||||
}
|
||||
|
||||
public function isSubscribed(): bool
|
||||
@ -87,7 +86,7 @@ class Subscriber extends ArrayCollection
|
||||
|
||||
public function getBounce(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::BOUNCE);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::BOUNCE));
|
||||
}
|
||||
|
||||
public function isBounced(): bool
|
||||
@ -102,7 +101,7 @@ class Subscriber extends ArrayCollection
|
||||
|
||||
public function getIp(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::IP);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::IP));
|
||||
}
|
||||
|
||||
public function getUnsubscription(): ?DateTime
|
||||
@ -112,17 +111,17 @@ class Subscriber extends ArrayCollection
|
||||
|
||||
public function getUnsubscriptionIp(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::UNSUBSCRIPTION_IP);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::UNSUBSCRIPTION_IP));
|
||||
}
|
||||
|
||||
public function getReferrer(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::REFERRER);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::REFERRER));
|
||||
}
|
||||
|
||||
public function getSmsPhone(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::SMS_PHONE);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::SMS_PHONE));
|
||||
}
|
||||
|
||||
public function setSmsPhone(string $smsPhone): void
|
||||
@ -134,12 +133,12 @@ class Subscriber extends ArrayCollection
|
||||
|
||||
public function getSmsStatus(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::SMS_STATUS);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::SMS_STATUS));
|
||||
}
|
||||
|
||||
public function getSmsBounce(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::SMS_BOUNCE);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::SMS_BOUNCE));
|
||||
}
|
||||
|
||||
public function getSmsDate(): ?DateTime
|
||||
@ -147,14 +146,14 @@ class Subscriber extends ArrayCollection
|
||||
return $this->getDateTimeFromValue($this->get(SubscriberEndpoint::SMS_DATE));
|
||||
}
|
||||
|
||||
public function getSmsUnsubscription(): ?string
|
||||
public function getSmsUnsubscription(): ?DateTime
|
||||
{
|
||||
return $this->getDateTimeFromValue($this->get(SubscriberEndpoint::SMS_UNSUBSCRIPTION));
|
||||
}
|
||||
|
||||
public function getSmsReferrer(): ?string
|
||||
{
|
||||
return $this->get(SubscriberEndpoint::SMS_REFERRER);
|
||||
return $this->getStringOrNullValue($this->get(SubscriberEndpoint::SMS_REFERRER));
|
||||
}
|
||||
|
||||
public function getFields(): ArrayCollection
|
||||
@ -181,14 +180,14 @@ class Subscriber extends ArrayCollection
|
||||
return str_starts_with($fieldId, 'field') ? trim($fieldId) : 'field'.trim($fieldId);
|
||||
}
|
||||
|
||||
public function getTags(): ArrayCollection
|
||||
public function getTags(): ?ArrayCollection
|
||||
{
|
||||
return new ArrayCollection($this->get(SubscriberEndpoint::TAGS) ?? []);
|
||||
return $this->getArrayCollectionFromValue($this->get(SubscriberEndpoint::TAGS));
|
||||
}
|
||||
|
||||
public function isTagSet(string $tagId): bool
|
||||
{
|
||||
return $this->getTags()->contains($tagId);
|
||||
return (bool) $this->getTags()?->contains($tagId);
|
||||
}
|
||||
|
||||
public function clearTags(): void
|
||||
@ -221,14 +220,14 @@ class Subscriber extends ArrayCollection
|
||||
/**
|
||||
* manuelle Tags
|
||||
*/
|
||||
public function getManualTags(): ArrayCollection
|
||||
public function getManualTags(): ?ArrayCollection
|
||||
{
|
||||
return new ArrayCollection($this->get(SubscriberEndpoint::MANUALTAGS) ?? []);
|
||||
return $this->getArrayCollectionFromValue($this->get(SubscriberEndpoint::MANUALTAGS));
|
||||
}
|
||||
|
||||
public function isManualTagSet(string $tagId): bool
|
||||
{
|
||||
return $this->getManualTags()->containsKey($tagId);
|
||||
return (bool) $this->getManualTags()?->containsKey($tagId);
|
||||
}
|
||||
|
||||
public function getManualTagTime(string $tagId): ?DateTime
|
||||
@ -236,9 +235,9 @@ class Subscriber extends ArrayCollection
|
||||
return $this->getDateTimeFromValue($this->getManualTags()->get($tagId));
|
||||
}
|
||||
|
||||
public function getSmartTags(): ArrayCollection
|
||||
public function getSmartTags(): ?ArrayCollection
|
||||
{
|
||||
return new ArrayCollection($this->get(SubscriberEndpoint::SMARTTAGS) ?? []);
|
||||
return $this->getArrayCollectionFromValue($this->get(SubscriberEndpoint::SMARTTAGS));
|
||||
}
|
||||
|
||||
public function getSmartTagTime(string $tagId): ?DateTime
|
||||
@ -249,9 +248,9 @@ class Subscriber extends ArrayCollection
|
||||
/**
|
||||
* Kampagne gestartet
|
||||
*/
|
||||
public function getStartedCampaigns(): ArrayCollection
|
||||
public function getStartedCampaigns(): ?ArrayCollection
|
||||
{
|
||||
return new ArrayCollection($this->get(SubscriberEndpoint::CAMPAIGNSSTARTED) ?? []);
|
||||
return $this->getArrayCollectionFromValue($this->get(SubscriberEndpoint::CAMPAIGNSSTARTED));
|
||||
}
|
||||
|
||||
public function getStartedCampaignTime(string $campaignId): ?DateTime
|
||||
@ -262,9 +261,9 @@ class Subscriber extends ArrayCollection
|
||||
/**
|
||||
* Kampagne beendet
|
||||
*/
|
||||
public function getFinishedCampaigns(): ArrayCollection
|
||||
public function getFinishedCampaigns(): ?ArrayCollection
|
||||
{
|
||||
return new ArrayCollection($this->get(SubscriberEndpoint::CAMPAIGNSFINISHED) ?? []);
|
||||
return $this->getArrayCollectionFromValue($this->get(SubscriberEndpoint::CAMPAIGNSFINISHED));
|
||||
}
|
||||
|
||||
public function getFinishedCampaignTime(string $campaignId): ?DateTime
|
||||
@ -275,41 +274,41 @@ class Subscriber extends ArrayCollection
|
||||
/**
|
||||
* Email (Marketing Cockpit) erhalten
|
||||
*/
|
||||
public function getSentNotificationEmails(): ArrayCollection
|
||||
public function getSentNotificationEmails(): ?ArrayCollection
|
||||
{
|
||||
return new ArrayCollection($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSSENT) ?? []);
|
||||
return $this->getArrayCollectionFromValue($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSSENT));
|
||||
}
|
||||
|
||||
/**
|
||||
* Email (Marketing Cockpit) geoeffnet
|
||||
*/
|
||||
public function getOpenedNotificationEmails(): ArrayCollection
|
||||
public function getOpenedNotificationEmails(): ?ArrayCollection
|
||||
{
|
||||
return new ArrayCollection($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSOPENED) ?? []);
|
||||
return $this->getArrayCollectionFromValue($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSOPENED));
|
||||
}
|
||||
|
||||
/**
|
||||
* Email (Marketing Cockpit) geklickt
|
||||
*/
|
||||
public function getClickedNotificationEmails(): ArrayCollection
|
||||
public function getClickedNotificationEmails(): ?ArrayCollection
|
||||
{
|
||||
return new ArrayCollection($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSCLICKED) ?? []);
|
||||
return $this->getArrayCollectionFromValue($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSCLICKED));
|
||||
}
|
||||
|
||||
/**
|
||||
* Email (Marketing Cockpit) im Webbrowser angesehen
|
||||
*/
|
||||
public function getViewedNotificationEmails(): ArrayCollection
|
||||
public function getViewedNotificationEmails(): ?ArrayCollection
|
||||
{
|
||||
return new ArrayCollection($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSVIEWED) ?? []);
|
||||
return $this->getArrayCollectionFromValue($this->get(SubscriberEndpoint::NOTIFICATIONEMAILSVIEWED));
|
||||
}
|
||||
|
||||
/**
|
||||
* Outbound ausgeloest
|
||||
*/
|
||||
public function getOutbounds(): ArrayCollection
|
||||
public function getOutbounds(): ?ArrayCollection
|
||||
{
|
||||
return new ArrayCollection($this->get(SubscriberEndpoint::OUTBOUND) ?? []);
|
||||
return $this->getArrayCollectionFromValue($this->get(SubscriberEndpoint::OUTBOUND));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -354,17 +353,6 @@ class Subscriber extends ArrayCollection
|
||||
}
|
||||
}
|
||||
|
||||
protected function getDateTimeFromValue($value): ?DateTime
|
||||
{
|
||||
try {
|
||||
return $value ?
|
||||
new DateTime((string)$value) :
|
||||
null;
|
||||
} catch (Exception) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// missing getters (return is timestamp list)
|
||||
|
||||
// smart_links SmartLinks
|
||||
|
@ -18,6 +18,7 @@ declare(strict_types=1);
|
||||
namespace D3\KlicktippPhpClient\tests\unit\Entities;
|
||||
|
||||
use D3\KlicktippPhpClient\Entities\Subscriber;
|
||||
use D3\KlicktippPhpClient\Exceptions\InvalidCredentialTypeException;
|
||||
use D3\KlicktippPhpClient\Resources\Subscriber as SubscriberEndpoint;
|
||||
use D3\KlicktippPhpClient\tests\TestCase;
|
||||
use DateTime;
|
||||
@ -27,7 +28,7 @@ use PHPUnit\Framework\MockObject\Rule\InvokedCount;
|
||||
use ReflectionException;
|
||||
|
||||
/**
|
||||
* @coversNothing
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber
|
||||
*/
|
||||
class SubscriberTest extends TestCase
|
||||
{
|
||||
@ -52,10 +53,11 @@ class SubscriberTest extends TestCase
|
||||
SubscriberEndpoint::SMS_STATUS => "sms status fixture",
|
||||
SubscriberEndpoint::SMS_BOUNCE => "sms bounce fixture",
|
||||
SubscriberEndpoint::SMS_DATE => "2024-12-23",
|
||||
SubscriberEndpoint::SMS_UNSUBSCRIPTION => "sms unsubscription fixture",
|
||||
// ToDo: is this date real
|
||||
SubscriberEndpoint::SMS_UNSUBSCRIPTION => "2024-12-24 18:00:00",
|
||||
SubscriberEndpoint::SMS_REFERRER => "sms referrer fixture",
|
||||
SubscriberEndpoint::FIELD_FIRSTNAME => "",
|
||||
SubscriberEndpoint::FIELD_LASTNAME => "",
|
||||
SubscriberEndpoint::FIELD_FIRSTNAME => "firstName",
|
||||
SubscriberEndpoint::FIELD_LASTNAME => "lastName",
|
||||
SubscriberEndpoint::FIELD_COMPANYNAME => "",
|
||||
SubscriberEndpoint::FIELD_STREET1 => "",
|
||||
SubscriberEndpoint::FIELD_STREET2 => "",
|
||||
@ -169,9 +171,9 @@ class SubscriberTest extends TestCase
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsStatus
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsBounce
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsReferrer
|
||||
* @dataProvider getSomethingDataProvider
|
||||
* @dataProvider getDataProvider
|
||||
*/
|
||||
public function testGetSomething(string $methodName, string $expectedValue): void
|
||||
public function testGet(string $methodName, string $expectedValue): void
|
||||
{
|
||||
$this->assertSame(
|
||||
$expectedValue,
|
||||
@ -179,7 +181,90 @@ class SubscriberTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public static function getSomethingDataProvider(): Generator
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getId
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getListId
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getOptinIp
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getEmailAddress
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getStatus
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getBounce
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getIp
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getUnsubscriptionIp
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getReferrer
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsPhone
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsStatus
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsBounce
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsReferrer
|
||||
* @dataProvider getDataProvider
|
||||
*/
|
||||
public function testGetNull(string $testMethod): void
|
||||
{
|
||||
$nullProperties = [];
|
||||
foreach (array_keys($this->entity->toArray()) as $key) {
|
||||
$nullProperties[$key] = null;
|
||||
}
|
||||
|
||||
$sut = new Subscriber($nullProperties);
|
||||
|
||||
$this->assertNull(
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
$testMethod,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getId
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getListId
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getOptinIp
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getEmailAddress
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getStatus
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getBounce
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getIp
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getUnsubscriptionIp
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getReferrer
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsPhone
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsStatus
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsBounce
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsReferrer
|
||||
* @dataProvider getDataProvider
|
||||
*/
|
||||
public function testGetInvalid(string $testMethod): void
|
||||
{
|
||||
$invalidProperties = [
|
||||
SubscriberEndpoint::ID => [],
|
||||
SubscriberEndpoint::LISTID => [],
|
||||
SubscriberEndpoint::OPTIN_IP => [],
|
||||
SubscriberEndpoint::EMAIL => [],
|
||||
SubscriberEndpoint::STATUS => [],
|
||||
SubscriberEndpoint::BOUNCE => [],
|
||||
SubscriberEndpoint::IP => [],
|
||||
SubscriberEndpoint::UNSUBSCRIPTION_IP => [],
|
||||
SubscriberEndpoint::REFERRER => [],
|
||||
SubscriberEndpoint::SMS_PHONE => [],
|
||||
SubscriberEndpoint::SMS_STATUS => [],
|
||||
SubscriberEndpoint::SMS_BOUNCE => [],
|
||||
SubscriberEndpoint::SMS_REFERRER => [],
|
||||
];
|
||||
|
||||
$sut = new Subscriber($invalidProperties);
|
||||
|
||||
$this->expectException(InvalidCredentialTypeException::class);
|
||||
|
||||
$this->assertNull(
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
$testMethod,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function getDataProvider(): Generator
|
||||
{
|
||||
yield ['getId', '155988456'];
|
||||
yield ['getListId', '368370'];
|
||||
@ -216,6 +301,57 @@ class SubscriberTest extends TestCase
|
||||
$this->callMethod($sut, $methodName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getOptinTime
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getDate
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getUnsubscription
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsDate
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsUnsubscription
|
||||
* @dataProvider getTimesDataProvider
|
||||
*/
|
||||
public function testGetInvalidTimes($methodName): void
|
||||
{
|
||||
$invalidProperties = [
|
||||
SubscriberEndpoint::DATE => [],
|
||||
SubscriberEndpoint::SMS_DATE => [],
|
||||
SubscriberEndpoint::OPTIN => [],
|
||||
SubscriberEndpoint::UNSUBSCRIPTION => [],
|
||||
SubscriberEndpoint::SMS_UNSUBSCRIPTION => [],
|
||||
];
|
||||
|
||||
$sut = new Subscriber($invalidProperties);
|
||||
|
||||
$this->expectException(InvalidCredentialTypeException::class);
|
||||
|
||||
$this->callMethod($sut, $methodName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getOptinTime
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getDate
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getUnsubscription
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsDate
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmsUnsubscription
|
||||
* @dataProvider getTimesDataProvider
|
||||
*/
|
||||
public function testGetNullTimes($methodName): void
|
||||
{
|
||||
$nullProperties = [];
|
||||
foreach (array_keys($this->entity->toArray()) as $key) {
|
||||
$nullProperties[$key] = null;
|
||||
}
|
||||
|
||||
$sut = new Subscriber($nullProperties);
|
||||
|
||||
$this->assertNull(
|
||||
$this->callMethod($sut, $methodName)
|
||||
);
|
||||
}
|
||||
|
||||
public static function getTimesDataProvider(): Generator
|
||||
{
|
||||
yield ['getOptinTime'];
|
||||
@ -454,7 +590,6 @@ class SubscriberTest extends TestCase
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @return void
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getTags
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getManualTags
|
||||
@ -479,6 +614,78 @@ class SubscriberTest extends TestCase
|
||||
$this->assertCount($expectedCount, $tags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getTags
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getManualTags
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmartTags
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getStartedCampaigns
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getFinishedCampaigns
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSentNotificationEmails
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getOpenedNotificationEmails
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getClickedNotificationEmails
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getViewedNotificationEmails
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getOutbounds
|
||||
* @dataProvider getTagsDataProvider
|
||||
*/
|
||||
public function testGetNullTags(string $methodName): void
|
||||
{
|
||||
$nullProperties = [];
|
||||
foreach (array_keys($this->entity->toArray()) as $key) {
|
||||
$nullProperties[$key] = null;
|
||||
}
|
||||
|
||||
$sut = new Subscriber($nullProperties);
|
||||
|
||||
$this->assertNull(
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
$methodName,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getTags
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getManualTags
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmartTags
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getStartedCampaigns
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getFinishedCampaigns
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSentNotificationEmails
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getOpenedNotificationEmails
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getClickedNotificationEmails
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getViewedNotificationEmails
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getOutbounds
|
||||
* @dataProvider getTagsDataProvider
|
||||
*/
|
||||
public function testGetInvalidTags(string $methodName): void
|
||||
{
|
||||
$invalidProperties = [
|
||||
SubscriberEndpoint::TAGS => "",
|
||||
SubscriberEndpoint::MANUALTAGS => "",
|
||||
SubscriberEndpoint::SMARTTAGS => "",
|
||||
SubscriberEndpoint::CAMPAIGNSSTARTED => "",
|
||||
SubscriberEndpoint::CAMPAIGNSFINISHED => "",
|
||||
SubscriberEndpoint::NOTIFICATIONEMAILSSENT => "",
|
||||
SubscriberEndpoint::NOTIFICATIONEMAILSOPENED => "",
|
||||
SubscriberEndpoint::NOTIFICATIONEMAILSCLICKED => "",
|
||||
SubscriberEndpoint::NOTIFICATIONEMAILSVIEWED => "",
|
||||
SubscriberEndpoint::OUTBOUND => "",
|
||||
];
|
||||
|
||||
$sut = new Subscriber($invalidProperties);
|
||||
|
||||
$this->expectException(InvalidCredentialTypeException::class);
|
||||
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
$methodName,
|
||||
);
|
||||
}
|
||||
|
||||
public static function getTagsDataProvider(): Generator
|
||||
{
|
||||
yield ['getTags', 2];
|
||||
@ -693,12 +900,12 @@ class SubscriberTest extends TestCase
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @throws ReflectionException
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getManualTagTime
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getSmartTagTime
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getStartedCampaignTime
|
||||
* @covers \D3\KlicktippPhpClient\Entities\Subscriber::getFinishedCampaignTime
|
||||
* @dataProvider getTagDataProvider
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testGetTag(string $testMethodName, string $invokedMethodName): void
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user