|
26 | 26 | abstract class WebTestCase extends SymfonyWebTestCase
|
27 | 27 | {
|
28 | 28 | protected static ?EntityManagerInterface $em = null;
|
29 |
| - |
30 | 29 | protected static KernelBrowser $client;
|
31 |
| - |
32 | 30 | private ?AbstractFixture $fixture = null;
|
33 |
| - |
34 | 31 | protected static ?string $authUser = null;
|
35 |
| - |
36 | 32 | protected static ?string $authPw = null;
|
37 |
| - |
38 |
| - /** @var ContainerInterface */ |
39 |
| - protected static $container; |
| 33 | + protected static ?ContainerInterface $container = null; |
40 | 34 |
|
41 | 35 | protected function setUp(): void
|
42 | 36 | {
|
@@ -64,15 +58,13 @@ protected function setUp(): void
|
64 | 58 |
|
65 | 59 | protected function tearDown(): void
|
66 | 60 | {
|
67 |
| - if (null !== self::$em) { |
68 |
| - self::$em->getConnection()->close(); |
69 |
| - } |
| 61 | + self::$em?->getConnection()->close(); |
70 | 62 | parent::tearDown();
|
71 | 63 | }
|
72 | 64 |
|
73 | 65 | /**
|
74 | 66 | * Save request output and show it in the browser
|
75 |
| - * See http://giorgiocefaro.com/blog/test-symfony-and-automatically-open-the-browser-with-the-response-content |
| 67 | + * See https://web.archive.org/web/20190205012632/https://giorgiocefaro.com/blog/test-symfony-and-automatically-open-the-browser-with-the-response-content |
76 | 68 | * You can define a "domain" parameter with the current domain of your app.
|
77 | 69 | */
|
78 | 70 | protected static function saveOutput(bool $delete = true): void
|
@@ -104,7 +96,7 @@ protected static function saveOutput(bool $delete = true): void
|
104 | 96 | *
|
105 | 97 | * @throws \InvalidArgumentException
|
106 | 98 | */
|
107 |
| - protected static function login( string $username = '[email protected]', string $firewall = null, string $service = null): void |
| 99 | + protected static function login( string $username = '[email protected]', ?string $firewall = null, ?string $service = null): void |
108 | 100 | {
|
109 | 101 | $service ??= static::$container->getParameter('beelab_test.user_service');
|
110 | 102 | $object = static::$container->get($service);
|
@@ -180,13 +172,13 @@ protected static function getTxtFile(string $file = '0'): UploadedFile
|
180 | 172 | *
|
181 | 173 | * @param array<int, string> $fixtures e.g. ['UserData', 'OrderData']
|
182 | 174 | *
|
183 |
| - * @throws \Doctrine\DBAL\DBALException |
| 175 | + * @throws \Doctrine\DBAL\Exception |
184 | 176 | * @throws \InvalidArgumentException
|
185 | 177 | */
|
186 | 178 | protected function loadFixtures(
|
187 | 179 | array $fixtures,
|
188 | 180 | string $namespace = 'App\\DataFixtures\\ORM\\',
|
189 |
| - string $managerService = null, |
| 181 | + ?string $managerService = null, |
190 | 182 | bool $append = false,
|
191 | 183 | ): void {
|
192 | 184 | if (null !== $managerService) {
|
@@ -238,7 +230,7 @@ protected static function commandTest(
|
238 | 230 | Command $command,
|
239 | 231 | array $arguments = [],
|
240 | 232 | array $otherCommands = [],
|
241 |
| - array $inputs = null, |
| 233 | + ?array $inputs = null, |
242 | 234 | ): string {
|
243 | 235 | $application = new Application(self::$client->getKernel());
|
244 | 236 | $application->add($command);
|
@@ -307,15 +299,15 @@ protected static function setSessionException(string $msg = 'error...'): void
|
307 | 299 | self::$client->getCookieJar()->set($cookie);
|
308 | 300 | }
|
309 | 301 |
|
310 |
| - protected static function clickLinkByData(string $dataName, string $parent = null): Crawler |
| 302 | + protected static function clickLinkByData(string $dataName, ?string $parent = null): Crawler |
311 | 303 | {
|
312 | 304 | $selector = (null === $parent ? '' : $parent.' ').'a[data-'.$dataName.']';
|
313 | 305 | $linkNode = self::$client->getCrawler()->filter($selector);
|
314 | 306 |
|
315 | 307 | return self::$client->click($linkNode->link());
|
316 | 308 | }
|
317 | 309 |
|
318 |
| - protected static function clickLinkBySelectorText(string $linkText, string $parent = null): Crawler |
| 310 | + protected static function clickLinkBySelectorText(string $linkText, ?string $parent = null): Crawler |
319 | 311 | {
|
320 | 312 | $selector = (null === $parent ? '' : $parent.' ').'a:contains("'.$linkText.'")';
|
321 | 313 | $linkNode = self::$client->getCrawler()->filter($selector);
|
|
0 commit comments