Add new settings and cache repository files, update admin settings controller and templates
- Introduced new `SettingsRepository` and `CacheRepository` classes in the `autoload\Domain` namespace. - Updated `SettingsController` in the `admin\Controllers` namespace to enhance settings management. - Added new templates for settings in `admin\templates\settings` and `admin\templates\site`. - Improved overall structure and organization of settings-related files.
This commit is contained in:
66
tests/Unit/admin/Controllers/SettingsControllerTest.php
Normal file
66
tests/Unit/admin/Controllers/SettingsControllerTest.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace Tests\Unit\admin\Controllers;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use admin\Controllers\SettingsController;
|
||||
use Domain\Settings\SettingsRepository;
|
||||
|
||||
/**
|
||||
* Testy dla SettingsController
|
||||
*
|
||||
* Kontroler używa SettingsRepository (DI).
|
||||
* Cache czyszczony bezpośrednio przez \S::delete_dir() i \RedisConnection.
|
||||
*/
|
||||
class SettingsControllerTest extends TestCase
|
||||
{
|
||||
private $mockSettingsRepository;
|
||||
private $controller;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->mockSettingsRepository = $this->createMock(SettingsRepository::class);
|
||||
$this->controller = new SettingsController($this->mockSettingsRepository);
|
||||
}
|
||||
|
||||
public function testConstructorAcceptsRepository(): void
|
||||
{
|
||||
$controller = new SettingsController($this->mockSettingsRepository);
|
||||
$this->assertInstanceOf(SettingsController::class, $controller);
|
||||
}
|
||||
|
||||
public function testHasClearCacheMethod(): void
|
||||
{
|
||||
$this->assertTrue(method_exists($this->controller, 'clearCache'));
|
||||
}
|
||||
|
||||
public function testHasClearCacheAjaxMethod(): void
|
||||
{
|
||||
$this->assertTrue(method_exists($this->controller, 'clearCacheAjax'));
|
||||
}
|
||||
|
||||
public function testHasSaveMethod(): void
|
||||
{
|
||||
$this->assertTrue(method_exists($this->controller, 'save'));
|
||||
}
|
||||
|
||||
public function testHasViewMethod(): void
|
||||
{
|
||||
$this->assertTrue(method_exists($this->controller, 'view'));
|
||||
}
|
||||
|
||||
public function testIsNotAbstract(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass($this->controller);
|
||||
$this->assertFalse($reflection->isAbstract());
|
||||
}
|
||||
|
||||
public function testActionMethodReturnTypes(): void
|
||||
{
|
||||
$reflection = new \ReflectionClass($this->controller);
|
||||
|
||||
$this->assertEquals('void', (string)$reflection->getMethod('clearCache')->getReturnType());
|
||||
$this->assertEquals('void', (string)$reflection->getMethod('clearCacheAjax')->getReturnType());
|
||||
$this->assertEquals('void', (string)$reflection->getMethod('save')->getReturnType());
|
||||
$this->assertEquals('string', (string)$reflection->getMethod('view')->getReturnType());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user