Files
FOSSBilling/tests-legacy/modules/Index/Controller/AdminTest.php
T
Adam DaleyandCopilot a0b3158b30 PHPUnit test-legacy refactor and cleanup (#3144)
* 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>
2026-01-13 17:32:09 +00:00

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);
}
}