Skip to content

Commit b4edac2

Browse files
committed
RuleInclusion*Test: remove a few redundant assertions
These assertions are checking whether explicitly declared properties exist, which is redundant. Removing the assertions does not diminish the value of the tests as there are follow-up assertions testing the value of the properties. Removing the assertions also gets rid of a warning thrown in PHPUnit 9.6.x about the `assertObjectHasAttribute()` assertion being removed in PHPUnit 10.0. Note: PHPUnit 10.1.0 adds these assertions back again, but under a different name `assertObjectHasProperty()`.
1 parent b82b84d commit b4edac2

File tree

3 files changed

+0
-5
lines changed

3 files changed

+0
-5
lines changed

tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public function tearDown()
9191
public function testLinuxStylePathRuleInclusion()
9292
{
9393
// Test that the sniff is correctly registered.
94-
$this->assertObjectHasAttribute('sniffCodes', $this->ruleset);
9594
$this->assertCount(1, $this->ruleset->sniffCodes);
9695
$this->assertArrayHasKey('Generic.Formatting.SpaceAfterNot', $this->ruleset->sniffCodes);
9796
$this->assertSame(

tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public function tearDown()
9292
public function testWindowsStylePathRuleInclusion()
9393
{
9494
// Test that the sniff is correctly registered.
95-
$this->assertObjectHasAttribute('sniffCodes', $this->ruleset);
9695
$this->assertCount(1, $this->ruleset->sniffCodes);
9796
$this->assertArrayHasKey('Generic.Formatting.SpaceAfterCast', $this->ruleset->sniffCodes);
9897
$this->assertSame(

tests/Core/Ruleset/RuleInclusionTest.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public function tearDown()
9191
*/
9292
public function testHasSniffCodes()
9393
{
94-
$this->assertObjectHasAttribute('sniffCodes', self::$ruleset);
9594
$this->assertCount(48, self::$ruleset->sniffCodes);
9695

9796
}//end testHasSniffCodes()
@@ -336,7 +335,6 @@ public function dataRegisteredSniffCodes()
336335
*/
337336
public function testSettingProperties($sniffClass, $propertyName, $expectedValue)
338337
{
339-
$this->assertObjectHasAttribute('sniffs', self::$ruleset);
340338
$this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs);
341339
$this->assertObjectHasAttribute($propertyName, self::$ruleset->sniffs[$sniffClass]);
342340

@@ -426,7 +424,6 @@ public function dataSettingProperties()
426424
*/
427425
public function testSettingInvalidPropertiesOnStandardsAndCategoriesSilentlyFails($sniffClass, $propertyName)
428426
{
429-
$this->assertObjectHasAttribute('sniffs', self::$ruleset, 'Ruleset does not have property sniffs');
430427
$this->assertArrayHasKey($sniffClass, self::$ruleset->sniffs, 'Sniff class '.$sniffClass.' not listed in registered sniffs');
431428

432429
$sniffObject = self::$ruleset->sniffs[$sniffClass];

0 commit comments

Comments
 (0)