@@ -15,17 +15,16 @@ class TestCasePropertiesTest extends \PHPUnit\Framework\TestCase
15
15
* @var array
16
16
*/
17
17
protected $ _fixtureProperties = [
18
- ['name ' => 'testPublic ' , 'is_static ' => false ],
19
- ['name ' => '_testPrivate ' , 'is_static ' => false ],
20
- ['name ' => '_testPropertyBoolean ' , 'is_static ' => false ],
21
- ['name ' => '_testPropertyInteger ' , 'is_static ' => false ],
22
- ['name ' => '_testPropertyFloat ' , 'is_static ' => false ],
23
- ['name ' => '_testPropertyString ' , 'is_static ' => false ],
24
- ['name ' => '_testPropertyArray ' , 'is_static ' => false ],
25
- ['name ' => '_testPropertyObject ' , 'is_static ' => false ],
26
- ['name ' => 'testPublicStatic ' , 'is_static ' => true ],
27
- ['name ' => '_testProtectedStatic ' , 'is_static ' => true ],
28
- ['name ' => '_testPrivateStatic ' , 'is_static ' => true ],
18
+ 'testPublic ' => ['name ' => 'testPublic ' , 'is_static ' => false ],
19
+ '_testPrivate ' => ['name ' => '_testPrivate ' , 'is_static ' => false ],
20
+ '_testPropertyBoolean ' => ['name ' => '_testPropertyBoolean ' , 'is_static ' => false ],
21
+ '_testPropertyInteger ' => ['name ' => '_testPropertyInteger ' , 'is_static ' => false ],
22
+ '_testPropertyFloat ' => ['name ' => '_testPropertyFloat ' , 'is_static ' => false ],
23
+ '_testPropertyString ' => ['name ' => '_testPropertyString ' , 'is_static ' => false ],
24
+ '_testPropertyArray ' => ['name ' => '_testPropertyArray ' , 'is_static ' => false ],
25
+ 'testPublicStatic ' => ['name ' => 'testPublicStatic ' , 'is_static ' => true ],
26
+ '_testProtectedStatic ' => ['name ' => '_testProtectedStatic ' , 'is_static ' => true ],
27
+ '_testPrivateStatic ' => ['name ' => '_testPrivateStatic ' , 'is_static ' => true ],
29
28
];
30
29
31
30
public function testEndTestSuiteDestruct ()
@@ -39,26 +38,25 @@ public function testEndTestSuiteDestruct()
39
38
/** @var $testClass \Magento\Test\Workaround\Cleanup\TestCasePropertiesTest\DummyTestCase */
40
39
$ testClass = $ testSuite ->testAt (0 );
41
40
42
- $ propertyObjectMock = $ this ->createPartialMock (\stdClass::class, ['__destruct ' ]);
43
- $ propertyObjectMock ->expects ($ this ->atLeastOnce ())->method ('__destruct ' );
44
- $ testClass ->setPropertyObject ($ propertyObjectMock );
45
-
46
- foreach ($ this ->_fixtureProperties as $ property ) {
47
- if ($ property ['is_static ' ]) {
48
- $ this ->assertAttributeNotEmpty ($ property ['name ' ], get_class ($ testClass ));
49
- } else {
50
- $ this ->assertAttributeNotEmpty ($ property ['name ' ], $ testClass );
41
+ $ reflectionClass = new \ReflectionClass ($ testClass );
42
+ $ classProperties = $ reflectionClass ->getProperties ();
43
+ $ fixturePropertiesNames = array_keys ($ this ->_fixtureProperties );
44
+ foreach ($ classProperties as $ property ) {
45
+ if (in_array ($ property ->getName (), $ fixturePropertiesNames )) {
46
+ $ property ->setAccessible (true );
47
+ $ value = $ property ->getValue ($ testClass );
48
+ $ this ->assertNotNull ($ value );
51
49
}
52
50
}
53
51
54
52
$ clearProperties = new \Magento \TestFramework \Workaround \Cleanup \TestCaseProperties ();
55
53
$ clearProperties ->endTestSuite ($ testSuite );
56
54
57
- foreach ($ this -> _fixtureProperties as $ property ) {
58
- if ($ property[ ' is_static ' ] ) {
59
- $ this -> assertAttributeEmpty ( $ property [ ' name ' ], get_class ( $ testClass ) );
60
- } else {
61
- $ this ->assertAttributeEmpty ( $ property [ ' name ' ], $ testClass );
55
+ foreach ($ classProperties as $ property ) {
56
+ if (in_array ( $ property-> getName (), $ fixturePropertiesNames ) ) {
57
+ $ property -> setAccessible ( true );
58
+ $ value = $ property -> getValue ( $ testClass );
59
+ $ this ->assertNull ( $ value );
62
60
}
63
61
}
64
62
}
0 commit comments