Skip to content

Commit aa3e018

Browse files
committed
refactor: use ::class constant instead of string value
1 parent 8e7328a commit aa3e018

17 files changed

+41
-41
lines changed

tests/ConstraintErrorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function testGetInvalidMessage(): void
1919
{
2020
$e = ConstraintError::MISSING_ERROR();
2121

22-
$this->expectException('\JsonSchema\Exception\InvalidArgumentException');
22+
$this->expectException(\JsonSchema\Exception\InvalidArgumentException::class);
2323
$this->expectExceptionMessage('Missing error message for missingError');
2424

2525
$e->getMessage();

tests/Constraints/SchemaValidationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ public function testValidCases($schema): void
9797

9898
public function testNonObjectSchema(): void
9999
{
100-
$this->expectException('\JsonSchema\Exception\RuntimeException');
100+
$this->expectException(\JsonSchema\Exception\RuntimeException::class);
101101
$this->expectExceptionMessage('Cannot validate the schema of a non-object');
102102

103103
$this->testValidCases('"notAnObject"');
104104
}
105105

106106
public function testInvalidSchemaException(): void
107107
{
108-
$this->expectException('\JsonSchema\Exception\InvalidSchemaException');
108+
$this->expectException(\JsonSchema\Exception\InvalidSchemaException::class);
109109
$this->expectExceptionMessage('Schema did not pass validation');
110110

111111
$input = json_decode('{}');

tests/Constraints/TypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function testValidateTypeException(): void
121121
$data = new \stdClass();
122122
$schema = json_decode('{"type": "notAValidTypeName"}');
123123

124-
$this->expectException('JsonSchema\Exception\InvalidArgumentException');
124+
$this->expectException(\JsonSchema\Exception\InvalidArgumentException::class);
125125
$this->expectExceptionMessage('object is an invalid type for notAValidTypeName');
126126

127127
$t->check($data, $schema);

tests/Constraints/ValidationExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ValidationExceptionTest extends TestCase
1414
public function testValidationException(): void
1515
{
1616
$exception = new ValidationException();
17-
$this->assertInstanceOf('\JsonSchema\Exception\ValidationException', $exception);
17+
$this->assertInstanceOf(\JsonSchema\Exception\ValidationException::class, $exception);
1818

1919
$checkValue = json_decode('{"propertyOne": "thisIsNotAnObject"}');
2020
$schema = json_decode('{
@@ -40,7 +40,7 @@ public function testValidationException(): void
4040
$exception->getMessage()
4141
);
4242

43-
$this->expectException('JsonSchema\Exception\ValidationException');
43+
$this->expectException(\JsonSchema\Exception\ValidationException::class);
4444
throw $exception;
4545
}
4646
}

tests/Exception/InvalidArgumentExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public function testHierarchy(): void
1313
{
1414
$exception = new InvalidArgumentException();
1515
self::assertInstanceOf('\InvalidArgumentException', $exception);
16-
self::assertInstanceOf('\JsonSchema\Exception\ExceptionInterface', $exception);
16+
self::assertInstanceOf(\JsonSchema\Exception\ExceptionInterface::class, $exception);
1717
}
1818
}

tests/Exception/InvalidSchemaMediaTypeExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function testHierarchy(): void
1313
{
1414
$exception = new InvalidSchemaMediaTypeException();
1515
self::assertInstanceOf('\RuntimeException', $exception);
16-
self::assertInstanceOf('\JsonSchema\Exception\RuntimeException', $exception);
17-
self::assertInstanceOf('\JsonSchema\Exception\ExceptionInterface', $exception);
16+
self::assertInstanceOf(\JsonSchema\Exception\RuntimeException::class, $exception);
17+
self::assertInstanceOf(\JsonSchema\Exception\ExceptionInterface::class, $exception);
1818
}
1919
}

tests/Exception/InvalidSourceUriExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function testHierarchy(): void
1313
{
1414
$exception = new InvalidSourceUriException();
1515
self::assertInstanceOf('\InvalidArgumentException', $exception);
16-
self::assertInstanceOf('\JsonSchema\Exception\InvalidArgumentException', $exception);
17-
self::assertInstanceOf('\JsonSchema\Exception\ExceptionInterface', $exception);
16+
self::assertInstanceOf(\JsonSchema\Exception\InvalidArgumentException::class, $exception);
17+
self::assertInstanceOf(\JsonSchema\Exception\ExceptionInterface::class, $exception);
1818
}
1919
}

tests/Exception/JsonDecodingExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ public function testHierarchy(): void
1313
{
1414
$exception = new JsonDecodingException();
1515
self::assertInstanceOf('\RuntimeException', $exception);
16-
self::assertInstanceOf('\JsonSchema\Exception\RuntimeException', $exception);
17-
self::assertInstanceOf('\JsonSchema\Exception\ExceptionInterface', $exception);
16+
self::assertInstanceOf(\JsonSchema\Exception\RuntimeException::class, $exception);
17+
self::assertInstanceOf(\JsonSchema\Exception\ExceptionInterface::class, $exception);
1818
}
1919

2020
public function testDefaultMessage()

tests/Exception/ResourceNotFoundExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public function testHierarchy(): void
1313
{
1414
$exception = new ResourceNotFoundException();
1515
self::assertInstanceOf('\RuntimeException', $exception);
16-
self::assertInstanceOf('\JsonSchema\Exception\RuntimeException', $exception);
17-
self::assertInstanceOf('\JsonSchema\Exception\ExceptionInterface', $exception);
16+
self::assertInstanceOf(\JsonSchema\Exception\RuntimeException::class, $exception);
17+
self::assertInstanceOf(\JsonSchema\Exception\ExceptionInterface::class, $exception);
1818
}
1919
}

tests/Exception/RuntimeExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public function testHierarchy(): void
1313
{
1414
$exception = new RuntimeException();
1515
self::assertInstanceOf('\RuntimeException', $exception);
16-
self::assertInstanceOf('\JsonSchema\Exception\ExceptionInterface', $exception);
16+
self::assertInstanceOf(\JsonSchema\Exception\ExceptionInterface::class, $exception);
1717
}
1818
}

0 commit comments

Comments
 (0)