2
2
3
3
declare (strict_types=1 );
4
4
5
- namespace Yii \PHPStan \Tests ;
5
+ namespace Yii2 \ Extensions \PHPStan \Tests ;
6
6
7
7
use InvalidArgumentException ;
8
8
use PhpParser \Node \Scalar \String_ ;
12
12
use SplFileInfo ;
13
13
use SplObjectStorage ;
14
14
use SplStack ;
15
- use Yii \PHPStan \ServiceMap ;
16
- use Yii \PHPStan \Tests \Yii \MyActiveRecord ;
15
+ use Yii2 \ Extensions \PHPStan \ServiceMap ;
16
+ use Yii2 \ Extensions \PHPStan \Tests \Yii \MyActiveRecord ;
17
17
18
18
final class ServiceMapTest extends TestCase
19
19
{
@@ -44,7 +44,9 @@ public function testThrowExceptionWhenServiceHasUnsupportedType(): void
44
44
$ this ->expectException (RuntimeException::class);
45
45
$ this ->expectExceptionMessage ('Unsupported service definition for unsupported-type ' );
46
46
47
- new ServiceMap (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-type.php ' );
47
+ new ServiceMap (
48
+ __DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-type.php '
49
+ );
48
50
}
49
51
50
52
/**
@@ -55,7 +57,9 @@ public function testThrowExceptionWhenServiceHasUnsupportedArray(): void
55
57
$ this ->expectException (RuntimeException::class);
56
58
$ this ->expectExceptionMessage ('Cannot guess service definition for unsupported-array ' );
57
59
58
- new ServiceMap (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-array.php ' );
60
+ new ServiceMap (
61
+ __DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'yii-config-invalid-unsupported-array.php '
62
+ );
59
63
}
60
64
61
65
/**
@@ -66,7 +70,9 @@ public function testThrowExceptionWhenComponentHasInvalidValue(): void
66
70
$ this ->expectException (RuntimeException::class);
67
71
$ this ->expectExceptionMessage ('Invalid value for component with id customComponent. Expected object or array. ' );
68
72
69
- new ServiceMap (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'yii-config-invalid-component.php ' );
73
+ new ServiceMap (
74
+ __DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'yii-config-invalid-component.php '
75
+ );
70
76
}
71
77
72
78
/**
@@ -76,18 +82,42 @@ public function testItLoadsServicesAndComponents(): void
76
82
{
77
83
$ serviceMap = new ServiceMap (__DIR__ . DIRECTORY_SEPARATOR . 'assets ' . DIRECTORY_SEPARATOR . 'yii-config-valid.php ' );
78
84
79
- self ::assertSame (MyActiveRecord::class, $ serviceMap ->getServiceClassFromNode (new String_ ('singleton-string ' )));
80
- self ::assertSame (MyActiveRecord::class, $ serviceMap ->getServiceClassFromNode (new String_ (MyActiveRecord::class)));
81
- self ::assertSame (SplStack::class, $ serviceMap ->getServiceClassFromNode (new String_ ('singleton-closure ' )));
82
- self ::assertSame (SplObjectStorage::class, $ serviceMap ->getServiceClassFromNode (new String_ ('singleton-service ' )));
83
- self ::assertSame (SplFileInfo::class, $ serviceMap ->getServiceClassFromNode (new String_ ('singleton-nested-service-class ' )));
84
-
85
- self ::assertSame (SplStack::class, $ serviceMap ->getServiceClassFromNode (new String_ ('closure ' )));
86
- self ::assertSame (SplObjectStorage::class, $ serviceMap ->getServiceClassFromNode (new String_ ('service ' )));
87
- self ::assertSame (SplFileInfo::class, $ serviceMap ->getServiceClassFromNode (new String_ ('nested-service-class ' )));
88
-
89
- self ::assertSame (MyActiveRecord::class, $ serviceMap ->getComponentClassById ('customComponent ' ));
90
- self ::assertSame (MyActiveRecord::class, $ serviceMap ->getComponentClassById ('customInitializedComponent ' ));
85
+ $ this ->assertSame (
86
+ MyActiveRecord::class,
87
+ $ serviceMap ->getServiceClassFromNode (new String_ ('singleton-string ' )),
88
+ );
89
+ $ this ->assertSame (
90
+ MyActiveRecord::class,
91
+ $ serviceMap ->getServiceClassFromNode (new String_ (MyActiveRecord::class)),
92
+ );
93
+ $ this ->assertSame (
94
+ SplStack::class,
95
+ $ serviceMap ->getServiceClassFromNode (new String_ ('singleton-closure ' )),
96
+ );
97
+ $ this ->assertSame (
98
+ SplObjectStorage::class,
99
+ $ serviceMap ->getServiceClassFromNode (new String_ ('singleton-service ' )),
100
+ );
101
+ $ this ->assertSame (
102
+ SplFileInfo::class,
103
+ $ serviceMap ->getServiceClassFromNode (new String_ ('singleton-nested-service-class ' )),
104
+ );
105
+
106
+ $ this ->assertSame (
107
+ SplStack::class,
108
+ $ serviceMap ->getServiceClassFromNode (new String_ ('closure ' )),
109
+ );
110
+ $ this ->assertSame (
111
+ SplObjectStorage::class,
112
+ $ serviceMap ->getServiceClassFromNode (new String_ ('service ' )),
113
+ );
114
+ $ this ->assertSame (
115
+ SplFileInfo::class,
116
+ $ serviceMap ->getServiceClassFromNode (new String_ ('nested-service-class ' )),
117
+ );
118
+
119
+ $ this ->assertSame (MyActiveRecord::class, $ serviceMap ->getComponentClassById ('customComponent ' ));
120
+ $ this ->assertSame (MyActiveRecord::class, $ serviceMap ->getComponentClassById ('customInitializedComponent ' ));
91
121
}
92
122
93
123
/**
0 commit comments