Skip to content

Commit eb41326

Browse files
committed
refactor: Replace @ExpectedException annotation for expectException method
1 parent e6eac18 commit eb41326

File tree

5 files changed

+21
-38
lines changed

5 files changed

+21
-38
lines changed

tests/Constraints/FactoryTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,17 @@ public function invalidConstraintNameProvider()
9696
);
9797
}
9898

99-
/**
100-
* @expectedException \JsonSchema\Exception\InvalidArgumentException
101-
*/
10299
public function testSetConstraintClassExistsCondition()
103100
{
101+
$this->expectException(\JsonSchema\Exception\InvalidArgumentException::class);
102+
104103
$this->factory->setConstraintClass('string', 'SomeConstraint');
105104
}
106105

107-
/**
108-
* @expectedException \JsonSchema\Exception\InvalidArgumentException
109-
*/
110106
public function testSetConstraintClassImplementsCondition()
111107
{
108+
$this->expectException(\JsonSchema\Exception\InvalidArgumentException::class);
109+
112110
$this->factory->setConstraintClass('string', 'JsonSchema\Tests\Constraints\MyBadConstraint');
113111
}
114112

tests/Uri/Retrievers/FileGetContentsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
*/
1111
class FileGetContentsTest extends TestCase
1212
{
13-
/**
14-
* @expectedException \JsonSchema\Exception\ResourceNotFoundException
15-
*/
1613
public function testFetchMissingFile()
1714
{
1815
$res = new FileGetContents();
16+
17+
$this->expectException(\JsonSchema\Exception\ResourceNotFoundException::class);
18+
1919
$res->retrieve(__DIR__ . '/Fixture/missing.json');
2020
}
2121

tests/Uri/Retrievers/PredefinedArrayTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ public function testRetrieve()
2929
$this->assertEquals('THE_ADDRESS_SCHEMA', $this->retriever->retrieve('http://acme.com/schemas/address#'));
3030
}
3131

32-
/**
33-
* @expectedException \JsonSchema\Exception\ResourceNotFoundException
34-
*/
3532
public function testRetrieveNonExistsingSchema()
3633
{
34+
$this->expectException(\JsonSchema\Exception\ResourceNotFoundException::class);
3735
$this->retriever->retrieve('http://acme.com/schemas/plop#');
3836
}
3937

tests/Uri/UriResolverTest.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,11 @@ public function testResolveAbsoluteUri()
9696
);
9797
}
9898

99-
/**
100-
* @expectedException \JsonSchema\Exception\UriResolverException
101-
*/
99+
102100
public function testResolveRelativeUriNoBase()
103101
{
104-
$this->assertEquals(
105-
'http://example.org/foo/bar.json',
106-
$this->resolver->resolve(
107-
'bar.json',
108-
null
109-
)
110-
);
102+
$this->expectException(\JsonSchema\Exception\UriResolverException::class);
103+
$this->resolver->resolve('bar.json', null);
111104
}
112105

113106
public function testResolveRelativeUriBaseDir()

tests/Uri/UriRetrieverTest.php

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ public function testResolvePointerFragment()
182182
);
183183
}
184184

185-
/**
186-
* @expectedException \JsonSchema\Exception\ResourceNotFoundException
187-
*/
188185
public function testResolvePointerFragmentNotFound()
189186
{
190187
$schema = (object) array(
@@ -197,14 +194,13 @@ public function testResolvePointerFragmentNotFound()
197194
);
198195

199196
$retriever = new UriRetriever();
197+
198+
$this->expectException(ResourceNotFoundException::class);
200199
$retriever->resolvePointer(
201200
$schema, 'http://example.org/schema.json#/definitions/bar'
202201
);
203202
}
204203

205-
/**
206-
* @expectedException \JsonSchema\Exception\ResourceNotFoundException
207-
*/
208204
public function testResolvePointerFragmentNoArray()
209205
{
210206
$schema = (object) array(
@@ -217,17 +213,18 @@ public function testResolvePointerFragmentNoArray()
217213
);
218214

219215
$retriever = new UriRetriever();
216+
217+
$this->expectException(ResourceNotFoundException::class);
220218
$retriever->resolvePointer(
221219
$schema, 'http://example.org/schema.json#/definitions/foo'
222220
);
223221
}
224222

225-
/**
226-
* @expectedException \JsonSchema\Exception\UriResolverException
227-
*/
228223
public function testResolveExcessLevelUp()
229224
{
230225
$retriever = new UriRetriever();
226+
227+
$this->expectException(UriResolverException::class);
231228
$retriever->resolve(
232229
'../schema.json#', 'http://example.org/schema.json#'
233230
);
@@ -257,9 +254,6 @@ public function testConfirmMediaTypeAcceptsJsonType()
257254
$this->assertEquals(null, $retriever->confirmMediaType($uriRetriever, null));
258255
}
259256

260-
/**
261-
* @expectedException \JsonSchema\Exception\InvalidSchemaMediaTypeException
262-
*/
263257
public function testConfirmMediaTypeThrowsExceptionForUnsupportedTypes()
264258
{
265259
$uriRetriever = $this->getMock('JsonSchema\Uri\Retrievers\UriRetrieverInterface');
@@ -269,7 +263,9 @@ public function testConfirmMediaTypeThrowsExceptionForUnsupportedTypes()
269263
->method('getContentType')
270264
->willReturn('text/html');
271265

272-
$this->assertEquals(null, $retriever->confirmMediaType($uriRetriever, null));
266+
$this->expectException(InvalidSchemaMediaTypeException::class);
267+
268+
$retriever->confirmMediaType($uriRetriever, null);
273269
}
274270

275271
private function mockRetriever($schema)
@@ -343,15 +339,13 @@ public function testInvalidContentTypeEndpointsDefault()
343339
$this->assertTrue($retriever->confirmMediaType($mock, 'https://json-schema.org/'));
344340
}
345341

346-
/**
347-
* @expectedException \JsonSchema\Exception\InvalidSchemaMediaTypeException
348-
*/
349342
public function testInvalidContentTypeEndpointsUnknown()
350343
{
351344
$mock = $this->getMock('JsonSchema\Uri\Retrievers\UriRetrieverInterface');
352345
$mock->method('getContentType')->willReturn('Application/X-Fake-Type');
353346
$retriever = new UriRetriever();
354347

348+
$this->expectException(InvalidSchemaMediaTypeException::class);
355349
$retriever->confirmMediaType($mock, 'http://example.com');
356350
}
357351

0 commit comments

Comments
 (0)