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