]>
Commit | Line | Data |
---|---|---|
5ec4708c A |
1 | <?php |
2 | ||
3 | declare(strict_types=1); | |
4 | ||
2899ebb5 | 5 | namespace Shaarli\Front\Controller\Visitor; |
5ec4708c A |
6 | |
7 | use PHPUnit\Framework\TestCase; | |
5ec4708c A |
8 | use Slim\Http\Request; |
9 | use Slim\Http\Response; | |
10 | ||
11 | class 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 | { | |
5ec4708c A |
27 | $request = $this->createMock(Request::class); |
28 | $response = new Response(); | |
29 | ||
30 | // Save RainTPL assigned variables | |
31 | $assignedVariables = []; | |
32 | $this->assignTemplateVars($assignedVariables); | |
33 | ||
34 | $result = $this->controller->index($request, $response); | |
35 | ||
36 | static::assertSame(200, $result->getStatusCode()); | |
dd09ec52 A |
37 | static::assertStringContainsString( |
38 | 'application/opensearchdescription+xml', | |
39 | $result->getHeader('Content-Type')[0] | |
40 | ); | |
5ec4708c A |
41 | static::assertSame('opensearch', (string) $result->getBody()); |
42 | static::assertSame('http://shaarli', $assignedVariables['serverurl']); | |
43 | } | |
5ec4708c | 44 | } |