You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.3 KiB
74 lines
2.3 KiB
<?= "<?php\n" ?>
|
|
|
|
namespace <?= $namespace; ?>;
|
|
|
|
use PHPUnit\Framework\MockObject\MockBuilder;
|
|
use Symfony\Bundle\FrameworkBundle\Client;
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application;
|
|
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
use Symfony\Component\BrowserKit\Cookie;
|
|
use Symfony\Component\Console\Tester\CommandTester;
|
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
use Symfony\Component\DependencyInjection\ResettableContainerInterface;
|
|
use Symfony\Component\DomCrawler\Crawler;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
|
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
|
|
use Symfony\Component\Security\Core\User\UserInterface;
|
|
|
|
class <?= $class_name ?> extends WebTestCase
|
|
{
|
|
public function test<?= $class_name ?>()
|
|
{
|
|
$this->runCommand(<?= $class_name ?>::getCommandName());
|
|
}
|
|
/**
|
|
* Builds up the environment to run the given command.
|
|
*
|
|
* @param string $name
|
|
* @param array $params
|
|
* @param bool $reuseKernel
|
|
*
|
|
* @return CommandTester
|
|
*/
|
|
protected function runCommand(string $name, array $params = [], bool $reuseKernel = false): CommandTester
|
|
{
|
|
if (!$reuseKernel) {
|
|
if (null !== static::$kernel) {
|
|
static::$kernel->shutdown();
|
|
}
|
|
|
|
$kernel = static::$kernel = static::createKernel(['environment' => $this->environment]);
|
|
$kernel->boot();
|
|
} else {
|
|
$kernel = $this->getContainer()->get('kernel');
|
|
}
|
|
|
|
$application = new Application($kernel);
|
|
|
|
$options = [
|
|
'interactive' => false,
|
|
'decorated' => $this->getDecorated(),
|
|
'verbosity' => $this->getVerbosityLevel(),
|
|
];
|
|
|
|
$command = $application->find($name);
|
|
$commandTester = new CommandTester($command);
|
|
|
|
if (null !== $inputs = $this->getInputs()) {
|
|
$commandTester->setInputs($inputs);
|
|
$options['interactive'] = true;
|
|
$this->inputs = null;
|
|
}
|
|
|
|
$commandTester->execute(
|
|
array_merge(['command' => $command->getName()], $params),
|
|
$options
|
|
);
|
|
|
|
return $commandTester;
|
|
}
|
|
|
|
}
|