ManifestLoaderTest.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace PharIo\Manifest;
  3. /**
  4. * @covers \PharIo\Manifest\ManifestLoader
  5. *
  6. * @uses \PharIo\Manifest\Author
  7. * @uses \PharIo\Manifest\AuthorCollection
  8. * @uses \PharIo\Manifest\AuthorCollectionIterator
  9. * @uses \PharIo\Manifest\AuthorElement
  10. * @uses \PharIo\Manifest\AuthorElementCollection
  11. * @uses \PharIo\Manifest\ApplicationName
  12. * @uses \PharIo\Manifest\BundledComponent
  13. * @uses \PharIo\Manifest\BundledComponentCollection
  14. * @uses \PharIo\Manifest\BundledComponentCollectionIterator
  15. * @uses \PharIo\Manifest\BundlesElement
  16. * @uses \PharIo\Manifest\ComponentElement
  17. * @uses \PharIo\Manifest\ComponentElementCollection
  18. * @uses \PharIo\Manifest\ContainsElement
  19. * @uses \PharIo\Manifest\CopyrightElement
  20. * @uses \PharIo\Manifest\CopyrightInformation
  21. * @uses \PharIo\Manifest\ElementCollection
  22. * @uses \PharIo\Manifest\Email
  23. * @uses \PharIo\Manifest\ExtElement
  24. * @uses \PharIo\Manifest\ExtElementCollection
  25. * @uses \PharIo\Manifest\License
  26. * @uses \PharIo\Manifest\LicenseElement
  27. * @uses \PharIo\Manifest\Manifest
  28. * @uses \PharIo\Manifest\ManifestDocument
  29. * @uses \PharIo\Manifest\ManifestDocumentMapper
  30. * @uses \PharIo\Manifest\ManifestElement
  31. * @uses \PharIo\Manifest\ManifestLoader
  32. * @uses \PharIo\Manifest\PhpElement
  33. * @uses \PharIo\Manifest\PhpExtensionRequirement
  34. * @uses \PharIo\Manifest\PhpVersionRequirement
  35. * @uses \PharIo\Manifest\RequirementCollection
  36. * @uses \PharIo\Manifest\RequirementCollectionIterator
  37. * @uses \PharIo\Manifest\RequiresElement
  38. * @uses \PharIo\Manifest\Type
  39. * @uses \PharIo\Manifest\Url
  40. * @uses \PharIo\Version\Version
  41. * @uses \PharIo\Version\VersionConstraint
  42. */
  43. class ManifestLoaderTest extends \PHPUnit\Framework\TestCase {
  44. public function testCanBeLoadedFromFile() {
  45. $this->assertInstanceOf(
  46. Manifest::class,
  47. ManifestLoader::fromFile(__DIR__ . '/_fixture/library.xml')
  48. );
  49. }
  50. public function testCanBeLoadedFromString() {
  51. $this->assertInstanceOf(
  52. Manifest::class,
  53. ManifestLoader::fromString(
  54. file_get_contents(__DIR__ . '/_fixture/library.xml')
  55. )
  56. );
  57. }
  58. public function testCanBeLoadedFromPhar() {
  59. $this->assertInstanceOf(
  60. Manifest::class,
  61. ManifestLoader::fromPhar(__DIR__ . '/_fixture/test.phar')
  62. );
  63. }
  64. public function testLoadingNonExistingFileThrowsException() {
  65. $this->expectException(ManifestLoaderException::class);
  66. ManifestLoader::fromFile('/not/existing');
  67. }
  68. /**
  69. * @uses \PharIo\Manifest\ManifestDocumentLoadingException
  70. */
  71. public function testLoadingInvalidXmlThrowsException() {
  72. $this->expectException(ManifestLoaderException::class);
  73. ManifestLoader::fromString('<?xml version="1.0" ?><broken>');
  74. }
  75. }