설명 없음

CopyrightElementTest.php 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace PharIo\Manifest;
  3. use DOMDocument;
  4. class CopyrightElementTest extends \PHPUnit\Framework\TestCase {
  5. /**
  6. * @var DOMDocument
  7. */
  8. private $dom;
  9. /**
  10. * @var CopyrightElement
  11. */
  12. private $copyright;
  13. protected function setUp() {
  14. $this->dom = new DOMDocument();
  15. $this->dom->loadXML('<?xml version="1.0" ?><copyright xmlns="https://phar.io/xml/manifest/1.0" />');
  16. $this->copyright = new CopyrightElement($this->dom->documentElement);
  17. }
  18. public function testThrowsExceptionWhenGetAuthroElementsIsCalledButNodesAreMissing() {
  19. $this->expectException(ManifestElementException::class);
  20. $this->copyright->getAuthorElements();
  21. }
  22. public function testThrowsExceptionWhenGetLicenseElementIsCalledButNodeIsMissing() {
  23. $this->expectException(ManifestElementException::class);
  24. $this->copyright->getLicenseElement();
  25. }
  26. public function testGetAuthorElementsReturnsAuthorElementCollection() {
  27. $this->dom->documentElement->appendChild(
  28. $this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'author')
  29. );
  30. $this->assertInstanceOf(
  31. AuthorElementCollection::class, $this->copyright->getAuthorElements()
  32. );
  33. }
  34. public function testGetLicenseElementReturnsLicenseElement() {
  35. $this->dom->documentElement->appendChild(
  36. $this->dom->createElementNS('https://phar.io/xml/manifest/1.0', 'license')
  37. );
  38. $this->assertInstanceOf(
  39. LicenseElement::class, $this->copyright->getLicenseElement()
  40. );
  41. }
  42. }