ContactAddressTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace CMText\RichContent\Common;
  3. use CMText\Exceptions\ContactAddressException;
  4. use PHPUnit\Framework\TestCase;
  5. class ContactAddressTest extends TestCase
  6. {
  7. public function testJsonSerialize()
  8. {
  9. $this->assertJson(
  10. json_encode(new ContactAddress('Breda', 'Netherlands', 'NL'))
  11. );
  12. }
  13. public function test__construct()
  14. {
  15. //empty
  16. $this->assertInstanceOf(
  17. ContactAddress::class,
  18. new ContactAddress()
  19. );
  20. // partial
  21. $this->assertInstanceOf(
  22. ContactAddress::class,
  23. new ContactAddress('Breda', 'Netherlands', 'NL')
  24. );
  25. // full
  26. $this->assertInstanceOf(
  27. ContactAddress::class,
  28. new ContactAddress('Breda', 'Netherlands', 'NL','Noord Brabant', 'Konijnenberg 30', ContactAddressTypes::WORK, '4825BD')
  29. );
  30. }
  31. public function testCountryCodeException()
  32. {
  33. // invalid country code
  34. $this->expectException(ContactAddressException::class);
  35. new ContactAddress('Breda', 'Netherlands', 'EXCEPTIONAL');
  36. }
  37. public function testAddressTypeException()
  38. {
  39. // unknown type
  40. $this->expectException(ContactAddressException::class);
  41. new ContactAddress('Breda', 'Netherlands', 'NL', 'Noord Brabant', 'Konijnenberg 30', 'EXCEPTIONAL', '4825BD');
  42. }
  43. }