ContactPhonenumberTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace CMText\RichContent\Common;
  3. use CMText\Exceptions\ContactPhonenumberException;
  4. use PHPUnit\Framework\TestCase;
  5. class ContactPhonenumberTest extends TestCase
  6. {
  7. public function test__construct()
  8. {
  9. $this->assertJson( json_encode(new ContactPhonenumber()) );
  10. }
  11. public function testJsonSerialize()
  12. {
  13. // empty
  14. $this->assertInstanceOf(
  15. ContactPhonenumber::class,
  16. new ContactPhonenumber()
  17. );
  18. // partial
  19. $this->assertInstanceOf(
  20. ContactPhonenumber::class,
  21. new ContactPhonenumber('+31765727000')
  22. );
  23. // full
  24. $this->assertInstanceOf(
  25. ContactPhonenumber::class,
  26. new ContactPhonenumber('+31765727000', ContactPhonenumberTypes::MAIN)
  27. );
  28. }
  29. public function testContactPhonenumberTypeException()
  30. {
  31. $this->expectException(ContactPhonenumberException::class);
  32. new ContactPhonenumber('+31765727000', 'EXCEPTIONAL');
  33. }
  34. }