diff options
Diffstat (limited to 'tests/front/controller/visitor/OpenSearchControllerTest.php')
-rw-r--r-- | tests/front/controller/visitor/OpenSearchControllerTest.php | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/front/controller/visitor/OpenSearchControllerTest.php b/tests/front/controller/visitor/OpenSearchControllerTest.php new file mode 100644 index 00000000..52475318 --- /dev/null +++ b/tests/front/controller/visitor/OpenSearchControllerTest.php | |||
@@ -0,0 +1,46 @@ | |||
1 | <?php | ||
2 | |||
3 | declare(strict_types=1); | ||
4 | |||
5 | namespace Shaarli\Front\Controller\Visitor; | ||
6 | |||
7 | use PHPUnit\Framework\TestCase; | ||
8 | use Slim\Http\Request; | ||
9 | use Slim\Http\Response; | ||
10 | |||
11 | class OpenSearchControllerTest extends TestCase | ||
12 | { | ||
13 | use FrontControllerMockHelper; | ||
14 | |||
15 | /** @var OpenSearchController */ | ||
16 | protected $controller; | ||
17 | |||
18 | public function setUp(): void | ||
19 | { | ||
20 | $this->createContainer(); | ||
21 | |||
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()); | ||
39 | static::assertStringContainsString( | ||
40 | 'application/opensearchdescription+xml', | ||
41 | $result->getHeader('Content-Type')[0] | ||
42 | ); | ||
43 | static::assertSame('opensearch', (string) $result->getBody()); | ||
44 | static::assertSame('http://shaarli', $assignedVariables['serverurl']); | ||
45 | } | ||
46 | } | ||