Skip to content

Commit fc0448b

Browse files
committed
tests refactoring
1 parent cd0a431 commit fc0448b

File tree

7 files changed

+24
-34
lines changed

7 files changed

+24
-34
lines changed

test/Factory/Symfony/ResponseFactoryTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
final class ResponseFactoryTest extends TestCase
1212
{
1313
/**
14-
* @dataProvider dataProviderMakeArray
15-
*
1614
* @param iterable<mixed> $streamedData
1715
*/
16+
#[DataProvider('dataProviderMakeArray')]
1817
public function testMakeArray(string $expectedBody, iterable $streamedData): void
1918
{
2019
$response = ResponseFactory::makeArray($streamedData);

test/Model/Client/RequestTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class RequestTest extends TestCase
1111
public function testWithJson(): void
1212
{
1313
$request = new Request('POST', '/test');
14-
$request = $request->withBaseUrl('http://host');
14+
$request = $request->withBaseUrl('https://host');
1515
$requestWithJson = $request->withJson(['test' => 'test'], null);
1616

1717
$factory = new HttpFactory();
@@ -23,13 +23,13 @@ public function testWithJson(): void
2323
public function testWithBaseUrl(): void
2424
{
2525
$request = new Request('GET', '/test', ['test' => 'test'], null, ['test' => 'test']);
26-
$requestWithBaseUrl = $request->withBaseUrl('http://host');
26+
$requestWithBaseUrl = $request->withBaseUrl('https://host');
2727
$psrRequest = $requestWithBaseUrl->createPsr(new HttpFactory());
2828

2929
self::assertSame(false, $request->hasBaseUrl());
3030
self::assertSame(true, $requestWithBaseUrl->hasBaseUrl());
3131
self::assertSame('GET', $psrRequest->getMethod());
32-
self::assertSame('http://host/test?test=test', (string) $psrRequest->getUri());
32+
self::assertSame('https://host/test?test=test', (string) $psrRequest->getUri());
3333
self::assertSame('', $psrRequest->getBody()->getContents());
3434
self::assertSame(['test'], $psrRequest->getHeader('test'));
3535
}

test/Model/Server/HeaderRuleTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
declare(strict_types=1);
44

5+
use PHPUnit\Framework\Attributes\CoversClass;
56
use PHPUnit\Framework\TestCase;
67
use SimpleAsFuck\ApiToolkit\Model\Server\HeaderRule;
78
use SimpleAsFuck\Validator\Factory\UnexpectedValueException;
89
use SimpleAsFuck\Validator\Model\Validated;
910
use SimpleAsFuck\Validator\Rule\String\StringRule;
1011

11-
/**
12-
* @covers \SimpleAsFuck\ApiToolkit\Model\Server\HeaderRule
13-
*/
12+
#[CoversClass(HeaderRule::class)]
1413
final class HeaderRuleTest extends TestCase
1514
{
1615
private HeaderRule $rule;

test/Model/Server/QueryRuleTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
declare(strict_types=1);
44

5-
5+
use PHPUnit\Framework\Attributes\CoversClass;
66
use PHPUnit\Framework\TestCase;
77
use SimpleAsFuck\ApiToolkit\Model\Server\QueryRule;
8-
use SimpleAsFuck\Validator\Factory\UnexpectedValueException as UnexpectedValueException;
9-
use SimpleAsFuck\Validator\Model\Validated as Validated;
8+
use SimpleAsFuck\Validator\Factory\UnexpectedValueException;
9+
use SimpleAsFuck\Validator\Model\Validated;
1010

11-
/**
12-
* @covers \SimpleAsFuck\ApiToolkit\Model\Server\QueryRule
13-
*/
11+
#[CoversClass(QueryRule::class)]
1412
final class QueryRuleTest extends TestCase
1513
{
1614
private QueryRule $rule;

test/Service/Client/DeprecationsLoggerTest.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,23 @@
33
declare(strict_types=1);
44

55
use GuzzleHttp\Psr7\Response;
6+
use PHPUnit\Framework\Attributes\CoversClass;
7+
use PHPUnit\Framework\Attributes\DataProvider;
68
use PHPUnit\Framework\TestCase;
79
use Psr\Http\Message\ResponseInterface;
810
use Psr\Log\LoggerInterface;
911
use SimpleAsFuck\ApiToolkit\Model\Client\Request;
1012
use SimpleAsFuck\ApiToolkit\Service\Client\Config;
1113
use SimpleAsFuck\ApiToolkit\Service\Client\DeprecationsLogger;
1214

13-
/**
14-
* @covers \SimpleAsFuck\ApiToolkit\Service\Client\DeprecationsLogger
15-
*/
15+
#[CoversClass(DeprecationsLogger::class)]
1616
final class DeprecationsLoggerTest extends TestCase
1717
{
1818
/**
19-
* @dataProvider dataProviderLogDeprecation
20-
*
2119
* @param non-empty-string|null $expectedLogMessage
2220
* @param array<non-empty-string, string> $expectedContext
2321
*/
22+
#[DataProvider('dataProviderLogDeprecation')]
2423
public function testLogDeprecation(?string $expectedLogMessage, array $expectedContext, ResponseInterface $response): void
2524
{
2625
$psrLogger = $this->createMock(LoggerInterface::class);

test/Service/Server/ExceptionTransformerTest.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,15 @@
22

33
declare(strict_types=1);
44

5+
use PHPUnit\Framework\Attributes\CoversClass;
6+
use PHPUnit\Framework\Attributes\DataProvider;
57
use PHPUnit\Framework\TestCase;
68
use SimpleAsFuck\ApiToolkit\Service\Server\ExceptionTransformer;
79

8-
/**
9-
* @covers \SimpleAsFuck\ApiToolkit\Service\Server\ExceptionTransformer
10-
*/
10+
#[CoversClass(ExceptionTransformer::class)]
1111
final class ExceptionTransformerTest extends TestCase
1212
{
13-
/**
14-
* @dataProvider dataProviderToApi
15-
*/
13+
#[DataProvider('dataProviderToApi')]
1614
public function testToApi(string $expectedMessage, bool $debug): void
1715
{
1816
$config = $this->createMock(SimpleAsFuck\ApiToolkit\Service\Config\Repository::class);

test/Service/Webhook/LaravelMysqlRepositoryTest.php

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
use Illuminate\Database\ConnectionResolver;
77
use Illuminate\Database\MySqlConnection;
88
use Illuminate\Support\Facades\DB;
9+
use PHPUnit\Framework\Attributes\CoversClass;
10+
use PHPUnit\Framework\Attributes\DataProvider;
911
use PHPUnit\Framework\TestCase;
1012
use SimpleAsFuck\ApiToolkit\Model\Webhook\Params;
1113
use SimpleAsFuck\ApiToolkit\Model\Webhook\Priority;
1214
use SimpleAsFuck\ApiToolkit\Model\Webhook\Webhook;
1315
use SimpleAsFuck\ApiToolkit\Service\Webhook\LaravelMysqlRepository;
1416

15-
/**
16-
* @covers \SimpleAsFuck\ApiToolkit\Service\Webhook\LaravelMysqlRepository
17-
*/
17+
#[CoversClass(LaravelMysqlRepository::class)]
1818
final class LaravelMysqlRepositoryTest extends TestCase
1919
{
2020
private static ConnectionResolver $connectionResolver;
@@ -61,12 +61,11 @@ public static function tearDownAfterClass(): void
6161
}
6262

6363
/**
64-
* @dataProvider dataProviderLoadForDispatching
65-
*
6664
* @param array<non-empty-string> $expectedUrls
6765
* @param non-empty-string $type
6866
* @param array<non-empty-string, non-empty-string> $attributes
6967
*/
68+
#[DataProvider('dataProviderLoadForDispatching')]
7069
public function testLoadForDispatching(array $expectedUrls, string $type, array $attributes): void
7170
{
7271
$repository = new LaravelMysqlRepository(
@@ -159,10 +158,9 @@ public static function dataProviderLoadForDispatching(): array
159158
}
160159

161160
/**
162-
* @dataProvider dataProviderSaveAndDelete
163-
*
164161
* @param non-empty-string $type
165162
*/
163+
#[DataProvider('dataProviderSaveAndDelete')]
166164
public function testSave(string $type, Params $params): void
167165
{
168166
$repository = new LaravelMysqlRepository(
@@ -208,10 +206,9 @@ public function testSave(string $type, Params $params): void
208206
}
209207

210208
/**
211-
* @dataProvider dataProviderSaveAndDelete
212-
*
213209
* @param non-empty-string $type
214210
*/
211+
#[DataProvider('dataProviderSaveAndDelete')]
215212
public function testDelete(string $type, Params $params): void
216213
{
217214
$connection = self::$connectionResolver->connection('default');

0 commit comments

Comments
 (0)