Skip to content

Commit c4de583

Browse files
Update dependency fdekker/log-viewer-bundle to v2 (#957)
* Update dependency fdekker/log-viewer-bundle to v2 * Fix phpstan issues --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Frank Dekker <[email protected]>
1 parent 446942a commit c4de583

File tree

10 files changed

+106
-96
lines changed

10 files changed

+106
-96
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"doctrine/doctrine-migrations-bundle": "^3.3",
4848
"doctrine/orm": "^3.1",
4949
"fdekker/commonmark-ext-emoji": "^1.1",
50-
"fdekker/log-viewer-bundle": "^1.0",
50+
"fdekker/log-viewer-bundle": "^1.0 || ^2.0",
5151
"league/commonmark": "^2.4",
5252
"league/oauth2-client": "^2.7",
5353
"league/uri": "^7.0",

composer.lock

Lines changed: 80 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/AbstractFunctionalTestCase.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
use Exception;
1212
use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
1313
use Liip\TestFixturesBundle\Services\DatabaseTools\AbstractDatabaseTool;
14+
use Nette\Utils\Json;
15+
use Nette\Utils\JsonException;
1416
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
1517
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
18+
use Symfony\Component\HttpFoundation\Response;
1619

1720
abstract class AbstractFunctionalTestCase extends WebTestCase
1821
{
@@ -54,7 +57,6 @@ protected function tearDown(): void
5457

5558
/**
5659
* @template T of object
57-
*
5860
* @param class-string<T> $serviceId
5961
*
6062
* @return T
@@ -68,6 +70,20 @@ protected static function getService(string $serviceId, ?string $alias = null):
6870
return $service;
6971
}
7072

73+
protected function getResponseContent(): string
74+
{
75+
return Assert::notFalse(Assert::isInstanceOf($this->client->getResponse(), Response::class)->getContent());
76+
}
77+
78+
/**
79+
* @return array<array-key, mixed>
80+
* @throws JsonException
81+
*/
82+
protected function getResponseArray(): array
83+
{
84+
return Assert::isArray(Json::decode($this->getResponseContent(), true));
85+
}
86+
7187
/**
7288
* @return class-string[]
7389
*/

tests/Functional/Controller/Api/AuthenticationTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use DR\Review\Tests\DataFixtures\UserAccessTokenFixtures;
1010
use DR\Utils\Assert;
1111
use Exception;
12-
use Nette\Utils\Json;
1312
use PHPUnit\Framework\Attributes\CoversNothing;
1413
use Symfony\Component\HttpFoundation\Response;
1514

@@ -27,7 +26,7 @@ public function testAuthenticatedSuccess(): void
2726
$this->client->request('GET', '/api/users/me', server: ['HTTP_AUTHORIZATION' => 'Bearer ' . $token->getToken()]);
2827
self::assertResponseIsSuccessful();
2928

30-
$data = Json::decode(Assert::notFalse($this->client->getResponse()->getContent()), true);
29+
$data = $this->getResponseArray();
3130
static::assertSame(['id' => $user->getId(), 'name' => $user->getName(), 'email' => $user->getEmail()], $data);
3231
}
3332

tests/Functional/Controller/Api/CodeReview/GetCollectionControllerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use DR\Review\Tests\DataFixtures\UserFixtures;
1010
use DR\Utils\Assert;
1111
use Exception;
12-
use Nette\Utils\Json;
1312
use PHPUnit\Framework\Attributes\CoversNothing;
1413

1514
#[CoversNothing]
@@ -26,7 +25,7 @@ public function testGet(): void
2625
$this->client->request('GET', '/api/code-reviews');
2726
self::assertResponseIsSuccessful();
2827

29-
$data = Json::decode(Assert::notFalse($this->client->getResponse()->getContent()), true);
28+
$data = $this->getResponseArray();
3029
static::assertIsArray($data);
3130
static::assertCount(1, $data);
3231
static::assertSame('title', $data[0]['title']);

tests/Functional/Controller/Api/CodeReviewActivity/GetCollectionControllerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use DR\Review\Tests\DataFixtures\CodeReviewActivityFixtures;
99
use DR\Utils\Assert;
1010
use Exception;
11-
use Nette\Utils\Json;
1211
use PHPUnit\Framework\Attributes\CoversNothing;
1312

1413
#[CoversNothing]
@@ -25,7 +24,7 @@ public function testGet(): void
2524
$this->client->request('GET', '/api/code-review-activities');
2625
self::assertResponseIsSuccessful();
2726

28-
$data = Json::decode(Assert::notFalse($this->client->getResponse()->getContent()), true);
27+
$data = $this->getResponseArray();
2928
static::assertIsArray($data);
3029
static::assertCount(1, $data);
3130
static::assertSame('event', $data[0]['eventName']);

tests/Functional/Controller/Api/DocControllerTest.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
namespace DR\Review\Tests\Functional\Controller\Api;
55

66
use DR\Review\Tests\AbstractFunctionalTestCase;
7-
use DR\Utils\Assert;
8-
use Nette\Utils\Json;
97
use Nette\Utils\JsonException;
108
use PHPUnit\Framework\Attributes\CoversNothing;
119

@@ -17,7 +15,7 @@ public function testHtmlDocs(): void
1715
$this->client->request('GET', '/api/docs', server: ['HTTP_ACCEPT' => 'text/html']);
1816
self::assertResponseIsSuccessful();
1917

20-
$content = $this->client->getResponse()->getContent();
18+
$content = $this->getResponseContent();
2119
static::assertIsString($content);
2220
static::assertStringContainsString('swagger-ui', $content);
2321
}
@@ -30,7 +28,7 @@ public function testJsonDocs(): void
3028
$this->client->request('GET', '/api/docs', server: ['HTTP_ACCEPT' => 'application/vnd.openapi+json']);
3129
self::assertResponseIsSuccessful();
3230

33-
$data = Json::decode(Assert::notFalse($this->client->getResponse()->getContent()), true);
31+
$data = $this->getResponseArray();
3432
static::assertIsArray($data);
3533
static::assertArrayHasKey('openapi', $data);
3634
}

tests/Functional/Controller/Api/Repository/GetCollectionControllerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use DR\Review\Tests\DataFixtures\UserFixtures;
1010
use DR\Utils\Assert;
1111
use Exception;
12-
use Nette\Utils\Json;
1312
use PHPUnit\Framework\Attributes\CoversNothing;
1413

1514
#[CoversNothing]
@@ -26,8 +25,7 @@ public function testGet(): void
2625
$this->client->request('GET', '/api/repositories');
2726
self::assertResponseIsSuccessful();
2827

29-
$data = Json::decode(Assert::notFalse($this->client->getResponse()->getContent()), true);
30-
static::assertIsArray($data);
28+
$data = $this->getResponseArray();
3129
static::assertCount(1, $data);
3230
static::assertSame('repository', $data[0]['name']);
3331
}

tests/Functional/Controller/Api/User/UserMeControllerTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use DR\Review\Tests\DataFixtures\UserFixtures;
99
use DR\Utils\Assert;
1010
use Exception;
11-
use Nette\Utils\Json;
1211
use PHPUnit\Framework\Attributes\CoversNothing;
1312

1413
#[CoversNothing]
@@ -25,7 +24,7 @@ public function testGet(): void
2524
$this->client->request('GET', '/api/users/me');
2625
self::assertResponseIsSuccessful();
2726

28-
$data = Json::decode(Assert::notFalse($this->client->getResponse()->getContent()), true);
27+
$data = $this->getResponseArray();
2928
static::assertSame(['id' => $user->getId(), 'name' => 'Sherlock Holmes', 'email' => '[email protected]'], $data);
3029
}
3130

tests/Functional/Webhook/GitlabWebhookTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function testWebhook(): void
5050
self::assertResponseIsSuccessful();
5151

5252
$response = $this->client->getResponse();
53+
static::assertInstanceOf(Response::class, $response);
5354
static::assertSame(Response::HTTP_ACCEPTED, $response->getStatusCode());
5455
}
5556

0 commit comments

Comments
 (0)