comparison vendor/phar-io/manifest/tests/xml/ContainsElementTest.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents
children
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
1 <?php
2
3 namespace PharIo\Manifest;
4
5 use DOMDocument;
6 use DOMElement;
7
8 class ContainsElementTest extends \PHPUnit_Framework_TestCase {
9 /**
10 * @var DOMElement
11 */
12 private $domElement;
13
14 /**
15 * @var ContainsElement
16 */
17 private $contains;
18
19 protected function setUp() {
20 $dom = new DOMDocument();
21 $dom->loadXML('<?xml version="1.0" ?><php xmlns="https://phar.io/xml/manifest/1.0" name="phpunit/phpunit" version="5.6.5" type="application" />');
22 $this->domElement = $dom->documentElement;
23 $this->contains = new ContainsElement($this->domElement);
24 }
25
26 public function testVersionCanBeRetrieved() {
27 $this->assertEquals('5.6.5', $this->contains->getVersion());
28 }
29
30 public function testThrowsExceptionWhenVersionAttributeIsMissing() {
31 $this->domElement->removeAttribute('version');
32 $this->expectException(ManifestElementException::class);
33 $this->contains->getVersion();
34 }
35
36 public function testNameCanBeRetrieved() {
37 $this->assertEquals('phpunit/phpunit', $this->contains->getName());
38 }
39
40 public function testThrowsExceptionWhenNameAttributeIsMissing() {
41 $this->domElement->removeAttribute('name');
42 $this->expectException(ManifestElementException::class);
43 $this->contains->getName();
44 }
45
46 public function testTypeCanBeRetrieved() {
47 $this->assertEquals('application', $this->contains->getType());
48 }
49
50 public function testThrowsExceptionWhenTypeAttributeIsMissing() {
51 $this->domElement->removeAttribute('type');
52 $this->expectException(ManifestElementException::class);
53 $this->contains->getType();
54 }
55
56 public function testGetExtensionElementReturnsExtensionElement() {
57 $this->domElement->appendChild(
58 $this->domElement->ownerDocument->createElementNS('https://phar.io/xml/manifest/1.0', 'extension')
59 );
60 $this->assertInstanceOf(ExtensionElement::class, $this->contains->getExtensionElement());
61 }
62
63 }