mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-09 13:36:07 +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>
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Box\Mod\Index\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(4))
|
|
->method('get');
|
|
|
|
$controller = new Admin();
|
|
$controller->register($boxAppMock);
|
|
}
|
|
|
|
public function testGetIndexAdminIsLogged(): void
|
|
{
|
|
$boxAppMock = $this->getMockBuilder('\Box_App')->disableOriginalConstructor()->getMock();
|
|
$boxAppMock->expects($this->atLeastOnce())
|
|
->method('render')
|
|
->with('mod_index_dashboard');
|
|
|
|
$authorizationMock = $this->getMockBuilder('\Box_Authorization')->disableOriginalConstructor()->getMock();
|
|
$authorizationMock->expects($this->atLeastOnce())
|
|
->method('isAdminLoggedIn')
|
|
->willReturn(true);
|
|
|
|
$di = $this->getDi();
|
|
$di['auth'] = $authorizationMock;
|
|
|
|
$controller = new Admin();
|
|
$controller->setDi($di);
|
|
$controller->get_index($boxAppMock);
|
|
}
|
|
}
|