mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-02 21:30:16 +09:00
* PHPUnit test-legacy cleanup Refactor and cleanup the legacy PHPUnit tests. * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
86 lines
2.7 KiB
PHP
86 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Box\Mod\Theme\Controller;
|
|
|
|
use PHPUnit\Framework\Attributes\Group;
|
|
|
|
#[Group('Core')]
|
|
final class AdminTest extends \BBTestCase
|
|
{
|
|
public function testDi(): void
|
|
{
|
|
$controller = new Admin();
|
|
|
|
$di = $this->getDi();
|
|
$db = $this->createMock('Box_Database');
|
|
|
|
$di['db'] = $db;
|
|
$controller->setDi($di);
|
|
$result = $controller->getDi();
|
|
$this->assertEquals($di, $result);
|
|
}
|
|
|
|
public function testRegister(): void
|
|
{
|
|
$boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock();
|
|
$boxAppMock->expects($this->exactly(1))
|
|
->method('get');
|
|
|
|
$controller = new Admin();
|
|
$controller->register($boxAppMock);
|
|
}
|
|
|
|
public function testGetTheme(): void
|
|
{
|
|
$boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock();
|
|
$boxAppMock->expects($this->atLeastOnce())
|
|
->method('render')
|
|
->with('mod_theme_preset')
|
|
->willReturn('Rendering ...');
|
|
|
|
$themeMock = $this->getMockBuilder(\Box\Mod\Theme\Model\Theme::class)->disableOriginalConstructor()->getMock();
|
|
$themeMock->expects($this->atLeastOnce())
|
|
->method('getSettingsPageHtml')
|
|
->willReturn('');
|
|
$themeMock->expects($this->atLeastOnce())
|
|
->method('getName');
|
|
$themeMock->expects($this->atLeastOnce())
|
|
->method('getUploadedAssets');
|
|
$themeMock->expects($this->atLeastOnce())
|
|
->method('isAssetsPathWritable')
|
|
->willReturn(false);
|
|
|
|
$themeServiceMock = $this->createMock(\Box\Mod\Theme\Service::class);
|
|
$themeServiceMock->expects($this->atLeastOnce())
|
|
->method('getTheme')
|
|
->willReturn($themeMock);
|
|
$themeServiceMock->expects($this->atLeastOnce())
|
|
->method('getCurrentThemePreset')
|
|
->willReturn('default');
|
|
$themeServiceMock->expects($this->atLeastOnce())
|
|
->method('getThemeSettings');
|
|
$themeServiceMock->expects($this->atLeastOnce())
|
|
->method('getThemePresets');
|
|
|
|
$modMock = $this->getMockBuilder('\\' . \FOSSBilling\Module::class)->disableOriginalConstructor()->getMock();
|
|
$modMock->expects($this->atLeastOnce())
|
|
->method('getService')
|
|
->willReturn($themeServiceMock);
|
|
|
|
$di = $this->getDi();
|
|
$di['mod'] = $di->protect(function ($name) use ($modMock) {
|
|
if ($name == 'theme') {
|
|
return $modMock;
|
|
}
|
|
});
|
|
|
|
$di['is_admin_logged'] = true;
|
|
|
|
$controller = new Admin();
|
|
$controller->setDi($di);
|
|
$controller->get_theme($boxAppMock, 'huraga');
|
|
}
|
|
}
|