- Migrate class.S → Shared\Helpers\Helpers (140+ files), remove 12 unused methods - Migrate class.Html → Shared\Html\Html - Migrate class.Email → Shared\Email\Email - Migrate class.Image → Shared\Image\ImageManipulator - Delete class.Log (unused), class.Mobile_Detect (outdated UA detection) - Remove grid library loading from admin (index.php, ajax.php) - Replace gridEdit usage in 10 admin templates with grid-edit-replacement.php - Fix grid-edit-replacement.php AJAX to send values as JSON (grid.js compat) - Remove mobile layout conditionals (m_html/m_css/m_js) from Site + LayoutsRepository - Remove \Log::save_log() calls from OrderAdminService, ShopOrder, Order Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
70 lines
2.3 KiB
PHP
70 lines
2.3 KiB
PHP
<?php
|
|
namespace Tests\Unit\admin\Controllers;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use admin\Controllers\SettingsController;
|
|
use Domain\Languages\LanguagesRepository;
|
|
use Domain\Settings\SettingsRepository;
|
|
|
|
/**
|
|
* Testy dla SettingsController
|
|
*
|
|
* Kontroler używa SettingsRepository (DI).
|
|
* Cache czyszczony bezpośrednio przez \Shared\Helpers\Helpers::delete_dir() i \Shared\Cache\RedisConnection.
|
|
*/
|
|
class SettingsControllerTest extends TestCase
|
|
{
|
|
private $mockSettingsRepository;
|
|
private $mockLanguagesRepository;
|
|
private $controller;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
$this->mockSettingsRepository = $this->createMock(SettingsRepository::class);
|
|
$this->mockLanguagesRepository = $this->createMock(LanguagesRepository::class);
|
|
$this->controller = new SettingsController($this->mockSettingsRepository, $this->mockLanguagesRepository);
|
|
}
|
|
|
|
public function testConstructorAcceptsRepository(): void
|
|
{
|
|
$controller = new SettingsController($this->mockSettingsRepository, $this->mockLanguagesRepository);
|
|
$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());
|
|
}
|
|
}
|