use generated example phone number

This commit is contained in:
Daniel Seifert 2022-07-15 23:54:52 +02:00
parent 23de1d2f06
commit 4e5147a0ac
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170
4 changed files with 35 additions and 5 deletions

View File

@ -22,6 +22,7 @@ use D3\LinkmobilityClient\Tests\ApiTestCase;
use D3\LinkmobilityClient\ValueObject\Recipient;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumber;
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberType;
use libphonenumber\PhoneNumberUtil;
use PHPUnit\Framework\MockObject\MockObject;
@ -35,7 +36,7 @@ class RecipientsListTest extends ApiTestCase
/** @var RecipientsList */
public $recipientsList;
private $phoneNumberFixture = '01527565839';
private $phoneNumberFixture;
private $phoneCountryFixture = 'DE';
/**
@ -51,6 +52,10 @@ class RecipientsListTest extends ApiTestCase
->getMock();
$this->recipientsList = new RecipientsList($clientMock);
$phoneUtil = PhoneNumberUtil::getInstance();
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
}
/**

View File

@ -24,6 +24,9 @@ use D3\LinkmobilityClient\SMS\Response;
use D3\LinkmobilityClient\Tests\ApiTestCase;
use D3\LinkmobilityClient\ValueObject\Recipient;
use D3\LinkmobilityClient\ValueObject\Sender;
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberType;
use libphonenumber\PhoneNumberUtil;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
@ -112,7 +115,11 @@ abstract class AbstractRequest extends ApiTestCase
*/
public function validatePassedTest()
{
$recipient = new Recipient('015792300219', 'DE');
$phoneUtil = PhoneNumberUtil::getInstance();
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
$recipient = new Recipient($phoneNumberFixture, 'DE');
/** @var Request|MockObject $requestMock */
$requestMock = $this->getMockBuilder($this->testClassName)
@ -139,7 +146,11 @@ abstract class AbstractRequest extends ApiTestCase
*/
public function validateFailedTest()
{
$recipient = new Recipient('015792300219', 'DE');
$phoneUtil = PhoneNumberUtil::getInstance();
$example = $phoneUtil->getExampleNumberForType('DE', PhoneNumberType::MOBILE);
$phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
$recipient = new Recipient($phoneNumberFixture, 'DE');
/** @var Request|MockObject $requestMock */
$requestMock = $this->getMockBuilder($this->testClassName)

View File

@ -20,6 +20,8 @@ use D3\LinkmobilityClient\Tests\ApiTestCase;
use D3\LinkmobilityClient\ValueObject\Recipient;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumber;
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberType;
use libphonenumber\PhoneNumberUtil;
use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
@ -29,7 +31,7 @@ class RecipientTest extends ApiTestCase
/** @var Recipient */
public $recipient;
private $phoneNumberFixture = '01527565839';
private $phoneNumberFixture;
private $phoneCountryFixture = 'DE';
/**
@ -40,6 +42,10 @@ class RecipientTest extends ApiTestCase
{
parent::setUp();
$phoneUtil = PhoneNumberUtil::getInstance();
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
$this->recipient = new Recipient($this->phoneNumberFixture, $this->phoneCountryFixture);
}

View File

@ -21,6 +21,8 @@ use D3\LinkmobilityClient\Tests\ApiTestCase;
use D3\LinkmobilityClient\ValueObject\Sender;
use libphonenumber\NumberParseException;
use libphonenumber\PhoneNumber;
use libphonenumber\PhoneNumberFormat;
use libphonenumber\PhoneNumberType;
use libphonenumber\PhoneNumberUtil;
use PHPUnit\Framework\MockObject\MockObject;
use ReflectionException;
@ -30,7 +32,7 @@ class SenderTest extends ApiTestCase
/** @var Sender */
public $sender;
private $phoneNumberFixture = '015792300219';
private $phoneNumberFixture;
private $phoneCountryFixture = 'DE';
/**
@ -42,7 +44,13 @@ class SenderTest extends ApiTestCase
{
parent::setUp();
$phoneUtil = PhoneNumberUtil::getInstance();
$example = $phoneUtil->getExampleNumberForType($this->phoneCountryFixture, PhoneNumberType::MOBILE);
$this->phoneNumberFixture = $phoneUtil->format($example, PhoneNumberFormat::NATIONAL);
$this->sender = new Sender($this->phoneNumberFixture, $this->phoneCountryFixture);
}
/**