11<?php
22namespace Gt \Http \Test ;
33
4+ use Gt \Http \PortOutOfBoundsException ;
45use Gt \Http \Uri ;
56use Gt \Http \UriFactory ;
7+ use Gt \Http \UriParseErrorException ;
68use PHPUnit \Framework \TestCase ;
9+ use TypeError ;
710
811class UriTest extends TestCase {
912 public function testParsesProvidedUri () {
@@ -83,11 +86,9 @@ public function getValidUris() {
8386 ];
8487 }
8588
86- /**
87- * @expectedException \Gt\Http\UriParseErrorException
88- * @dataProvider getInvalidUris
89- */
89+ /** @dataProvider getInvalidUris */
9090 public function testInvalidUrisThrowException ($ invalidUri ) {
91+ self ::expectException (UriParseErrorException::class);
9192 new Uri ($ invalidUri );
9293 }
9394
@@ -101,59 +102,43 @@ public function getInvalidUris() {
101102 ];
102103 }
103104
104- /**
105- * @expectedException \Gt\Http\PortOutOfBoundsException
106- */
107105 public function testPortMustBeValid () {
106+ self ::expectException (PortOutOfBoundsException::class);
108107 (new Uri ())->withPort (100000 );
109108 }
110109
111- /**
112- * @expectedException \Gt\Http\PortOutOfBoundsException
113- */
114110 public function testWithPortCannotBeZero () {
111+ self ::expectException (PortOutOfBoundsException::class);
115112 (new Uri ())->withPort (0 );
116113 }
117114
118- /**
119- * @expectedException \Gt\Http\UriParseErrorException
120- */
121115 public function testParseUriPortCannotBeZero () {
116+ self ::expectException (UriParseErrorException::class);
122117 new Uri ('//example.com:0 ' );
123118 }
124119
125- /**
126- * @expectedException \TypeError
127- */
128120 public function testSchemeMustHaveCorrectType () {
121+ self ::expectException (TypeError::class);
129122 (new Uri ())->withScheme ([]);
130123 }
131124
132- /**
133- * @expectedException \TypeError
134- */
135125 public function testHostMustHaveCorrectType () {
126+ self ::expectException (TypeError::class);
136127 (new Uri ())->withHost ([]);
137128 }
138129
139- /**
140- * @expectedException \TypeError
141- */
142130 public function testPathMustHaveCorrectType () {
131+ self ::expectException (TypeError::class);
143132 (new Uri ())->withPath ([]);
144133 }
145134
146- /**
147- * @expectedException \TypeError
148- */
149135 public function testQueryMustHaveCorrectType () {
136+ self ::expectException (TypeError::class);
150137 (new Uri ())->withQuery ([]);
151138 }
152139
153- /**
154- * @expectedException \TypeError
155- */
156140 public function testFragmentMustHaveCorrectType () {
141+ self ::expectException (TypeError::class);
157142 (new Uri ())->withFragment ([]);
158143 }
159144
@@ -379,10 +364,8 @@ public function testStandardPortIsNullIfSchemeChanges() {
379364 $ this ->assertNull ($ uri ->getPort ());
380365 }
381366
382- /**
383- * @expectedException \TypeError
384- */
385367 public function testPortPassedAsStringIsCastedToInt () {
368+ self ::expectException (TypeError::class);
386369 $ uri = (new Uri ('//example.com ' ))->withPort ('8080 ' );
387370 }
388371
0 commit comments