|
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 | {
|
@@ -358,7 +359,10 @@ public function dataRegisteredSniffCodes()
|
358 | 359 | public function testSettingProperties($sniffClass, $propertyName, $expectedValue)
|
359 | 360 | {
|
360 | 361 | $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs);
|
361 |
| - $this->assertObjectHasAttribute($propertyName, self::$ruleset->sniffs[$sniffClass]); |
| 362 | + |
| 363 | + $hasProperty = (new ReflectionObject(self::$ruleset->sniffs[$sniffClass]))->hasProperty($propertyName); |
| 364 | + $errorMsg = sprintf('Property %s does not exist on sniff class %s', $propertyName, $sniffClass); |
| 365 | + $this->assertTrue($hasProperty, $errorMsg); |
362 | 366 |
|
363 | 367 | $actualValue = self::$ruleset->sniffs[$sniffClass]->$propertyName;
|
364 | 368 | $this->assertSame($expectedValue, $actualValue);
|
@@ -449,7 +453,10 @@ public function testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFail
|
449 | 453 | $this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs, 'Sniff class '.$sniffClass.' not listed in registered sniffs');
|
450 | 454 |
|
451 | 455 | $sniffObject = self::$ruleset->sniffs[$sniffClass];
|
452 |
| - $this->assertObjectNotHasAttribute($propertyName, $sniffObject, 'Property '.$propertyName.' registered for sniff '.$sniffClass.' which does not support it'); |
| 456 | + |
| 457 | + $hasProperty = (new ReflectionObject(self::$ruleset->sniffs[$sniffClass]))->hasProperty($propertyName); |
| 458 | + $errorMsg = sprintf('Property %s registered for sniff %s which does not support it', $propertyName, $sniffClass); |
| 459 | + $this->assertFalse($hasProperty, $errorMsg); |
453 | 460 |
|
454 | 461 | }//end testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails()
|
455 | 462 |
|
|
0 commit comments