. */ declare(strict_types=1); namespace SP\Tests\Modules\Web\Controllers\AccessManager; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\Attributes\Test; 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\User\Models\ProfileData; use SP\Tests\BodyChecker; use SP\Tests\IntegrationTestCase; use Symfony\Component\DomCrawler\Crawler; /** * Class IndexControllerTest */ #[Group('integration')] class IndexControllerTest extends IntegrationTestCase { /** * @throws ContainerExceptionInterface * @throws Exception * @throws NotFoundExceptionInterface */ #[Test] #[BodyChecker('outputCheckerIndex')] public function index() { $container = $this->buildContainer( $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; } /** * @param string $output * @return void */ private function outputCheckerIndex(string $output): void { $crawler = new Crawler($output); $filter = $crawler->filterXPath( '//div[contains(@id, \'tabs-\')]//form' )->extract(['id']); self::assertCount(5, $filter); } }