. */ declare(strict_types=1); namespace SP\Tests\Modules\Web\Controllers\AccessManager; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\MockObject\Exception; use PHPUnit\Framework\MockObject\Stub; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use SP\Domain\Config\Ports\ConfigDataInterface; use SP\Domain\Core\Exceptions\InvalidClassException; use SP\Domain\User\Models\ProfileData; use SP\Infrastructure\File\FileException; use SP\Mvc\View\OutputHandlerInterface; use SP\Tests\IntegrationTestCase; use Symfony\Component\DomCrawler\Crawler; /** * Class IndexControllerTest */ #[Group('integration')] class IndexControllerTest extends IntegrationTestCase { /** * @throws Exception * @throws FileException * @throws InvalidClassException * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function testIndexAction() { $definitions = $this->getModuleDefinitions(); $definitions[OutputHandlerInterface::class] = $this->setupOutputHandler(function (string $output): void { $crawler = new Crawler($output); $filter = $crawler->filterXPath( '//div[contains(@id, \'tabs-\')]//form' )->extract(['id']); assert(!empty($output)); assert(count($filter) === 5); $this->assertTrue(true); }); $container = $this->buildContainer( $definitions, $this->buildRequest('get', 'index.php', ['r' => 'accessManager/index']) ); $this->runApp($container); } protected function getUserProfile(): ProfileData { return new ProfileData( [ 'mgmUsers' => true, 'mgmGroups' => true, 'mgmProfiles' => true, 'mgmApiTokens' => true, 'mgmPublicLinks' => true ] ); } protected function getConfigData(): ConfigDataInterface|Stub { $configData = parent::getConfigData(); $configData->method('isPublinksEnabled')->willReturn(true); return $configData; } }