ManifestTest.php
5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?php
/*
* This file is part of PharIo\Manifest.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Manifest;
use PharIo\Version\Version;
use PharIo\Version\AnyVersionConstraint;
use PHPUnit\Framework\TestCase;
/**
* @covers \PharIo\Manifest\Manifest
*
* @uses \PharIo\Manifest\ApplicationName
* @uses \PharIo\Manifest\Author
* @uses \PharIo\Manifest\AuthorCollection
* @uses \PharIo\Manifest\BundledComponent
* @uses \PharIo\Manifest\BundledComponentCollection
* @uses \PharIo\Manifest\CopyrightInformation
* @uses \PharIo\Manifest\Email
* @uses \PharIo\Manifest\License
* @uses \PharIo\Manifest\RequirementCollection
* @uses \PharIo\Manifest\PhpVersionRequirement
* @uses \PharIo\Manifest\Type
* @uses \PharIo\Manifest\Application
* @uses \PharIo\Manifest\Url
* @uses \PharIo\Version\Version
* @uses \PharIo\Version\VersionConstraint
*/
class ManifestTest extends TestCase {
/**
* @var ApplicationName
*/
private $name;
/**
* @var Version
*/
private $version;
/**
* @var Type
*/
private $type;
/**
* @var CopyrightInformation
*/
private $copyrightInformation;
/**
* @var RequirementCollection
*/
private $requirements;
/**
* @var BundledComponentCollection
*/
private $bundledComponents;
/**
* @var Manifest
*/
private $manifest;
protected function setUp() {
$this->version = new Version('5.6.5');
$this->type = Type::application();
$author = new Author('Joe Developer', new Email('user@example.com'));
$license = new License('BSD-3-Clause', new Url('https://github.com/sebastianbergmann/phpunit/blob/master/LICENSE'));
$authors = new AuthorCollection;
$authors->add($author);
$this->copyrightInformation = new CopyrightInformation($authors, $license);
$this->requirements = new RequirementCollection;
$this->requirements->add(new PhpVersionRequirement(new AnyVersionConstraint));
$this->bundledComponents = new BundledComponentCollection;
$this->bundledComponents->add(new BundledComponent('phpunit/php-code-coverage', new Version('4.0.2')));
$this->name = new ApplicationName('phpunit/phpunit');
$this->manifest = new Manifest(
$this->name,
$this->version,
$this->type,
$this->copyrightInformation,
$this->requirements,
$this->bundledComponents
);
}
public function testCanBeCreated() {
$this->assertInstanceOf(Manifest::class, $this->manifest);
}
public function testNameCanBeRetrieved() {
$this->assertEquals($this->name, $this->manifest->getName());
}
public function testVersionCanBeRetrieved() {
$this->assertEquals($this->version, $this->manifest->getVersion());
}
public function testTypeCanBeRetrieved() {
$this->assertEquals($this->type, $this->manifest->getType());
}
public function testTypeCanBeQueried() {
$this->assertTrue($this->manifest->isApplication());
$this->assertFalse($this->manifest->isLibrary());
$this->assertFalse($this->manifest->isExtension());
}
public function testCopyrightInformationCanBeRetrieved() {
$this->assertEquals($this->copyrightInformation, $this->manifest->getCopyrightInformation());
}
public function testRequirementsCanBeRetrieved() {
$this->assertEquals($this->requirements, $this->manifest->getRequirements());
}
public function testBundledComponentsCanBeRetrieved() {
$this->assertEquals($this->bundledComponents, $this->manifest->getBundledComponents());
}
/**
* @uses \PharIo\Manifest\Extension
*/
public function testExtendedApplicationCanBeQueriedForExtension()
{
$appName = new ApplicationName('foo/bar');
$manifest = new Manifest(
new ApplicationName('foo/foo'),
new Version('1.0.0'),
Type::extension($appName, new AnyVersionConstraint),
$this->copyrightInformation,
new RequirementCollection,
new BundledComponentCollection
);
$this->assertTrue($manifest->isExtensionFor($appName));
}
public function testNonExtensionReturnsFalseWhenQueriesForExtension() {
$appName = new ApplicationName('foo/bar');
$manifest = new Manifest(
new ApplicationName('foo/foo'),
new Version('1.0.0'),
Type::library(),
$this->copyrightInformation,
new RequirementCollection,
new BundledComponentCollection
);
$this->assertFalse($manifest->isExtensionFor($appName));
}
/**
* @uses \PharIo\Manifest\Extension
*/
public function testExtendedApplicationCanBeQueriedForExtensionWithVersion()
{
$appName = new ApplicationName('foo/bar');
$manifest = new Manifest(
new ApplicationName('foo/foo'),
new Version('1.0.0'),
Type::extension($appName, new AnyVersionConstraint),
$this->copyrightInformation,
new RequirementCollection,
new BundledComponentCollection
);
$this->assertTrue($manifest->isExtensionFor($appName, new Version('1.2.3')));
}
}