Skip to content

Commit 3dacef9

Browse files
committed
Merge remote-tracking branch 'origin/MC-33069-CE-7' into MC-33069
2 parents 9a3ae42 + 7c8fb36 commit 3dacef9

File tree

1 file changed

+23
-25
lines changed

1 file changed

+23
-25
lines changed

dev/tests/integration/framework/tests/unit/testsuite/Magento/Test/Workaround/Cleanup/TestCasePropertiesTest.php

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@ class TestCasePropertiesTest extends \PHPUnit\Framework\TestCase
1515
* @var array
1616
*/
1717
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],
2928
];
3029

3130
public function testEndTestSuiteDestruct()
@@ -39,26 +38,25 @@ public function testEndTestSuiteDestruct()
3938
/** @var $testClass \Magento\Test\Workaround\Cleanup\TestCasePropertiesTest\DummyTestCase */
4039
$testClass = $testSuite->testAt(0);
4140

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);
5149
}
5250
}
5351

5452
$clearProperties = new \Magento\TestFramework\Workaround\Cleanup\TestCaseProperties();
5553
$clearProperties->endTestSuite($testSuite);
5654

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);
6260
}
6361
}
6462
}

0 commit comments

Comments
 (0)