Ei kuvausta

ManifestLoaderTest.php 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. }