2019-06-14 04:05:38 +02:00
|
|
|
<?php
|
|
|
|
|
2023-02-03 20:41:59 +01:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-06-14 04:05:38 +02:00
|
|
|
namespace Engelsystem\Test\Unit\Controllers;
|
|
|
|
|
|
|
|
use Engelsystem\Config\Config;
|
|
|
|
use Engelsystem\Controllers\HomeController;
|
|
|
|
use Engelsystem\Helpers\Authenticator;
|
2020-05-10 15:55:44 +02:00
|
|
|
use Engelsystem\Http\Redirector;
|
|
|
|
use Engelsystem\Http\Response;
|
2022-11-06 12:41:52 +01:00
|
|
|
use Engelsystem\Models\User\User;
|
2019-06-14 04:05:38 +02:00
|
|
|
use Engelsystem\Test\Unit\TestCase;
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
|
|
|
|
|
|
class HomeControllerTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Controllers\HomeController::__construct
|
|
|
|
* @covers \Engelsystem\Controllers\HomeController::index
|
|
|
|
*/
|
2022-12-14 19:15:20 +01:00
|
|
|
public function testIndex(): void
|
2019-06-14 04:05:38 +02:00
|
|
|
{
|
|
|
|
$config = new Config(['home_site' => '/foo']);
|
|
|
|
/** @var Authenticator|MockObject $auth */
|
|
|
|
$auth = $this->createMock(Authenticator::class);
|
2022-11-06 12:41:52 +01:00
|
|
|
$this->setExpects($auth, 'user', null, new User());
|
2020-05-10 15:55:44 +02:00
|
|
|
/** @var Redirector|MockObject $redirect */
|
|
|
|
$redirect = $this->createMock(Redirector::class);
|
|
|
|
$this->setExpects($redirect, 'to', ['/foo'], new Response());
|
2019-06-14 04:05:38 +02:00
|
|
|
|
2020-05-10 15:55:44 +02:00
|
|
|
$controller = new HomeController($auth, $config, $redirect);
|
2019-06-14 04:05:38 +02:00
|
|
|
$controller->index();
|
|
|
|
}
|
|
|
|
}
|