Skip to content

Commit

Permalink
Add test for missing externalInfoUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
kamioftea committed Oct 3, 2020
1 parent 41a1f4b commit 6f5c74d
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion src/test/php/PHPMD/RuleSetFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,39 @@ public function testIfGettingRuleFilePathExcludeUnreadablePaths()
$this->assertEquals(5, $ruleSetNotFoundExceptionCount);
}

/**
* Checks the ruleset XML files provided with PHPMD all provide externalInfoUrls
*
* @param string $file The path to the ruleset xml to test
* @return void
* @dataProvider getDefaultRuleSets
*/
public function testDefaultRuleSetsProvideExternalInfoUrls($file)
{
$rulesets = $this->createRuleSetsFromFiles($file);
$ruleset = $rulesets[0];
/** @var Rule $rule */
foreach ($ruleset->getRules() as $rule) {
$message = sprintf(
'%s in rule set %s should provide an externalInfoUrl',
$rule->getName(),
$ruleset->getName()
);

$this->assertNotEmpty($rule->getExternalInfoUrl(), $message);
}
}

/**
* Provides an array of the file paths to rule sets provided with PHPMD
*
* @return array
*/
public function getDefaultRuleSets()
{
return static::getValuesAsArrays(glob(__DIR__ . '/../../../main/resources/rulesets/*.xml'));
}

/**
* Invokes the <b>createRuleSets()</b> of the {@link RuleSetFactory}
* class.
Expand Down Expand Up @@ -741,7 +774,7 @@ private function createRuleSetsFromFiles($file)
$args = func_get_args();

$factory = new RuleSetFactory();

return $factory->createRuleSets(implode(',', $args));
}

Expand Down

0 comments on commit 6f5c74d

Please sign in to comment.