Skip to content

Commit 8ae41d1

Browse files
committed
Fix tests
1 parent e75b245 commit 8ae41d1

24 files changed

+62
-31
lines changed

phpcs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@
5454
</properties>
5555
</rule>
5656
<exclude-pattern>tests/tmp</exclude-pattern>
57-
<exclude-pattern>tests/Symfony/ExampleContainer.php</exclude-pattern>
57+
<exclude-pattern>tests/*/data</exclude-pattern>
5858
</ruleset>

phpstan.neon

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,4 @@ parameters:
1111
- tests/tmp/*
1212
- tests/*/Example*.php
1313
- tests/*/console_application_loader.php
14-
- tests/*/envelope_all.php
15-
- tests/*/header_bag_get.php
16-
- tests/*/input_bag.php
17-
- tests/*/kernel_interface.php
18-
- tests/*/request_get_content.php
19-
- tests/*/request_get_session.php
20-
- tests/*/serializer.php
21-
- tests/*/denormalizer.php
14+
- tests/*/data/*

tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleFakeTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ protected function getRule(): Rule
1919

2020
public function testGetPrivateService(): void
2121
{
22+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
23+
self::markTestSkipped();
24+
}
2225
$this->analyse(
2326
[
2427
__DIR__ . '/ExampleController.php',
@@ -29,6 +32,9 @@ public function testGetPrivateService(): void
2932

3033
public function testGetPrivateServiceInAbstractController(): void
3134
{
35+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
36+
self::markTestSkipped();
37+
}
3238
$this->analyse(
3339
[
3440
__DIR__ . '/ExampleAbstractController.php',
@@ -43,6 +49,10 @@ public function testGetPrivateServiceInLegacyServiceSubscriber(): void
4349
self::markTestSkipped('The test needs Symfony\Component\DependencyInjection\ServiceSubscriberInterface class.');
4450
}
4551

52+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
53+
self::markTestSkipped();
54+
}
55+
4656
$this->analyse(
4757
[
4858
__DIR__ . '/ExampleLegacyServiceSubscriber.php',
@@ -59,6 +69,10 @@ public function testGetPrivateServiceInServiceSubscriber(): void
5969
self::markTestSkipped('The test needs Symfony\Contracts\Service\ServiceSubscriberInterface class.');
6070
}
6171

72+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
73+
self::markTestSkipped();
74+
}
75+
6276
$this->analyse(
6377
[
6478
__DIR__ . '/ExampleServiceSubscriber.php',

tests/Rules/Symfony/ContainerInterfacePrivateServiceRuleTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ protected function getRule(): Rule
1919

2020
public function testGetPrivateService(): void
2121
{
22+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
23+
self::markTestSkipped();
24+
}
2225
$this->analyse(
2326
[
2427
__DIR__ . '/ExampleController.php',
@@ -38,6 +41,10 @@ public function testGetPrivateServiceInLegacyServiceSubscriber(): void
3841
self::markTestSkipped('The test needs Symfony\Component\DependencyInjection\ServiceSubscriberInterface class.');
3942
}
4043

44+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
45+
self::markTestSkipped();
46+
}
47+
4148
$this->analyse(
4249
[
4350
__DIR__ . '/ExampleLegacyServiceSubscriber.php',
@@ -54,6 +61,10 @@ public function testGetPrivateServiceInServiceSubscriber(): void
5461
self::markTestSkipped('The test needs Symfony\Contracts\Service\ServiceSubscriberInterface class.');
5562
}
5663

64+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
65+
self::markTestSkipped();
66+
}
67+
5768
$this->analyse(
5869
[
5970
__DIR__ . '/ExampleServiceSubscriber.php',

tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleFakeTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use PHPStan\Symfony\XmlServiceMapFactory;
88
use PHPStan\Testing\RuleTestCase;
99
use PHPStan\Type\Symfony\ServiceTypeSpecifyingExtension;
10-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
1110

1211
/**
1312
* @extends RuleTestCase<ContainerInterfaceUnknownServiceRule>
@@ -26,12 +25,15 @@ protected function getRule(): Rule
2625
protected function getMethodTypeSpecifyingExtensions(): array
2726
{
2827
return [
29-
new ServiceTypeSpecifyingExtension(Controller::class, new Standard()),
28+
new ServiceTypeSpecifyingExtension('Symfony\Bundle\FrameworkBundle\Controller\Controller', new Standard()),
3029
];
3130
}
3231

3332
public function testGetPrivateService(): void
3433
{
34+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
35+
self::markTestSkipped();
36+
}
3537
$this->analyse(
3638
[
3739
__DIR__ . '/ExampleController.php',
@@ -42,6 +44,10 @@ public function testGetPrivateService(): void
4244

4345
public function testGetPrivateServiceInAbstractController(): void
4446
{
47+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
48+
self::markTestSkipped();
49+
}
50+
4551
$this->analyse(
4652
[
4753
__DIR__ . '/ExampleAbstractController.php',

tests/Rules/Symfony/ContainerInterfaceUnknownServiceRuleTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use PHPStan\Testing\RuleTestCase;
99
use PHPStan\Type\Symfony\ServiceTypeSpecifyingExtension;
1010
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
11-
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
1211

1312
/**
1413
* @extends RuleTestCase<ContainerInterfaceUnknownServiceRule>
@@ -27,13 +26,16 @@ protected function getRule(): Rule
2726
protected function getMethodTypeSpecifyingExtensions(): array
2827
{
2928
return [
30-
new ServiceTypeSpecifyingExtension(Controller::class, new Standard()),
29+
new ServiceTypeSpecifyingExtension('Symfony\Bundle\FrameworkBundle\Controller\Controller', new Standard()),
3130
new ServiceTypeSpecifyingExtension(AbstractController::class, new Standard()),
3231
];
3332
}
3433

3534
public function testGetPrivateService(): void
3635
{
36+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
37+
self::markTestSkipped();
38+
}
3739
$this->analyse(
3840
[
3941
__DIR__ . '/ExampleController.php',
@@ -49,6 +51,10 @@ public function testGetPrivateService(): void
4951

5052
public function testGetPrivateServiceInAbstractController(): void
5153
{
54+
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
55+
self::markTestSkipped();
56+
}
57+
5258
$this->analyse(
5359
[
5460
__DIR__ . '/ExampleAbstractController.php',

tests/Type/Symfony/ExtensionTest.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,36 @@
99
class ExtensionTest extends TypeInferenceTestCase
1010
{
1111

12+
/** @return mixed[] */
1213
public function dataFileAsserts(): iterable
1314
{
14-
yield from $this->gatherAssertTypes(__DIR__ . '/envelope_all.php');
15-
yield from $this->gatherAssertTypes(__DIR__ . '/header_bag_get.php');
15+
yield from $this->gatherAssertTypes(__DIR__ . '/data/envelope_all.php');
16+
yield from $this->gatherAssertTypes(__DIR__ . '/data/header_bag_get.php');
1617

1718
if (class_exists('Symfony\Component\HttpFoundation\InputBag')) {
18-
yield from $this->gatherAssertTypes(__DIR__ . '/input_bag.php');
19+
yield from $this->gatherAssertTypes(__DIR__ . '/data/input_bag.php');
1920
}
2021

21-
yield from $this->gatherAssertTypes(__DIR__ . '/Config/tree_builder.php');
22-
yield from $this->gatherAssertTypes(__DIR__ . '/ExampleBaseCommand.php');
23-
yield from $this->gatherAssertTypes(__DIR__ . '/ExampleOptionCommand.php');
24-
yield from $this->gatherAssertTypes(__DIR__ . '/kernel_interface.php');
25-
yield from $this->gatherAssertTypes(__DIR__ . '/request_get_content.php');
26-
22+
yield from $this->gatherAssertTypes(__DIR__ . '/data/tree_builder.php');
23+
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleBaseCommand.php');
24+
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleOptionCommand.php');
25+
yield from $this->gatherAssertTypes(__DIR__ . '/data/kernel_interface.php');
26+
yield from $this->gatherAssertTypes(__DIR__ . '/data/request_get_content.php');
2727

2828
$ref = new ReflectionMethod(Request::class, 'getSession');
2929
$doc = (string) $ref->getDocComment();
3030
if (strpos($doc, '@return SessionInterface|null') !== false) {
31-
yield from $this->gatherAssertTypes(__DIR__ . '/request_get_session_null.php');
31+
yield from $this->gatherAssertTypes(__DIR__ . '/data/request_get_session_null.php');
3232
} else {
33-
yield from $this->gatherAssertTypes(__DIR__ . '/request_get_session.php');
33+
yield from $this->gatherAssertTypes(__DIR__ . '/data/request_get_session.php');
3434
}
3535

36-
yield from $this->gatherAssertTypes(__DIR__ . '/serializer.php');
37-
yield from $this->gatherAssertTypes(__DIR__ . '/denormalizer.php');
38-
3936
if (class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
40-
yield from $this->gatherAssertTypes(__DIR__ . '/ExampleController.php');
37+
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleController.php');
4138
}
39+
40+
yield from $this->gatherAssertTypes(__DIR__ . '/data/serializer.php');
41+
yield from $this->gatherAssertTypes(__DIR__ . '/data/denormalizer.php');
4242
}
4343

4444
/**
@@ -64,5 +64,4 @@ public static function getAdditionalConfigFiles(): array
6464
];
6565
}
6666

67-
6867
}

tests/Type/Symfony/ExtensionTestWithoutContainer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
class ExtensionTestWithoutContainer extends TypeInferenceTestCase
88
{
99

10+
/** @return mixed[] */
1011
public function dataFileAsserts(): iterable
1112
{
12-
yield from $this->gatherAssertTypes(__DIR__ . '/ExampleControllerWithoutContainer.php');
13+
yield from $this->gatherAssertTypes(__DIR__ . '/data/ExampleControllerWithoutContainer.php');
1314
}
1415

1516
/**
@@ -25,7 +26,7 @@ public function testFileAsserts(
2526
): void
2627
{
2728
if (!class_exists('Symfony\Bundle\FrameworkBundle\Controller\Controller')) {
28-
$this->markTestSkipped('Needs class Symfony\Bundle\FrameworkBundle\Controller\Controller');
29+
self::markTestSkipped('Needs class Symfony\Bundle\FrameworkBundle\Controller\Controller');
2930
}
3031
$this->assertFileAsserts($assertType, $file, ...$args);
3132
}
@@ -36,4 +37,5 @@ public static function getAdditionalConfigFiles(): array
3637
__DIR__ . '/../../../extension.neon',
3738
];
3839
}
40+
3941
}

0 commit comments

Comments
 (0)