. */ declare(strict_types=1); namespace SP\Tests\Modules\Web\Controllers\ConfigBackup; 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\Core\Exceptions\InvalidClassException; use SP\Infrastructure\File\FileException; use SP\Tests\IntegrationTestCase; /** * Class ConfigBackupControllerTest */ #[Group('integration')] class ConfigBackupControllerTest extends IntegrationTestCase { private array $definitions; /** * @throws ContainerExceptionInterface * @throws Exception * @throws NotFoundExceptionInterface */ #[Test] public function downloadBackupApp() { $filename = REAL_APP_ROOT . DIRECTORY_SEPARATOR . 'app' . DIRECTORY_SEPARATOR . 'backup' . DIRECTORY_SEPARATOR . 'sysPass_app-' . $this->passwordSalt . '.gz'; file_put_contents($filename, 'test_data'); $container = $this->buildContainer( $this->definitions, $this->buildRequest('get', 'index.php', ['r' => 'configBackup/downloadBackupApp']) ); $this->runApp($container); $this->expectOutputString('test_data'); } /** * @throws InvalidClassException * @throws FileException */ protected function setUp(): void { parent::setUp(); $this->definitions = $this->getModuleDefinitions(); } protected function getConfigData(): ConfigDataInterface|Stub { $configData = parent::getConfigData(); $configData->method('getBackupHash')->willReturn($this->passwordSalt); return $configData; } }