BundlesElementTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace PharIo\Manifest;
  3. use DOMDocument;
  4. class BundlesElementTest extends \PHPUnit\Framework\TestCase {
  5. /**
  6. * @var DOMDocument
  7. */
  8. private $dom;
  9. /**
  10. * @var BundlesElement
  11. */
  12. private $bundles;
  13. protected function setUp() {
  14. $this->dom = new DOMDocument();
  15. $this->dom->loadXML('<?xml version="1.0" ?><bundles xmlns="https://phar.io/xml/manifest/1.0" />');
  16. $this->bundles = new BundlesElement($this->dom->documentElement);
  17. }
  18. public function testThrowsExceptionWhenGetComponentElementsIsCalledButNodesAreMissing() {
  19. $this->expectException(ManifestElementException::class);
  20. $this->bundles->getComponentElements();
  21. }
  22. public function testGetComponentElementsReturnsComponentElementCollection() {
  23. $this->addComponent();
  24. $this->assertInstanceOf(
  25. ComponentElementCollection::class, $this->bundles->getComponentElements()
  26. );
  27. }
  28. private function addComponent() {
  29. $this->dom->documentElement->appendChild(
  30. $this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'component')
  31. );
  32. }
  33. }