|
12 | 12 | use PHP_CodeSniffer\Config;
|
13 | 13 | use PHP_CodeSniffer\Ruleset;
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
| 15 | +use ReflectionObject; |
15 | 16 |
|
16 | 17 | class RuleInclusionTest extends TestCase
|
17 | 18 | {
|
@@ -336,7 +337,10 @@ public function dataRegisteredSniffCodes()
|
336 | 337 | public function testSettingProperties($sniffClass, $propertyName, $expectedValue)
|
337 | 338 | {
|
338 | 339 | $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs);
|
339 |
| - $this->assertObjectHasAttribute($propertyName, self::$ruleset->sniffs[$sniffClass]); |
| 340 | + |
| 341 | + $hasProperty = (new ReflectionObject(self::$ruleset->sniffs[$sniffClass]))->hasProperty($propertyName); |
| 342 | + $errorMsg = sprintf('Property %s does not exist on sniff class %s', $propertyName, $sniffClass); |
| 343 | + $this->assertTrue($hasProperty, $errorMsg); |
340 | 344 |
|
341 | 345 | $actualValue = self::$ruleset->sniffs[$sniffClass]->$propertyName;
|
342 | 346 | $this->assertSame($expectedValue, $actualValue);
|
@@ -427,7 +431,10 @@ public function testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFail
|
427 | 431 | $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs, 'Sniff class '.$sniffClass.' not listed in registered sniffs');
|
428 | 432 |
|
429 | 433 | $sniffObject = self::$ruleset->sniffs[$sniffClass];
|
430 |
| - $this->assertObjectNotHasAttribute($propertyName, $sniffObject, 'Property '.$propertyName.' registered for sniff '.$sniffClass.' which does not support it'); |
| 434 | + |
| 435 | + $hasProperty = (new ReflectionObject(self::$ruleset->sniffs[$sniffClass]))->hasProperty($propertyName); |
| 436 | + $errorMsg = sprintf('Property %s registered for sniff %s which does not support it', $propertyName, $sniffClass); |
| 437 | + $this->assertFalse($hasProperty, $errorMsg); |
431 | 438 |
|
432 | 439 | }//end testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails()
|
433 | 440 |
|
|
0 commit comments