Skip to content

Commit 0cabb1b

Browse files
committed
remove newer PHPUnit usage
1 parent 330d422 commit 0cabb1b

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

tests/SemanticVersionTest.php

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,30 @@ public function testCanParseVersionWithPrereleaseAndBuild()
4949

5050
public function testLeadingZeroNotAllowedInMajor()
5151
{
52-
$this->expectException(\InvalidArgumentException::class);
53-
SemanticVersion::parse('02.3.4');
52+
try {
53+
SemanticVersion::parse('02.3.4');
54+
$this->assertTrue(false, 'expected exception');
55+
// can't use expectException method because we must support older PHPUnit
56+
} catch (\InvalidArgumentException $e) {
57+
}
5458
}
5559

5660
public function testLeadingZeroNotAllowedInMinor()
5761
{
58-
$this->expectException(\InvalidArgumentException::class);
59-
SemanticVersion::parse('2.03.4');
62+
try {
63+
SemanticVersion::parse('2.03.4');
64+
$this->assertTrue(false, 'expected exception');
65+
} catch (\InvalidArgumentException $e) {
66+
}
6067
}
6168

6269
public function testLeadingZeroNotAllowedInPatch()
6370
{
64-
$this->expectException(\InvalidArgumentException::class);
65-
SemanticVersion::parse('2.3.04');
71+
try {
72+
SemanticVersion::parse('2.3.04');
73+
$this->assertTrue(false, 'expected exception');
74+
} catch (\InvalidArgumentException $e) {
75+
}
6676
}
6777

6878
public function testZeroByItselfIsAllowed()
@@ -139,14 +149,20 @@ public function testCanParseVersionWithMajorMinorAndBuildOnlyInLooseMode()
139149

140150
public function testCannotParseVersionWithMajorOnlyByDefault()
141151
{
142-
$this->expectException(\InvalidArgumentException::class);
143-
SemanticVersion::parse('2');
152+
try {
153+
SemanticVersion::parse('2');
154+
$this->assertTrue(false, 'expected exception');
155+
} catch (\InvalidArgumentException $e) {
156+
}
144157
}
145158

146159
public function testCannotParseVersionWithMajorAndMinorOnlyByDefault()
147160
{
148-
$this->expectException(\InvalidArgumentException::class);
149-
SemanticVersion::parse('2.3');
161+
try {
162+
SemanticVersion::parse('2.3');
163+
$this->assertTrue(false, 'expected exception');
164+
} catch (\InvalidArgumentException $e) {
165+
}
150166
}
151167

152168
public function testEqualVersionsHaveEqualPrecedence()

0 commit comments

Comments
 (0)