Commit 704dc729 by Lech Sawon

e2e test example

parent 3d55dc4e
......@@ -27,10 +27,10 @@ final class ApiExceptionSubscriber implements EventSubscriberInterface
public static function getSubscribedEvents()
{
return [
KernelEvents::EXCEPTION => [
['logException', 50],
['processException', 10],
]
// KernelEvents::EXCEPTION => [
// ['logException', 50],
// ['processException', 10],
// ]
];
}
......
......@@ -8,7 +8,7 @@ use App\Service\Reservation\AddReservation;
use PHPUnit\Framework\TestCase;
//uproszczony przykład testu jednstkowego
//uproszczony przykład testu jednostkowego
final class AddReservationTest extends TestCase
{
public function testTest(): void
......
<?php
declare(strict_types=1);
namespace App\Tests\E2E;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
//Example E2E test with negative scenario invalid token
final class ApiGetRoomTest extends WebTestCase
{
private KernelBrowser $client;
public function testInvalidToken()
{
$this->client = self::createClient([]);
$this->client->request(
'GET',
'/api/room/9', // mozna to URI wygenerować przy pomocy Symfony router,
[],
[],
[
'HTTP_AUTHORIZATION' => 'Bearer some_token',
]
);
$response = $this->client->getResponse();
$content = $response->getContent();
$expectedContent = '{"code":401,"message":"Invalid JWT Token"}';
self::assertEquals($content, $expectedContent);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment