2020-04-24 18:08:09 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Controllers;
|
|
|
|
|
2021-04-10 17:02:34 +02:00
|
|
|
use Engelsystem\Config\Config;
|
2020-04-24 18:08:09 +02:00
|
|
|
use Engelsystem\Controllers\DesignController;
|
|
|
|
use Engelsystem\Http\Response;
|
|
|
|
use Engelsystem\Test\Unit\TestCase;
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
|
|
|
|
|
|
class DesignControllerTest extends TestCase
|
|
|
|
{
|
2022-06-07 22:59:49 +02:00
|
|
|
protected function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
$this->mockRenderer();
|
|
|
|
$this->mockTranslator();
|
|
|
|
}
|
|
|
|
|
2020-04-24 18:08:09 +02:00
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Controllers\DesignController::__construct
|
|
|
|
* @covers \Engelsystem\Controllers\DesignController::index
|
|
|
|
*/
|
|
|
|
public function testIndex()
|
|
|
|
{
|
|
|
|
/** @var Response|MockObject $response */
|
|
|
|
$response = $this->createMock(Response::class);
|
|
|
|
$response->expects($this->once())
|
|
|
|
->method('withView')
|
|
|
|
->with('pages/design')
|
2021-07-24 12:35:29 +02:00
|
|
|
->willReturnCallback(function (string $view, array $data) use ($response) {
|
|
|
|
$this->assertTrue(isset($data['demo_user']));
|
|
|
|
$this->assertTrue(isset($data['demo_user_2']));
|
|
|
|
$this->assertIsArray($data['themes']);
|
2021-04-10 17:02:34 +02:00
|
|
|
|
|
|
|
return $response;
|
|
|
|
});
|
2021-07-24 12:35:29 +02:00
|
|
|
$config = new Config(['themes' => [42 => ['name' => 'Foo']]]);
|
2021-04-10 17:02:34 +02:00
|
|
|
|
|
|
|
$controller = new DesignController($response, $config);
|
2021-07-24 12:35:29 +02:00
|
|
|
$return = $controller->index();
|
|
|
|
|
|
|
|
$this->assertEquals($response, $return);
|
2021-04-10 17:02:34 +02:00
|
|
|
}
|
2020-04-24 18:08:09 +02:00
|
|
|
}
|