ApplicationNameTest.php 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php declare(strict_types = 1);
  2. namespace PharIo\Manifest;
  3. use PHPUnit\Framework\TestCase;
  4. class ApplicationNameTest extends TestCase {
  5. public function testCanBeCreatedWithValidName() {
  6. $this->assertInstanceOf(
  7. ApplicationName::class,
  8. new ApplicationName('foo/bar')
  9. );
  10. }
  11. public function testUsingInvalidFormatForNameThrowsException() {
  12. $this->expectException(InvalidApplicationNameException::class);
  13. $this->expectExceptionCode(InvalidApplicationNameException::InvalidFormat);
  14. new ApplicationName('foo');
  15. }
  16. public function testUsingWrongTypeForNameThrowsException() {
  17. $this->expectException(InvalidApplicationNameException::class);
  18. $this->expectExceptionCode(InvalidApplicationNameException::NotAString);
  19. new ApplicationName(123);
  20. }
  21. public function testReturnsTrueForEqualNamesWhenCompared() {
  22. $app = new ApplicationName('foo/bar');
  23. $this->assertTrue(
  24. $app->isEqual($app)
  25. );
  26. }
  27. public function testReturnsFalseForNonEqualNamesWhenCompared() {
  28. $app1 = new ApplicationName('foo/bar');
  29. $app2 = new ApplicationName('foo/foo');
  30. $this->assertFalse(
  31. $app1->isEqual($app2)
  32. );
  33. }
  34. public function testCanBeConvertedToString() {
  35. $this->assertEquals(
  36. 'foo/bar',
  37. new ApplicationName('foo/bar')
  38. );
  39. }
  40. }