set covers annotation for each test, complete tests

Cette révision appartient à :
Daniel Seifert 2022-07-16 23:49:47 +02:00
Parent f5579d9d5e
révision 05132f82ee
Signé par: DanielS
ID de la clé GPG: 6A513E13AEE66170
14 fichiers modifiés avec 393 ajouts et 15 suppressions

Voir le fichier

@ -21,8 +21,10 @@ use Psr\Log\AbstractLogger;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use ReflectionException; use ReflectionException;
class LoggerHandlerTest extends ApiTestCase class ALoggerHandlerTest extends ApiTestCase
{ {
/** tests must run as first, because of singleton, which must not initialized before */
/** @var LoggerHandler */ /** @var LoggerHandler */
public $loggerHandler; public $loggerHandler;
@ -46,9 +48,30 @@ class LoggerHandlerTest extends ApiTestCase
unset($this->loggerHandler); unset($this->loggerHandler);
} }
/**
* @test
* @return void
* @covers \D3\LinkmobilityClient\LoggerHandler::getInstance
*/
public function testGetInstance()
{
// not existing instance
$this->assertInstanceOf(
LoggerHandler::class,
LoggerHandler::getInstance()
);
// existing instance
$this->assertInstanceOf(
LoggerHandler::class,
LoggerHandler::getInstance()
);
}
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\LoggerHandler::__construct
*/ */
public function testConstruct() public function testConstruct()
{ {
@ -62,6 +85,8 @@ class LoggerHandlerTest extends ApiTestCase
* @test * @test
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\LoggerHandler::setLogger
* @covers \D3\LinkmobilityClient\LoggerHandler::getLogger
*/ */
public function testLogger() public function testLogger()
{ {

Voir le fichier

@ -68,6 +68,7 @@ class ClientTest extends ApiTestCase
* @param $apiClient * @param $apiClient
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\Client::__construct
*/ */
public function testConstruct($apiKey, $apiUrl, $apiClient) public function testConstruct($apiKey, $apiUrl, $apiClient)
{ {
@ -104,6 +105,7 @@ class ClientTest extends ApiTestCase
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @dataProvider requestPassedDataProvider * @dataProvider requestPassedDataProvider
* @covers \D3\LinkmobilityClient\Client::request
* *
*/ */
public function testRequest($requestIsValid) public function testRequest($requestIsValid)
@ -175,6 +177,7 @@ class ClientTest extends ApiTestCase
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @dataProvider rawRequestDataProvider * @dataProvider rawRequestDataProvider
* @covers \D3\LinkmobilityClient\Client::rawRequest
*/ */
public function testRawRequest($okStatus) public function testRawRequest($okStatus)
{ {
@ -260,6 +263,7 @@ class ClientTest extends ApiTestCase
* @test * @test
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\Client::getLoggerHandler
*/ */
public function testGetLoggerHandler() public function testGetLoggerHandler()
{ {

Voir le fichier

@ -71,6 +71,7 @@ class RecipientsListTest extends ApiTestCase
/** /**
* @test * @test
* @return void * @return void
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::__construct
*/ */
public function testConstruct() public function testConstruct()
{ {
@ -90,6 +91,7 @@ class RecipientsListTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::getPhoneNumberUtil
*/ */
public function testGetPhoneNumberUtil() public function testGetPhoneNumberUtil()
{ {
@ -105,6 +107,7 @@ class RecipientsListTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::add
*/ */
public function testAddValidNumber() public function testAddValidNumber()
{ {
@ -158,6 +161,7 @@ class RecipientsListTest extends ApiTestCase
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @dataProvider addInvalidNumberDataProvider * @dataProvider addInvalidNumberDataProvider
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::add
*/ */
public function testAddInvalidNumber($unparsable, $invalidNumber, $invalidNumberType) public function testAddInvalidNumber($unparsable, $invalidNumber, $invalidNumberType)
{ {
@ -246,6 +250,8 @@ class RecipientsListTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::clearRecipents
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::getRecipientsList
*/ */
public function testClearRecipents() public function testClearRecipents()
{ {
@ -273,6 +279,7 @@ class RecipientsListTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::getRecipients
*/ */
public function testGetRecipients() public function testGetRecipients()
{ {
@ -301,6 +308,7 @@ class RecipientsListTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::getRecipientsList
*/ */
public function testGetRecipientsList() public function testGetRecipientsList()
{ {
@ -332,6 +340,10 @@ class RecipientsListTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::current
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::next
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::key
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::rewind
*/ */
public function testCurrentNextKeyRewind() public function testCurrentNextKeyRewind()
{ {
@ -380,6 +392,7 @@ class RecipientsListTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::valid
*/ */
public function testValid() public function testValid()
{ {
@ -411,13 +424,15 @@ class RecipientsListTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::setClient
* @covers \D3\LinkmobilityClient\RecipientsList\RecipientsList::getClient
*/ */
public function testSetGetClient() public function testSetGetClient()
{ {
/** @var Client|MockObject $clientMock */ /** @var Client|MockObject $clientMock */
$clientMock = $this->getMockBuilder(Client::class) $clientMock = $this->getMockBuilder(Client::class)
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->assertInstanceOf( $this->assertInstanceOf(
RecipientsList::class, RecipientsList::class,

Voir le fichier

@ -65,6 +65,8 @@ abstract class AbstractRequest extends ApiTestCase
* @test * @test
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::__construct
* @covers \D3\LinkmobilityClient\SMS\TextRequest::__construct
*/ */
public function testConstruct() public function testConstruct()
{ {
@ -98,6 +100,8 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getUri
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getUri
*/ */
public function testGetUri() public function testGetUri()
{ {
@ -112,6 +116,9 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::validate
* @covers \D3\LinkmobilityClient\SMS\TextRequest::validate
* @covers \D3\LinkmobilityClient\Request\Request::validate
*/ */
public function validatePassedTest() public function validatePassedTest()
{ {
@ -143,6 +150,8 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::validate
* @covers \D3\LinkmobilityClient\SMS\TextRequest::validate
*/ */
public function validateFailedTest() public function validateFailedTest()
{ {
@ -176,6 +185,9 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getRawBody
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getRawBody
* @covers \D3\LinkmobilityClient\Request\Request::getRawBody
*/ */
public function testGetRawBody() public function testGetRawBody()
{ {
@ -200,6 +212,8 @@ abstract class AbstractRequest extends ApiTestCase
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @dataProvider getBodyDataProvider * @dataProvider getBodyDataProvider
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getBody
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getBody
*/ */
public function testGetBody($contentType, $expected) public function testGetBody($contentType, $expected)
{ {
@ -256,6 +270,8 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getOptions
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getOptions
*/ */
public function testGetOptions() public function testGetOptions()
{ {
@ -315,6 +331,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setMessage
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setMessage
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getMessage
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getMessage
*/ */
public function setGetMessageTest() public function setGetMessageTest()
{ {
@ -328,6 +348,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setMethod
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setMethod
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getMethod
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getMethod
*/ */
public function setGetMethodTest() public function setGetMethodTest()
{ {
@ -337,6 +361,8 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getMethods
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getMethods
*/ */
public function getMethodsTest() public function getMethodsTest()
{ {
@ -352,6 +378,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setContentType
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setContentType
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getContentType
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getContentType
*/ */
public function setGetContentTypeTest() public function setGetContentTypeTest()
{ {
@ -361,6 +391,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setClientMessageId
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setClientMessageId
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getClientMessageId
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getClientMessageId
*/ */
public function setGetClientMessageIdTest() public function setGetClientMessageIdTest()
{ {
@ -370,6 +404,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setContentCategory
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setContentCategory
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getContentCategory
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getContentCategory
*/ */
public function setGetContentCategoryTest() public function setGetContentCategoryTest()
{ {
@ -379,6 +417,8 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getContentCategories
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getContentCategories
*/ */
public function getContentCategoriesTest() public function getContentCategoriesTest()
{ {
@ -394,6 +434,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setTestMode
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setTestMode
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getTestMode
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getTestMode
*/ */
public function setGetTestModeTest() public function setGetTestModeTest()
{ {
@ -403,6 +447,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setMaxSmsPerMessage
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setMaxSmsPerMessage
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getMaxSmsPerMessage
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getMaxSmsPerMessage
*/ */
public function setGetMaxSmsPerMessageTest() public function setGetMaxSmsPerMessageTest()
{ {
@ -412,6 +460,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setMessageType
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setMessageType
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getMessageType
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getMessageType
*/ */
public function setGetMessageTypeTest() public function setGetMessageTypeTest()
{ {
@ -421,6 +473,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setNotificationCallbackUrl
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setNotificationCallbackUrl
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getNotificationCallbackUrl
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getNotificationCallbackUrl
*/ */
public function setGetNotificationCallbackUrlTest() public function setGetNotificationCallbackUrlTest()
{ {
@ -430,6 +486,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setPriority
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setPriority
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getPriority
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getPriority
*/ */
public function setGetPriorityTest() public function setGetPriorityTest()
{ {
@ -439,6 +499,8 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getRecipientsList
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getRecipientsList
*/ */
public function getRecipientsListTest() public function getRecipientsListTest()
{ {
@ -454,6 +516,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::sendAsFlashSms
* @covers \D3\LinkmobilityClient\SMS\TextRequest::sendAsFlashSms
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::doSendAsFlashSms
* @covers \D3\LinkmobilityClient\SMS\TextRequest::doSendAsFlashSms
*/ */
public function setGetFlashSmsTest() public function setGetFlashSmsTest()
{ {
@ -463,6 +529,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setSenderAddress
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setSenderAddress
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getSenderAddress
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getSenderAddress
*/ */
public function setGetSenderAddressTest() public function setGetSenderAddressTest()
{ {
@ -477,6 +547,10 @@ abstract class AbstractRequest extends ApiTestCase
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @dataProvider setGetSenderAddressTypeDataProvider * @dataProvider setGetSenderAddressTypeDataProvider
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setSenderAddressType
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setSenderAddressType
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getSenderAddressType
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getSenderAddressType
*/ */
public function testSetGetSenderAddressType($hasSender, $addressType, $expected) public function testSetGetSenderAddressType($hasSender, $addressType, $expected)
{ {
@ -530,6 +604,8 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getSenderAddressTypes
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getSenderAddressTypes
*/ */
public function getSenderAddressTypesTest() public function getSenderAddressTypesTest()
{ {
@ -545,6 +621,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setValidityPeriode
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setValidityPeriode
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getValidityPeriode
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getValidityPeriode
*/ */
public function setGetValidityPeriodeTest() public function setGetValidityPeriodeTest()
{ {
@ -555,6 +635,8 @@ abstract class AbstractRequest extends ApiTestCase
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @dataProvider getResponseInstanceDataProvider * @dataProvider getResponseInstanceDataProvider
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getResponseInstance
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getResponseInstance
*/ */
public function testGetResponseInstance(ResponseInterface $response) public function testGetResponseInstance(ResponseInterface $response)
{ {
@ -610,6 +692,10 @@ abstract class AbstractRequest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::setClient
* @covers \D3\LinkmobilityClient\SMS\TextRequest::setClient
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getClient
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getClient
*/ */
public function setGetClientTest() public function setGetClientTest()
{ {
@ -625,6 +711,8 @@ abstract class AbstractRequest extends ApiTestCase
* @test * @test
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\BinaryRequest::getResponseClass
* @covers \D3\LinkmobilityClient\SMS\TextRequest::getResponseClass
*/ */
public function testGetResponseClass() public function testGetResponseClass()
{ {

Voir le fichier

@ -29,6 +29,9 @@ abstract class AbstractResponse extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\Response::__construct
* @covers \D3\LinkmobilityClient\SMS\Response::getRawResponse
* @covers \D3\LinkmobilityClient\SMS\Response::getContent
*/ */
public function testConstruct() public function testConstruct()
{ {
@ -102,6 +105,7 @@ abstract class AbstractResponse extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\Response::getInternalStatus
*/ */
public function testGetInternalStatus() public function testGetInternalStatus()
{ {
@ -111,6 +115,7 @@ abstract class AbstractResponse extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\Response::getStatusMessage
*/ */
public function testGetStatusMessage() public function testGetStatusMessage()
{ {
@ -120,6 +125,7 @@ abstract class AbstractResponse extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\Response::getClientMessageId
*/ */
public function testGetClientMessageId() public function testGetClientMessageId()
{ {
@ -129,6 +135,7 @@ abstract class AbstractResponse extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\Response::getTransferId
*/ */
public function testGetTransferId() public function testGetTransferId()
{ {
@ -138,6 +145,7 @@ abstract class AbstractResponse extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\Response::getSmsCount
*/ */
public function testGetSmsCount() public function testGetSmsCount()
{ {
@ -151,6 +159,7 @@ abstract class AbstractResponse extends ApiTestCase
* *
* @throws ReflectionException * @throws ReflectionException
* @dataProvider isSuccessfulDataProvider * @dataProvider isSuccessfulDataProvider
* @covers \D3\LinkmobilityClient\SMS\Response::isSuccessful
*/ */
public function testIsSuccessful($statusCode, $expected) public function testIsSuccessful($statusCode, $expected)
{ {
@ -189,6 +198,7 @@ abstract class AbstractResponse extends ApiTestCase
* *
* @throws ReflectionException * @throws ReflectionException
* @dataProvider getErrorMessageDataProvider * @dataProvider getErrorMessageDataProvider
* @covers \D3\LinkmobilityClient\SMS\Response::getErrorMessage
*/ */
public function testGetErrorMessage($successful, $expected) public function testGetErrorMessage($successful, $expected)
{ {

Voir le fichier

@ -30,6 +30,7 @@ class RequestFactoryTest extends ApiTestCase
* @test * @test
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\RequestFactory::__construct
*/ */
public function testConstruct() public function testConstruct()
{ {
@ -59,6 +60,7 @@ class RequestFactoryTest extends ApiTestCase
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @dataProvider getTextSmsRequestDataProvider * @dataProvider getTextSmsRequestDataProvider
* @covers \D3\LinkmobilityClient\SMS\RequestFactory::getSmsRequest
*/ */
public function testGetTextSmsRequest($encoding, $expectedClass) public function testGetTextSmsRequest($encoding, $expectedClass)
{ {
@ -107,6 +109,7 @@ class RequestFactoryTest extends ApiTestCase
* @test * @test
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\SMS\RequestFactory::getSmsLength
*/ */
public function testGetSmsLengthInstance() public function testGetSmsLengthInstance()
{ {

Voir le fichier

@ -45,6 +45,7 @@ class UrlTest extends ApiTestCase
* @test * @test
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\Url\Url::getBaseUri
*/ */
public function testGetBaseUri() public function testGetBaseUri()
{ {
@ -63,6 +64,7 @@ class UrlTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\Url\Url::getTextSmsUri
*/ */
public function testGetTextSmsUri() public function testGetTextSmsUri()
{ {
@ -78,6 +80,7 @@ class UrlTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\Url\Url::getBinarySmsUri
*/ */
public function testGetBinarySmsUri() public function testGetBinarySmsUri()
{ {

Voir le fichier

@ -64,6 +64,7 @@ class RecipientTest extends ApiTestCase
* @return void * @return void
* @throws NumberParseException * @throws NumberParseException
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\Recipient::__construct
*/ */
public function testConstructValid() public function testConstructValid()
{ {
@ -111,6 +112,7 @@ class RecipientTest extends ApiTestCase
* @return void * @return void
* @throws NumberParseException * @throws NumberParseException
* @dataProvider constructInvalidDataProvider * @dataProvider constructInvalidDataProvider
* @covers \D3\LinkmobilityClient\ValueObject\Recipient::__construct
*/ */
public function testConstructInvalid($number, $country, $validNumber, $expectedException) public function testConstructInvalid($number, $country, $validNumber, $expectedException)
{ {
@ -158,6 +160,7 @@ class RecipientTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\Recipient::getPhoneNumberUtil
*/ */
public function testGetPhoneNumberUtil() public function testGetPhoneNumberUtil()
{ {
@ -169,4 +172,65 @@ class RecipientTest extends ApiTestCase
) )
); );
} }
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\Recipient::getCountryCode
*/
public function testGetCountryCode()
{
$this->assertSame(
$this->phoneCountryFixture,
$this->callMethod(
$this->recipient,
'getCountryCode'
)
);
}
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\ValueObject::get
* @covers \D3\LinkmobilityClient\ValueObject\StringValueObject::get
* @covers \D3\LinkmobilityClient\ValueObject\StringValueObject::__toString
* @covers \D3\LinkmobilityClient\ValueObject\Recipient::get
*/
public function testGet()
{
$this->assertSame(
'+4915123456789',
(string) $this->recipient
);
$this->assertSame(
'+4915123456789',
$this->callMethod(
$this->recipient,
'get'
)
);
}
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\ValueObject::getFormatted
* @covers \D3\LinkmobilityClient\ValueObject\StringValueObject::getFormatted
* @covers \D3\LinkmobilityClient\ValueObject\Recipient::getFormatted
*/
public function testGetFormatted()
{
$this->assertSame(
'4915123456789',
$this->callMethod(
$this->recipient,
'getFormatted'
)
);
}
} }

Voir le fichier

@ -16,6 +16,7 @@ declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\ValueObject; namespace D3\LinkmobilityClient\Tests\ValueObject;
use Assert\InvalidArgumentException; use Assert\InvalidArgumentException;
use D3\LinkmobilityClient\Exceptions\NoSenderDefinedException;
use D3\LinkmobilityClient\Exceptions\RecipientException; use D3\LinkmobilityClient\Exceptions\RecipientException;
use D3\LinkmobilityClient\Tests\ApiTestCase; use D3\LinkmobilityClient\Tests\ApiTestCase;
use D3\LinkmobilityClient\ValueObject\Sender; use D3\LinkmobilityClient\ValueObject\Sender;
@ -48,8 +49,8 @@ class SenderTest extends ApiTestCase
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE); $example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL); $this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
/** @var Sender|MockObject sender */
$this->sender = new Sender($this->phoneNumberFixture, $this->phoneCountryFixture); $this->sender = new Sender($this->phoneNumberFixture, $this->phoneCountryFixture);
} }
/** /**
@ -68,8 +69,10 @@ class SenderTest extends ApiTestCase
* @throws NumberParseException * @throws NumberParseException
* @throws RecipientException * @throws RecipientException
* @throws ReflectionException * @throws ReflectionException
* @dataProvider constructValidDataProvider
* @covers \D3\LinkmobilityClient\ValueObject\Sender::__construct
*/ */
public function testConstructValid() public function testConstructValid($number, $country, $hasNumber)
{ {
/** @var PhoneNumberUtil|MockObject $phoneNumberUtilMock */ /** @var PhoneNumberUtil|MockObject $phoneNumberUtilMock */
$phoneNumberUtilMock = $this->getMockBuilder(PhoneNumberUtil::class) $phoneNumberUtilMock = $this->getMockBuilder(PhoneNumberUtil::class)
@ -86,17 +89,33 @@ class SenderTest extends ApiTestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$senderMock->method('getPhoneNumberUtil')->willReturn($phoneNumberUtilMock); $senderMock->method('getPhoneNumberUtil')->willReturn($phoneNumberUtilMock);
$senderMock->__construct($this->phoneNumberFixture, $this->phoneCountryFixture); $senderMock->__construct($number, $country);
$this->assertSame( $this->assertSame(
'4915792300219', $hasNumber,
$this->callMethod( $this->callMethod(
$senderMock, $senderMock,
'get' 'get'
) ) === '4915792300219'
); );
} }
/**
* @return array[]
*/
public function constructValidDataProvider(): array
{
$phoneUtil = PhoneNumberUtil::getInstance();
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
return [
'null number' => [null, $this->phoneCountryFixture, false],
'null country' => [$this->phoneNumberFixture, null, false],
'all values' => [$this->phoneNumberFixture, $this->phoneCountryFixture, true]
];
}
/** /**
* @test * @test
* @param $number * @param $number
@ -107,6 +126,7 @@ class SenderTest extends ApiTestCase
* @throws NumberParseException * @throws NumberParseException
* @throws RecipientException * @throws RecipientException
* @dataProvider constructInvalidDataProvider * @dataProvider constructInvalidDataProvider
* @covers \D3\LinkmobilityClient\ValueObject\Sender::__construct
*/ */
public function testConstructInvalid($number, $country, $validNumber, $expectedException) public function testConstructInvalid($number, $country, $validNumber, $expectedException)
{ {
@ -116,12 +136,14 @@ class SenderTest extends ApiTestCase
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
if ($number === 'abc') { if ($number === 'abc') {
$phoneNumberUtilMock->method('parse')->willThrowException(new NumberParseException(0, 'message')); $phoneNumberUtilMock->expects($this->exactly((int) ($country !== 'DEX')))->method('parse')
->willThrowException(new NumberParseException(0, 'message'));
} else { } else {
$phoneNumberUtilMock->method('parse')->willReturn(new PhoneNumber()); $phoneNumberUtilMock->expects($this->exactly((int) ($country !== 'DEX')))->method('parse')
->willReturn(new PhoneNumber());
} }
$phoneNumberUtilMock->method('format')->willReturn($number); $phoneNumberUtilMock->method('format')->willReturn($number);
$phoneNumberUtilMock->method('isValidNumber')->willReturn($validNumber); $phoneNumberUtilMock->method('isValidNumber')->willReturn((bool) $validNumber);
/** @var Sender|MockObject $senderMock */ /** @var Sender|MockObject $senderMock */
$senderMock = $this->getMockBuilder(Sender::class) $senderMock = $this->getMockBuilder(Sender::class)
@ -131,7 +153,12 @@ class SenderTest extends ApiTestCase
$senderMock->method('getPhoneNumberUtil')->willReturn($phoneNumberUtilMock); $senderMock->method('getPhoneNumberUtil')->willReturn($phoneNumberUtilMock);
$this->expectException($expectedException); $this->expectException($expectedException);
$senderMock->__construct($number, $country);
$this->callMethod(
$senderMock,
'__construct',
[$number, $country]
);
} }
/** /**
@ -147,13 +174,14 @@ class SenderTest extends ApiTestCase
'empty number' => ['', 'DE', true, InvalidArgumentException::class], 'empty number' => ['', 'DE', true, InvalidArgumentException::class],
'invalid country code' => [$phoneNumberFixture, 'DEX', true, InvalidArgumentException::class], 'invalid country code' => [$phoneNumberFixture, 'DEX', true, InvalidArgumentException::class],
'unparsable' => ['abc', 'DE', true, NumberParseException::class], 'unparsable' => ['abc', 'DE', true, NumberParseException::class],
'invalid number' => ['abc', 'DE', false, NumberParseException::class] 'invalid number' => ['abcd', 'DE', false, RecipientException::class]
]; ];
} }
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\Sender::getPhoneNumberUtil
*/ */
public function testGetPhoneNumberUtil() public function testGetPhoneNumberUtil()
{ {
@ -165,4 +193,42 @@ class SenderTest extends ApiTestCase
) )
); );
} }
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\ValueObject::get
* @covers \D3\LinkmobilityClient\ValueObject\StringValueObject::get
* @covers \D3\LinkmobilityClient\ValueObject\Sender::get
*/
public function testGet()
{
$this->assertSame(
'+4915123456789',
$this->callMethod(
$this->sender,
'get'
)
);
}
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\ValueObject::getFormatted
* @covers \D3\LinkmobilityClient\ValueObject\StringValueObject::getFormatted
* @covers \D3\LinkmobilityClient\ValueObject\Sender::getFormatted
*/
public function testGetFormatted()
{
$this->assertSame(
'4915123456789',
$this->callMethod(
$this->sender,
'getFormatted'
)
);
}
} }

Voir le fichier

@ -53,6 +53,7 @@ class SmsBinaryMessageTest extends ApiTestCase
* @test * @test
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\SmsBinaryMessage::__construct
*/ */
public function testConstructValid() public function testConstructValid()
{ {
@ -89,6 +90,7 @@ class SmsBinaryMessageTest extends ApiTestCase
* *
* @throws ReflectionException * @throws ReflectionException
* @dataProvider constructInvalidDataProvider * @dataProvider constructInvalidDataProvider
* @covers \D3\LinkmobilityClient\ValueObject\SmsBinaryMessage::__construct
*/ */
public function testConstructInvalid($binaryMessage, $valid, $expectedException) public function testConstructInvalid($binaryMessage, $valid, $expectedException)
{ {
@ -136,6 +138,7 @@ class SmsBinaryMessageTest extends ApiTestCase
/** /**
* @test * @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\SmsBinaryMessage::getSmsLength
*/ */
public function testGetSmsLengthInstance() public function testGetSmsLengthInstance()
{ {
@ -149,7 +152,9 @@ class SmsBinaryMessageTest extends ApiTestCase
} }
/** /**
* @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\SmsBinaryMessage::chunkCount
*/ */
public function testGetChunkCount() public function testGetChunkCount()
{ {
@ -180,7 +185,9 @@ class SmsBinaryMessageTest extends ApiTestCase
} }
/** /**
* @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\SmsBinaryMessage::length
*/ */
public function testGetSize() public function testGetSize()
{ {
@ -211,7 +218,10 @@ class SmsBinaryMessageTest extends ApiTestCase
} }
/** /**
* @test
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\SmsBinaryMessage::getMessageContent
* @covers \D3\LinkmobilityClient\ValueObject\SmsMessageAbstract::getMessageContent
*/ */
public function testGetMessageContent() public function testGetMessageContent()
{ {

Voir le fichier

@ -42,6 +42,7 @@ class SmsTextMessageTest extends SmsBinaryMessageTest
* @test * @test
* @return void * @return void
* @throws ReflectionException * @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\SmsTextMessage::__construct
*/ */
public function testConstructValid() public function testConstructValid()
{ {
@ -78,6 +79,7 @@ class SmsTextMessageTest extends SmsBinaryMessageTest
* *
* @throws ReflectionException * @throws ReflectionException
* @dataProvider constructInvalidDataProvider * @dataProvider constructInvalidDataProvider
* @covers \D3\LinkmobilityClient\ValueObject\SmsTextMessage::__construct
*/ */
public function testConstructInvalid($binaryMessage, $valid, $expectedException) public function testConstructInvalid($binaryMessage, $valid, $expectedException)
{ {

Voir le fichier

@ -0,0 +1,88 @@
<?php
/**
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link https://www.oxidmodule.com
*/
declare(strict_types=1);
namespace D3\LinkmobilityClient\Tests\ValueObject;
use Assert\InvalidArgumentException;
use D3\LinkmobilityClient\Exceptions\NoSenderDefinedException;
use D3\LinkmobilityClient\Exceptions\RecipientException;
use D3\LinkmobilityClient\Tests\ApiTestCase;
use D3\LinkmobilityClient\ValueObject\Sender;
use D3\LinkmobilityClient\ValueObject\ValueObject;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumber;
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberType;
use libphonenumber\PhoneNumberUtil;
use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
class ValueObjectTest extends ApiTestCase
{
public function setUp(): void
{
parent::setUp();
/** @var ValueObject|MockObject value */
$this->value = $this->getMockBuilder(ValueObject::class)
->disableOriginalConstructor()
->getMock();
}
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\ValueObject::__construct
* @covers \D3\LinkmobilityClient\ValueObject\ValueObject::get
*/
public function testConstructValid()
{
$phoneUtil = PhoneNumberUtil::getInstance();
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
$this->callMethod(
$this->value,
'__construct',
[$phoneNumberFixture]
);
$this->assertSame(
'01512 3456789',
$this->getValue(
$this->value,
'value'
)
);
}
/**
* @test
* @return void
* @throws ReflectionException
* @covers \D3\LinkmobilityClient\ValueObject\ValueObject::__construct
*/
public function testConstructInvalid()
{
$this->expectException(InvalidArgumentException::class);
$this->callMethod(
$this->value,
'__construct',
['']
);
}
}

Voir le fichier

@ -5,7 +5,7 @@
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true"> convertWarningsToExceptions="true">
<testsuite name="tankerkoenig"> <testsuite name="linkmobility">
<directory>./Tests</directory> <directory>./Tests</directory>
</testsuite> </testsuite>

Voir le fichier

@ -35,7 +35,7 @@ class SmsBinaryMessage extends SmsMessageAbstract
public function getMessageContent() public function getMessageContent()
{ {
return str_split( return str_split(
base64_encode($this->get()), base64_encode(parent::getMessageContent()),
SmsLength::MAXIMUM_CHARACTERS_UCS2_SINGLE SmsLength::MAXIMUM_CHARACTERS_UCS2_SINGLE
); );
} }