Files
kupshop/bundles/KupShop/ProxyCacheBundle/Command/CookiesFunctionalityTestCommand.php
2025-08-02 16:30:27 +02:00

44 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace KupShop\ProxyCacheBundle\Command;
use KupShop\ProxyCacheBundle\Util\CookiesFunctionalityTest;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Contracts\Service\Attribute\Required;
class CookiesFunctionalityTestCommand extends Command
{
#[Required]
public CookiesFunctionalityTest $test;
protected function configure()
{
$this
->setName('kupshop:test:cookies')
->setDescription('Test if cacheable responses return cookies');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$errors = $this->test->testInitialRequestCookiesAbsence();
$failed = false;
foreach ($errors as $error) {
$failed = true;
$output->writeln('<error>COOKIE VRÁCENA:</error> '.$error);
}
if ($failed) {
$output->writeln('<comment>Více o tom jak funguje proxy_cache a jak má být nastavená: </comment>'.CookiesFunctionalityTest::WIKI_LINK);
} else {
$output->writeln('<info>Úspěch: na úvodní požadavky nebyly vráceny cookies</info>');
}
return 0;
}
}