infinito/application/symfony/tests/Integration/Controller/RoutesGetStatusIntegrationTest.php

51 lines
1.2 KiB
PHP
Raw Normal View History

2018-11-22 23:00:01 +01:00
<?php
2019-01-05 16:41:21 +01:00
namespace Tests\Integration\Controller;
2018-11-22 23:00:01 +01:00
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpFoundation\Request;
2019-01-05 21:26:36 +01:00
/**
* @author kevinfrantz
*/
class RoutesGetStatusIntegrationTest extends KernelTestCase
2018-11-22 23:00:01 +01:00
{
2018-11-22 23:18:47 +01:00
const GET_URLS_STATUS = [
'login' => 200,
'imprint' => 200,
'register' => 301,
'logout' => 302,
2018-11-23 13:22:45 +01:00
'profile/edit' => 302,
2019-01-06 02:24:35 +01:00
'spa' => 302,
2018-11-22 23:18:47 +01:00
];
2019-02-12 18:04:36 +01:00
/**
* {@inheritdoc}
*
* @see \PHPUnit\Framework\TestCase::setUp()
*/
2018-11-22 23:00:01 +01:00
public function setUp(): void
{
self::bootKernel();
}
2018-11-22 23:18:47 +01:00
public function testParameterlesGetUrls(): void
2018-11-22 23:00:01 +01:00
{
2018-11-22 23:18:47 +01:00
foreach (self::GET_URLS_STATUS as $url => $status) {
$this->parameterlesGetRouteTest($url, $status);
2018-11-22 23:00:01 +01:00
}
}
2019-02-12 18:04:36 +01:00
/**
* @param string $url
* @param int $status
*/
2019-01-05 16:41:21 +01:00
private function parameterlesGetRouteTest(string $url, int $status): void
2018-11-22 23:00:01 +01:00
{
$request = new Request([], [], [], [], [], ['REQUEST_URI' => $url, null]);
$request->setMethod(Request::METHOD_GET);
$response = static::$kernel->handle($request);
2019-02-17 13:54:30 +01:00
$this->assertEquals($status, $response->getStatusCode(), "Url <<$url>> with status <<$status>> is not reachable.");
2018-11-22 23:00:01 +01:00
}
}