mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°8834 - Add compatibility with PHP 8.4 (#819)
* N°8834 - Add compatibility with PHP 8.4 * Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
@@ -43,7 +43,7 @@ trait BrowserKitAssertionsTrait
|
||||
self::assertThatForResponse(new ResponseConstraint\ResponseFormatSame(self::getRequest(), $expectedFormat), $message);
|
||||
}
|
||||
|
||||
public static function assertResponseRedirects(string $expectedLocation = null, int $expectedCode = null, string $message = ''): void
|
||||
public static function assertResponseRedirects(?string $expectedLocation = null, ?int $expectedCode = null, string $message = ''): void
|
||||
{
|
||||
$constraint = new ResponseConstraint\ResponseIsRedirected();
|
||||
if ($expectedLocation) {
|
||||
@@ -82,17 +82,17 @@ trait BrowserKitAssertionsTrait
|
||||
self::assertThatForResponse(new LogicalNot(new ResponseConstraint\ResponseHeaderSame($headerName, $expectedValue)), $message);
|
||||
}
|
||||
|
||||
public static function assertResponseHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void
|
||||
public static function assertResponseHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void
|
||||
{
|
||||
self::assertThatForResponse(new ResponseConstraint\ResponseHasCookie($name, $path, $domain), $message);
|
||||
}
|
||||
|
||||
public static function assertResponseNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void
|
||||
public static function assertResponseNotHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void
|
||||
{
|
||||
self::assertThatForResponse(new LogicalNot(new ResponseConstraint\ResponseHasCookie($name, $path, $domain)), $message);
|
||||
}
|
||||
|
||||
public static function assertResponseCookieValueSame(string $name, string $expectedValue, string $path = '/', string $domain = null, string $message = ''): void
|
||||
public static function assertResponseCookieValueSame(string $name, string $expectedValue, string $path = '/', ?string $domain = null, string $message = ''): void
|
||||
{
|
||||
self::assertThatForResponse(LogicalAnd::fromConstraints(
|
||||
new ResponseConstraint\ResponseHasCookie($name, $path, $domain),
|
||||
@@ -105,17 +105,17 @@ trait BrowserKitAssertionsTrait
|
||||
self::assertThatForResponse(new ResponseConstraint\ResponseIsUnprocessable(), $message);
|
||||
}
|
||||
|
||||
public static function assertBrowserHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void
|
||||
public static function assertBrowserHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void
|
||||
{
|
||||
self::assertThatForClient(new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain), $message);
|
||||
}
|
||||
|
||||
public static function assertBrowserNotHasCookie(string $name, string $path = '/', string $domain = null, string $message = ''): void
|
||||
public static function assertBrowserNotHasCookie(string $name, string $path = '/', ?string $domain = null, string $message = ''): void
|
||||
{
|
||||
self::assertThatForClient(new LogicalNot(new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain)), $message);
|
||||
}
|
||||
|
||||
public static function assertBrowserCookieValueSame(string $name, string $expectedValue, bool $raw = false, string $path = '/', string $domain = null, string $message = ''): void
|
||||
public static function assertBrowserCookieValueSame(string $name, string $expectedValue, bool $raw = false, string $path = '/', ?string $domain = null, string $message = ''): void
|
||||
{
|
||||
self::assertThatForClient(LogicalAnd::fromConstraints(
|
||||
new BrowserKitConstraint\BrowserHasCookie($name, $path, $domain),
|
||||
@@ -162,7 +162,7 @@ trait BrowserKitAssertionsTrait
|
||||
self::assertThat(self::getClient(), $constraint, $message);
|
||||
}
|
||||
|
||||
protected static function getClient(AbstractBrowser $newClient = null): ?AbstractBrowser
|
||||
protected static function getClient(?AbstractBrowser $newClient = null): ?AbstractBrowser
|
||||
{
|
||||
static $client;
|
||||
|
||||
@@ -171,7 +171,7 @@ trait BrowserKitAssertionsTrait
|
||||
}
|
||||
|
||||
if (!$client instanceof AbstractBrowser) {
|
||||
static::fail(sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', __CLASS__));
|
||||
static::fail(\sprintf('A client must be set to make assertions on it. Did you forget to call "%s::createClient()"?', __CLASS__));
|
||||
}
|
||||
|
||||
return $client;
|
||||
|
||||
@@ -26,12 +26,12 @@ trait DomCrawlerAssertionsTrait
|
||||
{
|
||||
public static function assertSelectorExists(string $selector, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getCrawler(), new DomCrawlerConstraint\CrawlerSelectorExists($selector), $message);
|
||||
self::assertThat(self::getCrawler(), new CrawlerSelectorExists($selector), $message);
|
||||
}
|
||||
|
||||
public static function assertSelectorNotExists(string $selector, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getCrawler(), new LogicalNot(new DomCrawlerConstraint\CrawlerSelectorExists($selector)), $message);
|
||||
self::assertThat(self::getCrawler(), new LogicalNot(new CrawlerSelectorExists($selector)), $message);
|
||||
}
|
||||
|
||||
public static function assertSelectorCount(int $expectedCount, string $selector, string $message = ''): void
|
||||
@@ -42,7 +42,7 @@ trait DomCrawlerAssertionsTrait
|
||||
public static function assertSelectorTextContains(string $selector, string $text, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
|
||||
new DomCrawlerConstraint\CrawlerSelectorExists($selector),
|
||||
new CrawlerSelectorExists($selector),
|
||||
new DomCrawlerConstraint\CrawlerSelectorTextContains($selector, $text)
|
||||
), $message);
|
||||
}
|
||||
@@ -50,7 +50,7 @@ trait DomCrawlerAssertionsTrait
|
||||
public static function assertAnySelectorTextContains(string $selector, string $text, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
|
||||
new DomCrawlerConstraint\CrawlerSelectorExists($selector),
|
||||
new CrawlerSelectorExists($selector),
|
||||
new DomCrawlerConstraint\CrawlerAnySelectorTextContains($selector, $text)
|
||||
), $message);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ trait DomCrawlerAssertionsTrait
|
||||
public static function assertSelectorTextSame(string $selector, string $text, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
|
||||
new DomCrawlerConstraint\CrawlerSelectorExists($selector),
|
||||
new CrawlerSelectorExists($selector),
|
||||
new DomCrawlerConstraint\CrawlerSelectorTextSame($selector, $text)
|
||||
), $message);
|
||||
}
|
||||
@@ -66,7 +66,7 @@ trait DomCrawlerAssertionsTrait
|
||||
public static function assertAnySelectorTextSame(string $selector, string $text, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
|
||||
new DomCrawlerConstraint\CrawlerSelectorExists($selector),
|
||||
new CrawlerSelectorExists($selector),
|
||||
new DomCrawlerConstraint\CrawlerAnySelectorTextSame($selector, $text)
|
||||
), $message);
|
||||
}
|
||||
@@ -74,7 +74,7 @@ trait DomCrawlerAssertionsTrait
|
||||
public static function assertSelectorTextNotContains(string $selector, string $text, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
|
||||
new DomCrawlerConstraint\CrawlerSelectorExists($selector),
|
||||
new CrawlerSelectorExists($selector),
|
||||
new LogicalNot(new DomCrawlerConstraint\CrawlerSelectorTextContains($selector, $text))
|
||||
), $message);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ trait DomCrawlerAssertionsTrait
|
||||
public static function assertAnySelectorTextNotContains(string $selector, string $text, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
|
||||
new DomCrawlerConstraint\CrawlerSelectorExists($selector),
|
||||
new CrawlerSelectorExists($selector),
|
||||
new LogicalNot(new DomCrawlerConstraint\CrawlerAnySelectorTextContains($selector, $text))
|
||||
), $message);
|
||||
}
|
||||
@@ -100,7 +100,7 @@ trait DomCrawlerAssertionsTrait
|
||||
public static function assertInputValueSame(string $fieldName, string $expectedValue, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
|
||||
new DomCrawlerConstraint\CrawlerSelectorExists("input[name=\"$fieldName\"]"),
|
||||
new CrawlerSelectorExists("input[name=\"$fieldName\"]"),
|
||||
new DomCrawlerConstraint\CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'value', $expectedValue)
|
||||
), $message);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ trait DomCrawlerAssertionsTrait
|
||||
public static function assertInputValueNotSame(string $fieldName, string $expectedValue, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getCrawler(), LogicalAnd::fromConstraints(
|
||||
new DomCrawlerConstraint\CrawlerSelectorExists("input[name=\"$fieldName\"]"),
|
||||
new CrawlerSelectorExists("input[name=\"$fieldName\"]"),
|
||||
new LogicalNot(new DomCrawlerConstraint\CrawlerSelectorAttributeValueSame("input[name=\"$fieldName\"]", 'value', $expectedValue))
|
||||
), $message);
|
||||
}
|
||||
@@ -126,18 +126,18 @@ trait DomCrawlerAssertionsTrait
|
||||
public static function assertFormValue(string $formSelector, string $fieldName, string $value, string $message = ''): void
|
||||
{
|
||||
$node = self::getCrawler()->filter($formSelector);
|
||||
self::assertNotEmpty($node, sprintf('Form "%s" not found.', $formSelector));
|
||||
self::assertNotEmpty($node, \sprintf('Form "%s" not found.', $formSelector));
|
||||
$values = $node->form()->getValues();
|
||||
self::assertArrayHasKey($fieldName, $values, $message ?: sprintf('Field "%s" not found in form "%s".', $fieldName, $formSelector));
|
||||
self::assertArrayHasKey($fieldName, $values, $message ?: \sprintf('Field "%s" not found in form "%s".', $fieldName, $formSelector));
|
||||
self::assertSame($value, $values[$fieldName]);
|
||||
}
|
||||
|
||||
public static function assertNoFormValue(string $formSelector, string $fieldName, string $message = ''): void
|
||||
{
|
||||
$node = self::getCrawler()->filter($formSelector);
|
||||
self::assertNotEmpty($node, sprintf('Form "%s" not found.', $formSelector));
|
||||
self::assertNotEmpty($node, \sprintf('Form "%s" not found.', $formSelector));
|
||||
$values = $node->form()->getValues();
|
||||
self::assertArrayNotHasKey($fieldName, $values, $message ?: sprintf('Field "%s" has a value in form "%s".', $fieldName, $formSelector));
|
||||
self::assertArrayNotHasKey($fieldName, $values, $message ?: \sprintf('Field "%s" has a value in form "%s".', $fieldName, $formSelector));
|
||||
}
|
||||
|
||||
private static function getCrawler(): Crawler
|
||||
|
||||
@@ -14,13 +14,12 @@ namespace Symfony\Bundle\FrameworkBundle\Test;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Component\HttpClient\DataCollector\HttpClientDataCollector;
|
||||
|
||||
/*
|
||||
/**
|
||||
* @author Mathieu Santostefano <msantostefano@protonmail.com>
|
||||
*/
|
||||
|
||||
trait HttpClientAssertionsTrait
|
||||
{
|
||||
public static function assertHttpClientRequest(string $expectedUrl, string $expectedMethod = 'GET', string|array $expectedBody = null, array $expectedHeaders = [], string $httpClientId = 'http_client'): void
|
||||
public static function assertHttpClientRequest(string $expectedUrl, string $expectedMethod = 'GET', string|array|null $expectedBody = null, array $expectedHeaders = [], string $httpClientId = 'http_client'): void
|
||||
{
|
||||
/** @var KernelBrowser $client */
|
||||
$client = static::getClient();
|
||||
@@ -34,7 +33,7 @@ trait HttpClientAssertionsTrait
|
||||
$expectedRequestHasBeenFound = false;
|
||||
|
||||
if (!\array_key_exists($httpClientId, $httpClientDataCollector->getClients())) {
|
||||
static::fail(sprintf('HttpClient "%s" is not registered.', $httpClientId));
|
||||
static::fail(\sprintf('HttpClient "%s" is not registered.', $httpClientId));
|
||||
}
|
||||
|
||||
foreach ($httpClientDataCollector->getClients()[$httpClientId]['traces'] as $trace) {
|
||||
@@ -102,7 +101,7 @@ trait HttpClientAssertionsTrait
|
||||
$unexpectedUrlHasBeenFound = false;
|
||||
|
||||
if (!\array_key_exists($httpClientId, $httpClientDataCollector->getClients())) {
|
||||
static::fail(sprintf('HttpClient "%s" is not registered.', $httpClientId));
|
||||
static::fail(\sprintf('HttpClient "%s" is not registered.', $httpClientId));
|
||||
}
|
||||
|
||||
foreach ($httpClientDataCollector->getClients()[$httpClientId]['traces'] as $trace) {
|
||||
@@ -114,7 +113,7 @@ trait HttpClientAssertionsTrait
|
||||
}
|
||||
}
|
||||
|
||||
self::assertFalse($unexpectedUrlHasBeenFound, sprintf('Unexpected URL called: "%s" - "%s"', $expectedMethod, $unexpectedUrl));
|
||||
self::assertFalse($unexpectedUrlHasBeenFound, \sprintf('Unexpected URL called: "%s" - "%s"', $expectedMethod, $unexpectedUrl));
|
||||
}
|
||||
|
||||
public static function assertHttpClientRequestCount(int $count, string $httpClientId = 'http_client'): void
|
||||
|
||||
@@ -15,6 +15,7 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;
|
||||
use Symfony\Component\Filesystem\Filesystem;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
use Symfony\Contracts\Service\ResetInterface;
|
||||
|
||||
@@ -45,6 +46,14 @@ abstract class KernelTestCase extends TestCase
|
||||
static::$booted = false;
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass(): void
|
||||
{
|
||||
static::ensureKernelShutdown();
|
||||
static::$class = null;
|
||||
static::$kernel = null;
|
||||
static::$booted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \RuntimeException
|
||||
* @throws \LogicException
|
||||
@@ -52,11 +61,11 @@ abstract class KernelTestCase extends TestCase
|
||||
protected static function getKernelClass(): string
|
||||
{
|
||||
if (!isset($_SERVER['KERNEL_CLASS']) && !isset($_ENV['KERNEL_CLASS'])) {
|
||||
throw new \LogicException(sprintf('You must set the KERNEL_CLASS environment variable to the fully-qualified class name of your Kernel in phpunit.xml / phpunit.xml.dist or override the "%1$s::createKernel()" or "%1$s::getKernelClass()" method.', static::class));
|
||||
throw new \LogicException(\sprintf('You must set the KERNEL_CLASS environment variable to the fully-qualified class name of your Kernel in phpunit.xml / phpunit.xml.dist or override the "%1$s::createKernel()" or "%1$s::getKernelClass()" method.', static::class));
|
||||
}
|
||||
|
||||
if (!class_exists($class = $_ENV['KERNEL_CLASS'] ?? $_SERVER['KERNEL_CLASS'])) {
|
||||
throw new \RuntimeException(sprintf('Class "%s" doesn\'t exist or cannot be autoloaded. Check that the KERNEL_CLASS value in phpunit.xml matches the fully-qualified class name of your Kernel or override the "%s::createKernel()" method.', $class, static::class));
|
||||
throw new \RuntimeException(\sprintf('Class "%s" doesn\'t exist or cannot be autoloaded. Check that the KERNEL_CLASS value in phpunit.xml matches the fully-qualified class name of your Kernel or override the "%s::createKernel()" method.', $class, static::class));
|
||||
}
|
||||
|
||||
return $class;
|
||||
@@ -74,6 +83,18 @@ abstract class KernelTestCase extends TestCase
|
||||
static::$kernel = $kernel;
|
||||
static::$booted = true;
|
||||
|
||||
// If the cache warmer is registered, it means that the cache has been
|
||||
// warmed up, so the current container is not fresh anymore. Let's
|
||||
// reboot a fresh one.
|
||||
if (self::getContainer()->initialized('cache_warmer')) {
|
||||
static::ensureKernelShutdown();
|
||||
|
||||
$kernel = static::createKernel($options);
|
||||
$kernel->boot();
|
||||
static::$kernel = $kernel;
|
||||
static::$booted = true;
|
||||
}
|
||||
|
||||
return static::$kernel;
|
||||
}
|
||||
|
||||
@@ -126,12 +147,27 @@ abstract class KernelTestCase extends TestCase
|
||||
if (null !== static::$kernel) {
|
||||
static::$kernel->boot();
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$httpCacheDir = null;
|
||||
if ($container->has('http_cache')) {
|
||||
$httpCacheDir = static::$kernel->getCacheDir().'/http_cache';
|
||||
}
|
||||
|
||||
if ($container->has('services_resetter')) {
|
||||
// Instantiate the service because Container::reset() only resets services that have been used
|
||||
$container->get('services_resetter');
|
||||
}
|
||||
|
||||
static::$kernel->shutdown();
|
||||
static::$booted = false;
|
||||
|
||||
if ($container instanceof ResetInterface) {
|
||||
$container->reset();
|
||||
}
|
||||
|
||||
if (null !== $httpCacheDir && is_dir($httpCacheDir)) {
|
||||
(new Filesystem())->remove($httpCacheDir);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,12 @@ use Symfony\Component\Mime\Test\Constraint as MimeConstraint;
|
||||
|
||||
trait MailerAssertionsTrait
|
||||
{
|
||||
public static function assertEmailCount(int $count, string $transport = null, string $message = ''): void
|
||||
public static function assertEmailCount(int $count, ?string $transport = null, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getMessageMailerEvents(), new MailerConstraint\EmailCount($count, $transport), $message);
|
||||
}
|
||||
|
||||
public static function assertQueuedEmailCount(int $count, string $transport = null, string $message = ''): void
|
||||
public static function assertQueuedEmailCount(int $count, ?string $transport = null, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getMessageMailerEvents(), new MailerConstraint\EmailCount($count, $transport, true), $message);
|
||||
}
|
||||
@@ -103,12 +103,12 @@ trait MailerAssertionsTrait
|
||||
/**
|
||||
* @return MessageEvent[]
|
||||
*/
|
||||
public static function getMailerEvents(string $transport = null): array
|
||||
public static function getMailerEvents(?string $transport = null): array
|
||||
{
|
||||
return self::getMessageMailerEvents()->getEvents($transport);
|
||||
}
|
||||
|
||||
public static function getMailerEvent(int $index = 0, string $transport = null): ?MessageEvent
|
||||
public static function getMailerEvent(int $index = 0, ?string $transport = null): ?MessageEvent
|
||||
{
|
||||
return self::getMailerEvents($transport)[$index] ?? null;
|
||||
}
|
||||
@@ -116,12 +116,12 @@ trait MailerAssertionsTrait
|
||||
/**
|
||||
* @return RawMessage[]
|
||||
*/
|
||||
public static function getMailerMessages(string $transport = null): array
|
||||
public static function getMailerMessages(?string $transport = null): array
|
||||
{
|
||||
return self::getMessageMailerEvents()->getMessages($transport);
|
||||
}
|
||||
|
||||
public static function getMailerMessage(int $index = 0, string $transport = null): ?RawMessage
|
||||
public static function getMailerMessage(int $index = 0, ?string $transport = null): ?RawMessage
|
||||
{
|
||||
return self::getMailerMessages($transport)[$index] ?? null;
|
||||
}
|
||||
|
||||
@@ -17,17 +17,17 @@ use Symfony\Component\Notifier\Event\NotificationEvents;
|
||||
use Symfony\Component\Notifier\Message\MessageInterface;
|
||||
use Symfony\Component\Notifier\Test\Constraint as NotifierConstraint;
|
||||
|
||||
/*
|
||||
/**
|
||||
* @author Smaïne Milianni <smaine.milianni@gmail.com>
|
||||
*/
|
||||
trait NotificationAssertionsTrait
|
||||
{
|
||||
public static function assertNotificationCount(int $count, string $transportName = null, string $message = ''): void
|
||||
public static function assertNotificationCount(int $count, ?string $transportName = null, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getNotificationEvents(), new NotifierConstraint\NotificationCount($count, $transportName), $message);
|
||||
}
|
||||
|
||||
public static function assertQueuedNotificationCount(int $count, string $transportName = null, string $message = ''): void
|
||||
public static function assertQueuedNotificationCount(int $count, ?string $transportName = null, string $message = ''): void
|
||||
{
|
||||
self::assertThat(self::getNotificationEvents(), new NotifierConstraint\NotificationCount($count, $transportName, true), $message);
|
||||
}
|
||||
@@ -52,12 +52,12 @@ trait NotificationAssertionsTrait
|
||||
self::assertThat($notification, new LogicalNot(new NotifierConstraint\NotificationSubjectContains($text)), $message);
|
||||
}
|
||||
|
||||
public static function assertNotificationTransportIsEqual(MessageInterface $notification, string $transportName = null, string $message = ''): void
|
||||
public static function assertNotificationTransportIsEqual(MessageInterface $notification, ?string $transportName = null, string $message = ''): void
|
||||
{
|
||||
self::assertThat($notification, new NotifierConstraint\NotificationTransportIsEqual($transportName), $message);
|
||||
}
|
||||
|
||||
public static function assertNotificationTransportIsNotEqual(MessageInterface $notification, string $transportName = null, string $message = ''): void
|
||||
public static function assertNotificationTransportIsNotEqual(MessageInterface $notification, ?string $transportName = null, string $message = ''): void
|
||||
{
|
||||
self::assertThat($notification, new LogicalNot(new NotifierConstraint\NotificationTransportIsEqual($transportName)), $message);
|
||||
}
|
||||
@@ -65,12 +65,12 @@ trait NotificationAssertionsTrait
|
||||
/**
|
||||
* @return MessageEvent[]
|
||||
*/
|
||||
public static function getNotifierEvents(string $transportName = null): array
|
||||
public static function getNotifierEvents(?string $transportName = null): array
|
||||
{
|
||||
return self::getNotificationEvents()->getEvents($transportName);
|
||||
}
|
||||
|
||||
public static function getNotifierEvent(int $index = 0, string $transportName = null): ?MessageEvent
|
||||
public static function getNotifierEvent(int $index = 0, ?string $transportName = null): ?MessageEvent
|
||||
{
|
||||
return self::getNotifierEvents($transportName)[$index] ?? null;
|
||||
}
|
||||
@@ -78,12 +78,12 @@ trait NotificationAssertionsTrait
|
||||
/**
|
||||
* @return MessageInterface[]
|
||||
*/
|
||||
public static function getNotifierMessages(string $transportName = null): array
|
||||
public static function getNotifierMessages(?string $transportName = null): array
|
||||
{
|
||||
return self::getNotificationEvents()->getMessages($transportName);
|
||||
}
|
||||
|
||||
public static function getNotifierMessage(int $index = 0, string $transportName = null): ?MessageInterface
|
||||
public static function getNotifierMessage(int $index = 0, ?string $transportName = null): ?MessageInterface
|
||||
{
|
||||
return self::getNotifierMessages($transportName)[$index] ?? null;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class TestBrowserToken extends AbstractToken
|
||||
{
|
||||
private string $firewallName;
|
||||
|
||||
public function __construct(array $roles = [], UserInterface $user = null, string $firewallName = 'main')
|
||||
public function __construct(array $roles = [], ?UserInterface $user = null, string $firewallName = 'main')
|
||||
{
|
||||
parent::__construct($roles);
|
||||
|
||||
|
||||
@@ -71,15 +71,11 @@ class TestContainer extends Container
|
||||
$container = $this->getPublicContainer();
|
||||
$renamedId = $this->renamedIds[$id] ?? $id;
|
||||
|
||||
try {
|
||||
if (!$this->getPrivateContainer()->has($renamedId)) {
|
||||
$container->set($renamedId, $service);
|
||||
} catch (InvalidArgumentException $e) {
|
||||
if (!str_starts_with($e->getMessage(), "The \"$renamedId\" service is private")) {
|
||||
throw $e;
|
||||
}
|
||||
if (isset($container->privates[$renamedId])) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" service is already initialized, you cannot replace it.', $id));
|
||||
}
|
||||
} elseif (isset($container->privates[$renamedId])) {
|
||||
throw new InvalidArgumentException(\sprintf('The "%s" service is already initialized, you cannot replace it.', $id));
|
||||
} else {
|
||||
$container->privates[$renamedId] = $service;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ abstract class WebTestCase extends KernelTestCase
|
||||
protected static function createClient(array $options = [], array $server = []): KernelBrowser
|
||||
{
|
||||
if (static::$booted) {
|
||||
throw new \LogicException(sprintf('Booting the kernel before calling "%s()" is not supported, the kernel should only be booted once.', __METHOD__));
|
||||
throw new \LogicException(\sprintf('Booting the kernel before calling "%s()" is not supported, the kernel should only be booted once.', __METHOD__));
|
||||
}
|
||||
|
||||
$kernel = static::bootKernel($options);
|
||||
|
||||
Reference in New Issue
Block a user