-
Notifications
You must be signed in to change notification settings - Fork 3
/
VersionTest.php
86 lines (75 loc) · 2.42 KB
/
VersionTest.php
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
<?php
namespace Concise;
class VersionTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->version = new Version();
}
public function testAnEmptyStringWillBeReturnedIfThePackageCanNotBeFound()
{
$this->assert($this->version->getVersionForPackage('foo'), is_blank);
}
public function testVersionCanBeExtractedForAPackageName()
{
$this->assert(
$this->version->getVersionForPackage('sebastian/version'),
matches_regex,
'/^\\d\.\\d+/'
);
}
public function testWeCanEasilyGetTheConciseVersion()
{
$this->assert(
$this->version->getConciseVersion(),
equals,
$this->version->getVersionForPackage('elliotchance/concise')
);
}
public function testFindingVendorFolder()
{
$this->assert($this->version->findVendorFolder(), ends_with, '/vendor');
}
public function testReturnEmptyStringIfVendorFolderCannotBeFound()
{
$version = $this->niceMock('Concise\Version')
->stub('findVendorFolder')
->get();
$this->assert($version->getConciseVersion(), is_blank);
}
public function testFindVendorFolderWillReturnNullIfTheVendorFolderCouldNotBeFound()
{
$version = $this->niceMock('Concise\Version')
->expose('findVendorFolder')
->get();
$this->assert($version->findVendorFolder('/tmp'), is_null);
}
public function versionData()
{
return array(
// Edge cases.
'unknown version is blank' => array('', ''),
'version can be prefixed with v' => array('v1.1', 'Dark Matter'),
'patch version' => array('1.2.3', 'String Theory'),
// Specific versions.
array('1.0', 'Big Bang'),
array('1.1', 'Dark Matter'),
array('1.2', 'String Theory'),
array('1.3', 'Supernova'),
array('1.4', 'Quantum'),
array('1.5', 'Antimatter'),
array('1.6', 'Entropy'),
array('1.7', 'Multiverse'),
);
}
/**
* @group #257
* @dataProvider versionData
*/
public function testVersionName($version, $expectedName)
{
$name = $this->version->getVersionNameForVersion($version);
$this->assert($name, equals, $expectedName);
}
}