@@ -47,32 +47,31 @@ public function testCanParseVersionWithPrereleaseAndBuild()
4747 $ this ->assertEquals ('build2.4 ' , $ sv ->build );
4848 }
4949
50+ /**
51+ * @expectedException \InvalidArgumentException
52+ * @expectedExceptionMessage not a valid semantic version
53+ */
5054 public function testLeadingZeroNotAllowedInMajor ()
5155 {
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- }
56+ SemanticVersion::parse ('02.3.4 ' );
5857 }
5958
59+ /**
60+ * @expectedException \InvalidArgumentException
61+ * @expectedExceptionMessage not a valid semantic version
62+ */
6063 public function testLeadingZeroNotAllowedInMinor ()
6164 {
62- try {
63- SemanticVersion::parse ('2.03.4 ' );
64- $ this ->assertTrue (false , 'expected exception ' );
65- } catch (\InvalidArgumentException $ e ) {
66- }
65+ SemanticVersion::parse ('2.03.4 ' );
6766 }
6867
68+ /**
69+ * @expectedException \InvalidArgumentException
70+ * @expectedExceptionMessage not a valid semantic version
71+ */
6972 public function testLeadingZeroNotAllowedInPatch ()
7073 {
71- try {
72- SemanticVersion::parse ('2.3.04 ' );
73- $ this ->assertTrue (false , 'expected exception ' );
74- } catch (\InvalidArgumentException $ e ) {
75- }
74+ SemanticVersion::parse ('2.3.04 ' );
7675 }
7776
7877 public function testZeroByItselfIsAllowed ()
@@ -147,22 +146,22 @@ public function testCanParseVersionWithMajorMinorAndBuildOnlyInLooseMode()
147146 $ this ->assertEquals ('build1 ' , $ sv ->build );
148147 }
149148
149+ /**
150+ * @expectedException \InvalidArgumentException
151+ * @expectedExceptionMessage not a valid semantic version
152+ */
150153 public function testCannotParseVersionWithMajorOnlyByDefault ()
151154 {
152- try {
153- SemanticVersion::parse ('2 ' );
154- $ this ->assertTrue (false , 'expected exception ' );
155- } catch (\InvalidArgumentException $ e ) {
156- }
155+ SemanticVersion::parse ('2 ' );
157156 }
158157
158+ /**
159+ * @expectedException \InvalidArgumentException
160+ * @expectedExceptionMessage not a valid semantic version
161+ */
159162 public function testCannotParseVersionWithMajorAndMinorOnlyByDefault ()
160163 {
161- try {
162- SemanticVersion::parse ('2.3 ' );
163- $ this ->assertTrue (false , 'expected exception ' );
164- } catch (\InvalidArgumentException $ e ) {
165- }
164+ SemanticVersion::parse ('2.3 ' );
166165 }
167166
168167 public function testEqualVersionsHaveEqualPrecedence ()
0 commit comments