2020-05-20 10:47:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2020-05-22 13:20:31 +02:00
|
|
|
namespace Shaarli\Front\Controller\Visitor;
|
2020-05-20 10:47:20 +02:00
|
|
|
|
2020-09-29 14:41:40 +02:00
|
|
|
use Shaarli\TestCase;
|
2020-05-20 10:47:20 +02:00
|
|
|
use Slim\Http\Request;
|
|
|
|
use Slim\Http\Response;
|
|
|
|
|
|
|
|
class OpenSearchControllerTest extends TestCase
|
|
|
|
{
|
2020-05-20 12:43:40 +02:00
|
|
|
use FrontControllerMockHelper;
|
2020-05-20 10:47:20 +02:00
|
|
|
|
|
|
|
/** @var OpenSearchController */
|
|
|
|
protected $controller;
|
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
2020-05-20 12:43:40 +02:00
|
|
|
$this->createContainer();
|
|
|
|
|
2020-05-20 10:47:20 +02:00
|
|
|
$this->controller = new OpenSearchController($this->container);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOpenSearchController(): void
|
|
|
|
{
|
|
|
|
$request = $this->createMock(Request::class);
|
|
|
|
$response = new Response();
|
|
|
|
|
|
|
|
// Save RainTPL assigned variables
|
|
|
|
$assignedVariables = [];
|
|
|
|
$this->assignTemplateVars($assignedVariables);
|
|
|
|
|
|
|
|
$result = $this->controller->index($request, $response);
|
|
|
|
|
|
|
|
static::assertSame(200, $result->getStatusCode());
|
2020-05-20 12:43:40 +02:00
|
|
|
static::assertStringContainsString(
|
|
|
|
'application/opensearchdescription+xml',
|
|
|
|
$result->getHeader('Content-Type')[0]
|
|
|
|
);
|
2020-05-20 10:47:20 +02:00
|
|
|
static::assertSame('opensearch', (string) $result->getBody());
|
2020-09-03 14:52:34 +02:00
|
|
|
static::assertSame('http://shaarli/subfolder/', $assignedVariables['serverurl']);
|
2020-05-20 10:47:20 +02:00
|
|
|
}
|
|
|
|
}
|