Mercurial > hg > isophonics-drupal-site
comparison vendor/phar-io/manifest/tests/xml/ManifestDocumentTest.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 class ManifestDocumentTest extends \PHPUnit_Framework_TestCase { | |
6 public function testThrowsExceptionWhenFileDoesNotExist() { | |
7 $this->expectException(ManifestDocumentException::class); | |
8 ManifestDocument::fromFile('/does/not/exist'); | |
9 } | |
10 | |
11 public function testCanBeCreatedFromFile() { | |
12 $this->assertInstanceOf( | |
13 ManifestDocument::class, | |
14 ManifestDocument::fromFile(__DIR__ . '/../_fixture/phpunit-5.6.5.xml') | |
15 ); | |
16 } | |
17 | |
18 public function testCaneBeConstructedFromString() { | |
19 $content = file_get_contents(__DIR__ . '/../_fixture/phpunit-5.6.5.xml'); | |
20 $this->assertInstanceOf( | |
21 ManifestDocument::class, | |
22 ManifestDocument::fromString($content) | |
23 ); | |
24 } | |
25 | |
26 public function testThrowsExceptionOnInvalidXML() { | |
27 $this->expectException(ManifestDocumentLoadingException::class); | |
28 ManifestDocument::fromString('<?xml version="1.0" ?><root>'); | |
29 } | |
30 | |
31 public function testLoadingDocumentWithWrongRootNameThrowsException() { | |
32 $this->expectException(ManifestDocumentException::class); | |
33 ManifestDocument::fromString('<?xml version="1.0" ?><root />'); | |
34 } | |
35 | |
36 public function testLoadingDocumentWithWrongNamespaceThrowsException() { | |
37 $this->expectException(ManifestDocumentException::class); | |
38 ManifestDocument::fromString('<?xml version="1.0" ?><phar xmlns="foo:bar" />'); | |
39 } | |
40 | |
41 public function testContainsElementCanBeRetrieved() { | |
42 $this->assertInstanceOf( | |
43 ContainsElement::class, | |
44 $this->loadFixture()->getContainsElement() | |
45 ); | |
46 } | |
47 | |
48 public function testRequiresElementCanBeRetrieved() { | |
49 $this->assertInstanceOf( | |
50 RequiresElement::class, | |
51 $this->loadFixture()->getRequiresElement() | |
52 ); | |
53 } | |
54 | |
55 public function testCopyrightElementCanBeRetrieved() { | |
56 $this->assertInstanceOf( | |
57 CopyrightElement::class, | |
58 $this->loadFixture()->getCopyrightElement() | |
59 ); | |
60 } | |
61 | |
62 public function testBundlesElementCanBeRetrieved() { | |
63 $this->assertInstanceOf( | |
64 BundlesElement::class, | |
65 $this->loadFixture()->getBundlesElement() | |
66 ); | |
67 } | |
68 | |
69 public function testThrowsExceptionWhenContainsIsMissing() { | |
70 $this->expectException(ManifestDocumentException::class); | |
71 $this->loadEmptyFixture()->getContainsElement(); | |
72 } | |
73 | |
74 public function testThrowsExceptionWhenCopyirhgtIsMissing() { | |
75 $this->expectException(ManifestDocumentException::class); | |
76 $this->loadEmptyFixture()->getCopyrightElement(); | |
77 } | |
78 | |
79 public function testThrowsExceptionWhenRequiresIsMissing() { | |
80 $this->expectException(ManifestDocumentException::class); | |
81 $this->loadEmptyFixture()->getRequiresElement(); | |
82 } | |
83 | |
84 public function testThrowsExceptionWhenBundlesIsMissing() { | |
85 $this->expectException(ManifestDocumentException::class); | |
86 $this->loadEmptyFixture()->getBundlesElement(); | |
87 } | |
88 | |
89 public function testHasBundlesReturnsTrueWhenBundlesNodeIsPresent() { | |
90 $this->assertTrue( | |
91 $this->loadFixture()->hasBundlesElement() | |
92 ); | |
93 } | |
94 | |
95 public function testHasBundlesReturnsFalseWhenBundlesNoNodeIsPresent() { | |
96 $this->assertFalse( | |
97 $this->loadEmptyFixture()->hasBundlesElement() | |
98 ); | |
99 } | |
100 | |
101 private function loadFixture() { | |
102 return ManifestDocument::fromFile(__DIR__ . '/../_fixture/phpunit-5.6.5.xml'); | |
103 } | |
104 | |
105 private function loadEmptyFixture() { | |
106 return ManifestDocument::fromString( | |
107 '<?xml version="1.0" ?><phar xmlns="https://phar.io/xml/manifest/1.0" />' | |
108 ); | |
109 } | |
110 } |