-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathBouncesControllerTest.php
More file actions
47 lines (38 loc) · 1.82 KB
/
Copy pathBouncesControllerTest.php
File metadata and controls
47 lines (38 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace PhpList\WebFrontend\Tests\Integration\Controller;
use PhpList\WebFrontend\Controller\BouncesController;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
use Symfony\Component\Routing\RouterInterface;
class BouncesControllerTest extends KernelTestCase
{
public function testBouncesRouteIsRegistered(): void
{
self::bootKernel();
/** @var RouterInterface $router */
$router = static::getContainer()->get('router');
self::assertSame('/bounces/', $router->generate('bounce_list'));
}
public function testBouncesPageRendersExpectedSpaPayload(): void
{
self::bootKernel();
/** @var BouncesController $controller */
$controller = static::getContainer()->get(BouncesController::class);
$apiBaseUrl = (string) static::getContainer()->getParameter('app.api_base_url');
$request = Request::create('/bounces/');
$session = new Session(new MockArraySessionStorage());
$session->set('auth_token', 'integration-token');
$request->setSession($session);
static::getContainer()->get(RequestStack::class)->push($request);
$response = $controller->index($request);
$content = (string) $response->getContent();
self::assertSame(200, $response->getStatusCode());
self::assertStringContainsString('<title>phpList - Bounces</title>', $content);
self::assertStringContainsString('data-api-token="integration-token"', $content);
self::assertStringContainsString(sprintf('data-api-base-url="%s"', $apiBaseUrl), $content);
}
}