RequiresElementTest.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace PharIo\Manifest;
  3. use DOMDocument;
  4. class RequiresElementTest extends \PHPUnit\Framework\TestCase {
  5. /**
  6. * @var DOMDocument
  7. */
  8. private $dom;
  9. /**
  10. * @var RequiresElement
  11. */
  12. private $requires;
  13. protected function setUp() {
  14. $this->dom = new DOMDocument();
  15. $this->dom->loadXML('<?xml version="1.0" ?><requires xmlns="https://phar.io/xml/manifest/1.0" />');
  16. $this->requires = new RequiresElement($this->dom->documentElement);
  17. }
  18. public function testThrowsExceptionWhenGetPhpElementIsCalledButElementIsMissing() {
  19. $this->expectException(ManifestElementException::class);
  20. $this->requires->getPHPElement();
  21. }
  22. public function testHasExtElementsReturnsTrueWhenExtensionsAreRequired() {
  23. $this->dom->documentElement->appendChild(
  24. $this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'php')
  25. );
  26. $this->assertInstanceOf(PhpElement::class, $this->requires->getPHPElement());
  27. }
  28. }