3 declare(strict_types
=1);
5 namespace Shaarli\Front\Controller\Admin
;
9 use Slim\Http\Response
;
11 class ToolsControllerTest
extends TestCase
13 use FrontAdminControllerMockHelper
;
15 /** @var ToolsController */
16 protected $controller;
18 public function setUp(): void
20 $this->createContainer();
22 $this->controller
= new ToolsController($this->container
);
25 public function testDefaultInvokeWithHttps(): void
27 $request = $this->createMock(Request
::class);
28 $response = new Response();
30 $this->container
->environment
= [
31 'SERVER_NAME' => 'shaarli',
36 // Save RainTPL assigned variables
37 $assignedVariables = [];
38 $this->assignTemplateVars($assignedVariables);
40 $result = $this->controller
->index($request, $response);
42 static::assertSame(200, $result->getStatusCode());
43 static::assertSame('tools', (string) $result->getBody());
44 static::assertSame('https://shaarli/', $assignedVariables['pageabsaddr']);
45 static::assertTrue($assignedVariables['sslenabled']);
48 public function testDefaultInvokeWithoutHttps(): void
50 $request = $this->createMock(Request
::class);
51 $response = new Response();
53 $this->container
->environment
= [
54 'SERVER_NAME' => 'shaarli',
58 // Save RainTPL assigned variables
59 $assignedVariables = [];
60 $this->assignTemplateVars($assignedVariables);
62 $result = $this->controller
->index($request, $response);
64 static::assertSame(200, $result->getStatusCode());
65 static::assertSame('tools', (string) $result->getBody());
66 static::assertSame('http://shaarli/', $assignedVariables['pageabsaddr']);
67 static::assertFalse($assignedVariables['sslenabled']);