]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - tests/front/controller/visitor/OpenSearchControllerTest.php
Initialize admin Slim controllers
[github/shaarli/Shaarli.git] / tests / front / controller / visitor / OpenSearchControllerTest.php
CommitLineData
5ec4708c
A
1<?php
2
3declare(strict_types=1);
4
2899ebb5 5namespace Shaarli\Front\Controller\Visitor;
5ec4708c
A
6
7use PHPUnit\Framework\TestCase;
5ec4708c
A
8use Slim\Http\Request;
9use Slim\Http\Response;
10
11class OpenSearchControllerTest extends TestCase
12{
dd09ec52 13 use FrontControllerMockHelper;
5ec4708c
A
14
15 /** @var OpenSearchController */
16 protected $controller;
17
18 public function setUp(): void
19 {
dd09ec52
A
20 $this->createContainer();
21
5ec4708c
A
22 $this->controller = new OpenSearchController($this->container);
23 }
24
25 public function testOpenSearchController(): void
26 {
27 $this->createValidContainerMockSet();
28
29 $request = $this->createMock(Request::class);
30 $response = new Response();
31
32 // Save RainTPL assigned variables
33 $assignedVariables = [];
34 $this->assignTemplateVars($assignedVariables);
35
36 $result = $this->controller->index($request, $response);
37
38 static::assertSame(200, $result->getStatusCode());
dd09ec52
A
39 static::assertStringContainsString(
40 'application/opensearchdescription+xml',
41 $result->getHeader('Content-Type')[0]
42 );
5ec4708c
A
43 static::assertSame('opensearch', (string) $result->getBody());
44 static::assertSame('http://shaarli', $assignedVariables['serverurl']);
45 }
5ec4708c 46}