Skip to content

Commit e3e5972

Browse files
committed
chore: Use self:: instead of static:: inside tests.
This was a change from php-cs-fixer.
1 parent c01b3ad commit e3e5972

26 files changed

+251
-251
lines changed

tests/unit/Bridge/LeagueOpenAPIValidation/Exception/InvalidOpenApiDefinitionExceptionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function testItCanBeBuilt(): void
1515
{
1616
$exception = new InvalidOpenApiDefinitionException(new Exception());
1717

18-
static::assertInstanceOf(InvalidArgumentException::class, $exception);
19-
static::assertStringContainsString('The given OpenApi definition can\'t be loaded', $exception->getMessage());
18+
self::assertInstanceOf(InvalidArgumentException::class, $exception);
19+
self::assertStringContainsString('The given OpenApi definition can\'t be loaded', $exception->getMessage());
2020
}
2121
}

tests/unit/Bridge/LeagueOpenAPIValidation/Exception/ValidationExceptionMapperTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testItDoesntMapUnknownException(): void
3333
)
3434
);
3535

36-
static::assertNull(
36+
self::assertNull(
3737
(new ValidationExceptionMapper())->map($exceptionChain)
3838
);
3939
}
@@ -53,9 +53,9 @@ public function testItMapsSchemaMismatchException(): void
5353

5454
$mapped = (new ValidationExceptionMapper())->map($exceptionChain);
5555

56-
static::assertInstanceOf(DataSchemaException::class, $mapped);
57-
static::assertSame('a.b', $mapped->path);
58-
static::assertSame($error, $mapped->getPrevious());
56+
self::assertInstanceOf(DataSchemaException::class, $mapped);
57+
self::assertSame('a.b', $mapped->path);
58+
self::assertSame($error, $mapped->getPrevious());
5959
}
6060

6161
public function testItMapsInvalidSchema(): void
@@ -72,8 +72,8 @@ public function testItMapsInvalidSchema(): void
7272

7373
$mapped = (new ValidationExceptionMapper())->map($exceptionChain);
7474

75-
static::assertInstanceOf(ApiSchemaException::class, $mapped);
76-
static::assertSame($error, $mapped->getPrevious());
75+
self::assertInstanceOf(ApiSchemaException::class, $mapped);
76+
self::assertSame($error, $mapped->getPrevious());
7777
}
7878

7979
public function testItMapsValidationFailed(): void
@@ -90,7 +90,7 @@ public function testItMapsValidationFailed(): void
9090

9191
$mapped = (new ValidationExceptionMapper())->map($exceptionChain);
9292

93-
static::assertInstanceOf(GenericException::class, $mapped);
93+
self::assertInstanceOf(GenericException::class, $mapped);
9494
}
9595

9696
public function testItMapsInvalidQueryArgs(): void
@@ -113,7 +113,7 @@ public function testItMapsInvalidQueryArgs(): void
113113

114114
$mapped = (new ValidationExceptionMapper())->map($exceptionChain);
115115

116-
static::assertInstanceOf(GenericException::class, $mapped);
117-
static::assertSame($invalidQueryArgsError, $mapped->getPrevious());
116+
self::assertInstanceOf(GenericException::class, $mapped);
117+
self::assertSame($invalidQueryArgsError, $mapped->getPrevious());
118118
}
119119
}

tests/unit/Bridge/LeagueOpenAPIValidation/FactoryTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ public function testItCanBuildValidators(): void
2121
{
2222
$leagueBuilder = $this->createMock(ValidatorBuilder::class);
2323
$leagueBuilder
24-
->expects(static::once())
24+
->expects(self::once())
2525
->method('getRequestValidator')
2626
->willReturn($this->createMock(PSR7RequestValidator::class));
2727
$leagueBuilder
28-
->expects(static::once())
28+
->expects(self::once())
2929
->method('getResponseValidator')
3030
->willReturn($this->createMock(PSR7ResponseValidator::class));
3131

3232
$factory = new Factory($leagueBuilder);
3333

34-
static::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator());
35-
static::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator());
34+
self::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator());
35+
self::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator());
3636
}
3737

3838
public function testItCaptureErrorsDuringRequestValidatorCreation(): void
@@ -41,7 +41,7 @@ public function testItCaptureErrorsDuringRequestValidatorCreation(): void
4141

4242
$leagueBuilder = $this->createMock(ValidatorBuilder::class);
4343
$leagueBuilder
44-
->expects(static::once())
44+
->expects(self::once())
4545
->method('getRequestValidator')
4646
->willThrowException(new Exception('Anything happened there…'));
4747

@@ -54,7 +54,7 @@ public function testItCaptureErrorsDuringResponseValidatorCreation(): void
5454

5555
$leagueBuilder = $this->createMock(ValidatorBuilder::class);
5656
$leagueBuilder
57-
->expects(static::once())
57+
->expects(self::once())
5858
->method('getResponseValidator')
5959
->willThrowException(new Exception('Anything happened there…'));
6060

@@ -71,14 +71,14 @@ public function testItCanBeBuiltFromYamlFile(): void
7171
YAML);
7272

7373
if ($writeSuccess === false) {
74-
static::markTestSkipped('Temp file wasn\'t written.');
74+
self::markTestSkipped('Temp file wasn\'t written.');
7575
return;
7676
}
7777

7878
$factory = Factory::fromYamlFile($file);
7979

80-
static::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator());
81-
static::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator());
80+
self::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator());
81+
self::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator());
8282
}
8383

8484
public function testItCanBeBuiltFromJsonFile(): void
@@ -94,14 +94,14 @@ public function testItCanBeBuiltFromJsonFile(): void
9494
JSON);
9595

9696
if ($writeSuccess === false) {
97-
static::markTestSkipped('Temp file wasn\'t written.');
97+
self::markTestSkipped('Temp file wasn\'t written.');
9898
return;
9999
}
100100

101101
$factory = Factory::fromJsonFile($file);
102102

103-
static::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator());
104-
static::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator());
103+
self::assertInstanceOf(RequestValidator::class, $factory->getRequestValidator());
104+
self::assertInstanceOf(ResponseValidator::class, $factory->getResponseValidator());
105105
}
106106

107107
public function testItCantBeBuiltFromInexistantJsonFile(): void

tests/unit/Bridge/LeagueOpenAPIValidation/RequestValidatorTest.php

Lines changed: 71 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -30,77 +30,77 @@ public function testItCanBeBuilt(): void
3030
new ValidationExceptionMapper()
3131
);
3232

33-
static::assertInstanceOf(RequestValidatorInterface::class, $validator);
33+
self::assertInstanceOf(RequestValidatorInterface::class, $validator);
3434
}
3535

36-
public function testItCanValidateRequest(): void
37-
{
38-
$requestValidator = $this->createMock(PSR7RequestValidator::class);
39-
$request = $this->createMock(RequestInterface::class);
40-
41-
$requestValidator
42-
->expects(static::once())
43-
->method('validate')
44-
->with($request);
45-
46-
(new RequestValidator(
47-
$requestValidator,
48-
new ValidationExceptionMapper()
49-
))->validate($request);
50-
}
51-
52-
public function testItCallsExceptionMapperOnThrowable(): void
53-
{
54-
$this->expectException(ApiSchemaException::class);
55-
56-
$requestValidator = $this->createMock(PSR7RequestValidator::class);
57-
$validationMapper = $this->createMock(ValidationExceptionMapper::class);
58-
$request = $this->createMock(RequestInterface::class);
59-
60-
$error = new Exception('Error');
61-
62-
$requestValidator
63-
->expects(static::once())
64-
->method('validate')
65-
->with($request)
66-
->willThrowException($error);
67-
68-
$validationMapper
69-
->expects(static::once())
70-
->method('map')
71-
->with($error)
72-
->willReturn(new ApiSchemaException($error));
73-
74-
(new RequestValidator($requestValidator, $validationMapper))->validate($request);
75-
}
76-
77-
/**
78-
* @dataProvider giveExceptions
79-
*/
80-
public function testItCanCatchExceptions(Throwable $error, string $exception): void
81-
{
82-
$this->expectException($exception);
83-
84-
$requestValidator = $this->createMock(PSR7RequestValidator::class);
85-
$request = $this->createMock(RequestInterface::class);
86-
87-
$requestValidator
88-
->expects(static::once())
89-
->method('validate')
90-
->with($request)
91-
->willThrowException($error);
92-
93-
(new RequestValidator(
94-
$requestValidator,
95-
new ValidationExceptionMapper()
96-
))->validate($request);
97-
}
98-
99-
public function giveExceptions(): \Generator
100-
{
101-
yield [new NoOperation('Message'), OperationNotFoundException::class];
102-
yield [new NoPath('Message'), OperationNotFoundException::class];
103-
yield [new MultipleOperationsMismatchForRequest('Message'), OperationNotFoundException::class];
104-
yield [new RuntimeException('Message'), RuntimeException::class];
105-
}
36+
public function testItCanValidateRequest(): void
37+
{
38+
$requestValidator = $this->createMock(PSR7RequestValidator::class);
39+
$request = $this->createMock(RequestInterface::class);
40+
41+
$requestValidator
42+
->expects(self::once())
43+
->method('validate')
44+
->with($request);
45+
46+
(new RequestValidator(
47+
$requestValidator,
48+
new ValidationExceptionMapper()
49+
))->validate($request);
50+
}
51+
52+
public function testItCallsExceptionMapperOnThrowable(): void
53+
{
54+
$this->expectException(ApiSchemaException::class);
55+
56+
$requestValidator = $this->createMock(PSR7RequestValidator::class);
57+
$validationMapper = $this->createMock(ValidationExceptionMapper::class);
58+
$request = $this->createMock(RequestInterface::class);
59+
60+
$error = new Exception('Error');
61+
62+
$requestValidator
63+
->expects(self::once())
64+
->method('validate')
65+
->with($request)
66+
->willThrowException($error);
67+
68+
$validationMapper
69+
->expects(self::once())
70+
->method('map')
71+
->with($error)
72+
->willReturn(new ApiSchemaException($error));
73+
74+
(new RequestValidator($requestValidator, $validationMapper))->validate($request);
75+
}
76+
77+
/**
78+
* @dataProvider provideItCanCatchExceptionsCases
79+
*/
80+
public function testItCanCatchExceptions(Throwable $error, string $exception): void
81+
{
82+
$this->expectException($exception);
83+
84+
$requestValidator = $this->createMock(PSR7RequestValidator::class);
85+
$request = $this->createMock(RequestInterface::class);
86+
87+
$requestValidator
88+
->expects(self::once())
89+
->method('validate')
90+
->with($request)
91+
->willThrowException($error);
92+
93+
(new RequestValidator(
94+
$requestValidator,
95+
new ValidationExceptionMapper()
96+
))->validate($request);
97+
}
98+
99+
public static function provideItCanCatchExceptionsCases(): iterable
100+
{
101+
yield [new NoOperation('Message'), OperationNotFoundException::class];
102+
yield [new NoPath('Message'), OperationNotFoundException::class];
103+
yield [new MultipleOperationsMismatchForRequest('Message'), OperationNotFoundException::class];
104+
yield [new RuntimeException('Message'), RuntimeException::class];
105+
}
106106
}

0 commit comments

Comments
 (0)