Skip to content

Commit

Permalink
Update dependency fdekker/log-viewer-bundle to v2 (#957)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
renovate[bot] and frankdekker authored Jan 31, 2025
1 parent 446942a commit c4de583
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 96 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"doctrine/doctrine-migrations-bundle": "^3.3",
"doctrine/orm": "^3.1",
"fdekker/commonmark-ext-emoji": "^1.1",
"fdekker/log-viewer-bundle": "^1.0",
"fdekker/log-viewer-bundle": "^1.0 || ^2.0",
"league/commonmark": "^2.4",
"league/oauth2-client": "^2.7",
"league/uri": "^7.0",
Expand Down
159 changes: 80 additions & 79 deletions composer.lock

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion tests/AbstractFunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
use Exception;
use Liip\TestFixturesBundle\Services\DatabaseToolCollection;
use Liip\TestFixturesBundle\Services\DatabaseTools\AbstractDatabaseTool;
use Nette\Utils\Json;
use Nette\Utils\JsonException;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Response;

abstract class AbstractFunctionalTestCase extends WebTestCase
{
Expand Down Expand Up @@ -54,7 +57,6 @@ protected function tearDown(): void

/**
* @template T of object
*
* @param class-string<T> $serviceId
*
* @return T
Expand All @@ -68,6 +70,20 @@ protected static function getService(string $serviceId, ?string $alias = null):
return $service;
}

protected function getResponseContent(): string
{
return Assert::notFalse(Assert::isInstanceOf($this->client->getResponse(), Response::class)->getContent());
}

/**
* @return array<array-key, mixed>
* @throws JsonException
*/
protected function getResponseArray(): array
{
return Assert::isArray(Json::decode($this->getResponseContent(), true));
}

/**
* @return class-string[]
*/
Expand Down
3 changes: 1 addition & 2 deletions tests/Functional/Controller/Api/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use DR\Review\Tests\DataFixtures\UserAccessTokenFixtures;
use DR\Utils\Assert;
use Exception;
use Nette\Utils\Json;
use PHPUnit\Framework\Attributes\CoversNothing;
use Symfony\Component\HttpFoundation\Response;

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use DR\Review\Tests\DataFixtures\UserFixtures;
use DR\Utils\Assert;
use Exception;
use Nette\Utils\Json;
use PHPUnit\Framework\Attributes\CoversNothing;

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

$data = Json::decode(Assert::notFalse($this->client->getResponse()->getContent()), true);
$data = $this->getResponseArray();
static::assertIsArray($data);
static::assertCount(1, $data);
static::assertSame('title', $data[0]['title']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use DR\Review\Tests\DataFixtures\CodeReviewActivityFixtures;
use DR\Utils\Assert;
use Exception;
use Nette\Utils\Json;
use PHPUnit\Framework\Attributes\CoversNothing;

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

$data = Json::decode(Assert::notFalse($this->client->getResponse()->getContent()), true);
$data = $this->getResponseArray();
static::assertIsArray($data);
static::assertCount(1, $data);
static::assertSame('event', $data[0]['eventName']);
Expand Down
6 changes: 2 additions & 4 deletions tests/Functional/Controller/Api/DocControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
namespace DR\Review\Tests\Functional\Controller\Api;

use DR\Review\Tests\AbstractFunctionalTestCase;
use DR\Utils\Assert;
use Nette\Utils\Json;
use Nette\Utils\JsonException;
use PHPUnit\Framework\Attributes\CoversNothing;

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

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

$data = Json::decode(Assert::notFalse($this->client->getResponse()->getContent()), true);
$data = $this->getResponseArray();
static::assertIsArray($data);
static::assertArrayHasKey('openapi', $data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use DR\Review\Tests\DataFixtures\UserFixtures;
use DR\Utils\Assert;
use Exception;
use Nette\Utils\Json;
use PHPUnit\Framework\Attributes\CoversNothing;

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

$data = Json::decode(Assert::notFalse($this->client->getResponse()->getContent()), true);
static::assertIsArray($data);
$data = $this->getResponseArray();
static::assertCount(1, $data);
static::assertSame('repository', $data[0]['name']);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use DR\Review\Tests\DataFixtures\UserFixtures;
use DR\Utils\Assert;
use Exception;
use Nette\Utils\Json;
use PHPUnit\Framework\Attributes\CoversNothing;

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

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

Expand Down
1 change: 1 addition & 0 deletions tests/Functional/Webhook/GitlabWebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function testWebhook(): void
self::assertResponseIsSuccessful();

$response = $this->client->getResponse();
static::assertInstanceOf(Response::class, $response);
static::assertSame(Response::HTTP_ACCEPTED, $response->getStatusCode());
}

Expand Down

0 comments on commit c4de583

Please sign in to comment.