Skip to content

Commit ed7aeb7

Browse files
committed
Refactor tests
1 parent d4b1163 commit ed7aeb7

7 files changed

+98
-186
lines changed

tests/PHPStan/Rules/Properties/AccessPropertiesFromArrayRuleTest.php

-45
This file was deleted.

tests/PHPStan/Rules/Properties/AccessPropertiesFromVariableRuleTest.php

-33
This file was deleted.

tests/PHPStan/Rules/Properties/AccessPropertiesInAssignRuleTest.php

+32
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,36 @@ public function testRule(): void
3030
]);
3131
}
3232

33+
public function testRuleExpressionNames(): void
34+
{
35+
$this->analyse([__DIR__ . '/data/properties-from-variable-into-object.php'], [
36+
[
37+
'Access to an undefined property PropertiesFromVariableIntoObject\Foo::$noop.',
38+
26,
39+
],
40+
]);
41+
}
42+
43+
public function testRuleExpressionNames2(): void
44+
{
45+
$this->analyse([__DIR__ . '/data/properties-from-array-into-object.php'], [
46+
[
47+
'Access to an undefined property PropertiesFromArrayIntoObject\Foo::$noop.',
48+
42,
49+
],
50+
[
51+
'Access to an undefined property PropertiesFromArrayIntoObject\Foo::$noop.',
52+
54,
53+
],
54+
[
55+
'Access to an undefined property PropertiesFromArrayIntoObject\Foo::$noop.',
56+
69,
57+
],
58+
[
59+
'Access to an undefined property PropertiesFromArrayIntoObject\Foo::$noop.',
60+
110,
61+
],
62+
]);
63+
}
64+
3365
}

tests/PHPStan/Rules/Properties/AccessStaticPropertiesFromArrayRuleTest.php

-34
This file was deleted.

tests/PHPStan/Rules/Properties/AccessStaticPropertiesRuleTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,14 @@ public function testClassExists(): void
186186
$this->analyse([__DIR__ . '/data/static-properties-class-exists.php'], []);
187187
}
188188

189+
public function testRuleExpressionNames(): void
190+
{
191+
$this->analyse([__DIR__ . '/data/properties-from-array-into-static-object.php'], [
192+
[
193+
'Cannot access static property $noop on PropertiesFromArrayIntoStaticObject\Foo.',
194+
29,
195+
],
196+
]);
197+
}
198+
189199
}

tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesFromArrayRuleTest.php

-74
This file was deleted.

tests/PHPStan/Rules/Properties/TypesAssignedToPropertiesRuleTest.php

+56
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,60 @@ public function testBug1216(): void
9191
]);
9292
}
9393

94+
public function testTypesAssignedToPropertiesExpressionNames(): void
95+
{
96+
$this->analyse([__DIR__ . '/data/properties-from-array-into-object.php'], [
97+
[
98+
'Property PropertiesFromArrayIntoObject\Foo::$lall (int) does not accept string.',
99+
42,
100+
],
101+
[
102+
'Property PropertiesFromArrayIntoObject\Foo::$lall (int) does not accept string.',
103+
54,
104+
],
105+
[
106+
'Property PropertiesFromArrayIntoObject\Foo::$test (int|null) does not accept stdClass.',
107+
66,
108+
],
109+
[
110+
'Property PropertiesFromArrayIntoObject\Foo::$lall (int) does not accept string.',
111+
69,
112+
],
113+
[
114+
'Property PropertiesFromArrayIntoObject\Foo::$foo (string) does not accept int.',
115+
73,
116+
],
117+
[
118+
'Property PropertiesFromArrayIntoObject\Foo::$foo (string) does not accept float.',
119+
83,
120+
],
121+
[
122+
'Property PropertiesFromArrayIntoObject\Foo::$lall (int) does not accept string.',
123+
110,
124+
],
125+
[
126+
'Property PropertiesFromArrayIntoObject\FooBar::$foo (string) does not accept float.',
127+
147,
128+
],
129+
]);
130+
}
131+
132+
public function testTypesAssignedToStaticPropertiesExpressionNames(): void
133+
{
134+
$this->analyse([__DIR__ . '/data/properties-from-array-into-static-object.php'], [
135+
[
136+
'Static property PropertiesFromArrayIntoStaticObject\Foo::$lall (stdClass|null) does not accept string.',
137+
29,
138+
],
139+
[
140+
'Static property PropertiesFromArrayIntoStaticObject\Foo::$foo (string) does not accept float.',
141+
36,
142+
],
143+
[
144+
'Static property PropertiesFromArrayIntoStaticObject\FooBar::$foo (string) does not accept float.',
145+
72,
146+
],
147+
]);
148+
}
149+
94150
}

0 commit comments

Comments
 (0)