Skip to content
Permalink
Browse files

tests: clean up all `E2E/Controller` tests.

  • Loading branch information...
tarlepp committed May 5, 2019
1 parent 466e914 commit f98f643e961dbb46cb45dfa1e788a7121d9bf4d7
@@ -9,6 +9,7 @@
use App\Utils\Tests\WebTestCase;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
/**
* Class ApiKeyControllerTest
@@ -21,7 +22,7 @@ class ApiKeyControllerTest extends WebTestCase
private $baseUrl = '/api_key';
/**
* @throws \Exception
* @throws Throwable
*/
public function testThatGetBaseRouteReturn401(): void
{
@@ -33,7 +34,7 @@ public function testThatGetBaseRouteReturn401(): void
static::assertInstanceOf(Response::class, $response);
/** @noinspection NullPointerExceptionInspection */
static::assertSame(401, $response->getStatusCode());
static::assertSame(401, $response->getStatusCode(), "Response:\n" . $response);
unset($response, $client);
}
@@ -45,7 +46,7 @@ public function testThatGetBaseRouteReturn401(): void
* @param string $password
* @param int $expectedStatus
*
* @throws \Exception
* @throws Throwable
*/
public function testThatFindActionWorksAsExpected(string $username, string $password, int $expectedStatus): void
{
@@ -57,7 +58,7 @@ public function testThatFindActionWorksAsExpected(string $username, string $pass
static::assertInstanceOf(Response::class, $response);
/** @noinspection NullPointerExceptionInspection */
static::assertSame($expectedStatus, $response->getStatusCode(), $response->getContent());
static::assertSame($expectedStatus, $response->getStatusCode(), "Response:\n" . $response);
unset($response, $client);
}
@@ -68,12 +69,10 @@ public function testThatFindActionWorksAsExpected(string $username, string $pass
public function dataProviderTestThatFindActionWorksAsExpected(): array
{
return [
/*
['john', 'password', 403],
['john-api', 'password-api', 403],
['john-logged', 'password-logged', 403],
['john-user', 'password-user', 403],
*/
['john-admin', 'password-admin', 403],
['john-root', 'password-root', 200],
];
@@ -10,6 +10,8 @@
use App\Resource\LogRequestResource;
use App\Utils\JSON;
use App\Utils\Tests\WebTestCase;
use Throwable;
use function file_get_contents;
/**
* Class DefaultControllerTest
@@ -20,7 +22,7 @@
class DefaultControllerTest extends WebTestCase
{
/**
* @throws \Exception
* @throws Throwable
*/
public function testThatDefaultRouteReturns200(): void
{
@@ -30,13 +32,13 @@ public function testThatDefaultRouteReturns200(): void
$response = $client->getResponse();
/** @noinspection NullPointerExceptionInspection */
static::assertSame(200, $response->getStatusCode());
static::assertSame(200, $response->getStatusCode(), "Response:\n" . $response);
unset($response, $client);
}
/**
* @throws \Exception
* @throws Throwable
*/
public function testThatHealthzRouteReturns200(): void
{
@@ -46,14 +48,13 @@ public function testThatHealthzRouteReturns200(): void
$response = $client->getResponse();
/** @noinspection NullPointerExceptionInspection */
static::assertSame(200, $response->getStatusCode());
static::assertSame(200, $response->getStatusCode(), "Response:\n" . $response);
unset($response, $client);
}
/**
* @throws \Doctrine\ORM\NonUniqueResultException
* @throws \Exception
* @throws Throwable
*/
public function testThatHealthzRouteDoesNotMakeRequestLog(): void
{
@@ -73,7 +74,7 @@ public function testThatHealthzRouteDoesNotMakeRequestLog(): void
}
/**
* @throws \Exception
* @throws Throwable
*/
public function testThatVersionRouteReturns200(): void
{
@@ -83,14 +84,13 @@ public function testThatVersionRouteReturns200(): void
$response = $client->getResponse();
/** @noinspection NullPointerExceptionInspection */
static::assertSame(200, $response->getStatusCode());
static::assertSame(200, $response->getStatusCode(), "Response:\n" . $response);
unset($response, $client);
}
/**
* @throws \Doctrine\ORM\NonUniqueResultException
* @throws \Exception
* @throws Throwable
*/
public function testThatVersionRouteDoesNotMakeRequestLog(): void
{
@@ -110,7 +110,7 @@ public function testThatVersionRouteDoesNotMakeRequestLog(): void
}
/**
* @throws \Exception
* @throws Throwable
*/
public function testThatApiVersionIsAddedToResponseHeaders(): void
{
@@ -123,7 +123,7 @@ public function testThatApiVersionIsAddedToResponseHeaders(): void
$version = $response->headers->get('X-API-VERSION');
static::assertNotNull($version);
static::assertSame(JSON::decode(\file_get_contents(__DIR__ . '/../../../composer.json'))->version, $version);
static::assertSame(JSON::decode(file_get_contents(__DIR__ . '/../../../composer.json'))->version, $version);
unset($response, $client);
}

0 comments on commit f98f643

Please sign in to comment.
You can’t perform that action at this time.