-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathVersionTest.php
More file actions
53 lines (46 loc) · 1.35 KB
/
VersionTest.php
File metadata and controls
53 lines (46 loc) · 1.35 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
<?php
namespace CssCrush\UnitTest;
use CssCrush\Version;
class VersionTest extends \PHPUnit\Framework\TestCase
{
public function test__toString()
{
$version = new Version('2.8.5');
$version->minor = 9;
$version->extra = 'beta';
$this->assertEquals('v2.9.5-beta', (string) $version);
unset($version->extra);
$this->assertEquals('v2.9.5', (string) $version);
}
public function testCompare()
{
$version = new Version('1.8.5-beta');
$this->assertEquals(1, $version->compare('1'));
$this->assertEquals(-1, $version->compare('2'));
$this->assertEquals(0, $version->compare('1.8.5'));
}
public function testProperties()
{
$version = new Version('1.8.5');
$this->assertEquals(1, $version->major);
$this->assertEquals(8, $version->minor);
$this->assertEquals(5, $version->patch);
}
public function testGitDescribe()
{
if ($version = Version::gitDescribe()) {
$this->assertMatchesRegularExpression('~^
v
\d+\.
\d+\.
\d+
(-(?:alpha|beta)\.\d+)?
-\d+
-g.+
$~x', $version->__toString());
}
else {
$this->markTestSkipped('Returned null');
}
}
}