-
-
Headings
-
H4
-
H5
-
H6
+
+
Headings small
+ H4 small
+ H5 small
+ H6 small
+
+
Lists
+
+ This page should be used when creating and testing new designs to find usability and/or design issues.
+ {{ lipsum|replace({'…': '.'}) }}
+
+
+ - Unordered
+ - List
+ - Items
+
+
+ - Ordered
+ - List
+ - Items
+
+
{{ linksum|raw }} {{ lipsum }}
+
+
+
+
diff --git a/src/Controllers/DesignController.php b/src/Controllers/DesignController.php
index 55c064f8..89bced59 100644
--- a/src/Controllers/DesignController.php
+++ b/src/Controllers/DesignController.php
@@ -2,6 +2,8 @@
namespace Engelsystem\Controllers;
+use Engelsystem\Config\Config;
+use Engelsystem\Http\Request;
use Engelsystem\Http\Response;
use Engelsystem\Models\User\State;
use Engelsystem\Models\User\User;
@@ -11,23 +13,30 @@ class DesignController extends BaseController
/** @var Response */
protected $response;
+ /** @var Config */
+ protected $config;
+
/**
* @param Response $response
+ * @param Config $config
*/
- public function __construct(Response $response)
+ public function __construct(Response $response, Config $config)
{
+ $this->config = $config;
$this->response = $response;
}
/**
* Show the design overview page
*
+ * @param Request $request
+ *
* @return Response
*/
- public function index()
+ public function index(Request $request)
{
$demoUser = (new User())->forceFill([
- 'id' => 42,
+ 'id' => 42,
'name' => 'test',
]);
$demoUser->__set('state', (new State())->forceFill([
@@ -35,7 +44,7 @@ class DesignController extends BaseController
'arrived' => true,
]));
$demoUser2 = (new User())->forceFill([
- 'id' => 1337,
+ 'id' => 1337,
'name' => 'test2',
]);
$demoUser2->__set('state', (new State())->forceFill([
@@ -43,12 +52,22 @@ class DesignController extends BaseController
'arrived' => false,
]));
+ $themes = $this->config->get('available_themes');
+
+ $data = [
+ 'demo_user' => $demoUser,
+ 'demo_user_2' => $demoUser2,
+ 'themes' => $themes,
+ ];
+
+ $theme = $request->get('theme');
+ if (isset($themes[$theme])) {
+ $data['theme'] = $theme;
+ }
+
return $this->response->withView(
'pages/design',
- [
- 'demo_user' => $demoUser,
- 'demo_user_2' => $demoUser2,
- ]
+ $data
);
}
}
diff --git a/tests/Unit/Controllers/DesignControllerTest.php b/tests/Unit/Controllers/DesignControllerTest.php
index f1b26d07..4f93eed6 100644
--- a/tests/Unit/Controllers/DesignControllerTest.php
+++ b/tests/Unit/Controllers/DesignControllerTest.php
@@ -2,7 +2,9 @@
namespace Engelsystem\Test\Unit\Controllers;
+use Engelsystem\Config\Config;
use Engelsystem\Controllers\DesignController;
+use Engelsystem\Http\Request;
use Engelsystem\Http\Response;
use Engelsystem\Test\Unit\TestCase;
use PHPUnit\Framework\MockObject\MockObject;
@@ -21,10 +23,35 @@ class DesignControllerTest extends TestCase
->method('withView')
->with('pages/design')
->willReturn($response);
+ $request = new Request(['theme' => 42]);
+ $config = new Config();
- $controller = new DesignController($response);
- $return = $controller->index();
+ $controller = new DesignController($response, $config);
+ $return = $controller->index($request);
$this->assertEquals($response, $return);
}
+
+ /**
+ * @covers \Engelsystem\Controllers\DesignController::index
+ */
+ public function testIndexSetTheme()
+ {
+ /** @var Response|MockObject $response */
+ $response = $this->createMock(Response::class);
+ $response->expects($this->once())
+ ->method('withView')
+ ->willReturnCallback(function (string $view, array $data) use ($response) {
+ $this->assertTrue(isset($data['theme']));
+ $this->assertEquals('42', $data['theme']);
+
+ return $response;
+ });
+ $request = new Request();
+ $request->attributes->set('theme', '42');
+ $config = new Config(['available_themes' => ['42' => 'Meaning of Live']]);
+
+ $controller = new DesignController($response, $config);
+ $controller->index($request);
+ }
}