. */ declare(strict_types=1); namespace SP\Tests\Modules\Web\Controllers\Account; 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\Account\Adapters\AccountPassItemWithIdAndName; use SP\Domain\Core\Context\SessionContext; use SP\Domain\Core\Crypt\CryptInterface; use SP\Domain\Core\Crypt\VaultInterface; use SP\Domain\Core\Exceptions\InvalidClassException; use SP\Domain\User\Models\ProfileData; use SP\Infrastructure\Database\QueryResult; use SP\Infrastructure\File\FileException; use SP\Tests\Generators\AccountDataGenerator; use SP\Tests\IntegrationTestCase; /** * Class CopyPassHistoryControllerTest */ #[Group('integration')] class CopyPassHistoryControllerTest extends IntegrationTestCase { /** * @throws NotFoundExceptionInterface * @throws Exception * @throws FileException * @throws InvalidClassException * @throws ContainerExceptionInterface */ public function testCopyPassHistoryAction() { $this->addDatabaseMapperResolver( AccountPassItemWithIdAndName::class, new QueryResult([ AccountPassItemWithIdAndName::buildFromSimpleModel( AccountDataGenerator::factory()->buildAccountDataView() ) ]) ); $crypt = $this->createStub(CryptInterface::class); $crypt->method('decrypt')->willReturn('some_data'); $crypt->method('encrypt')->willReturn('some_data'); $definitions = $this->getModuleDefinitions(); $definitions[CryptInterface::class] = $crypt; $container = $this->buildContainer( $definitions, $this->buildRequest( 'get', 'index.php', ['r' => 'account/copyPassHistory/id/' . self::$faker->randomNumber(3)] ) ); $this->runApp($container); $this->expectOutputString('{"status":0,"description":null,"data":{"accpass":"some_data"},"messages":[]}'); } protected function getContext(): SessionContext|Stub { $vault = self::createStub(VaultInterface::class); $context = parent::getContext(); $context->method('getVault')->willReturn($vault); return $context; } protected function getUserProfile(): ProfileData { return new ProfileData(['accViewPass' => true, 'accViewHistory' => true]); } }