Skip to content

Commit 73171a7

Browse files
authored
Merge pull request #21 from cidilabs/scottcooper/php-ally-track-number
Make changes for IssueCount and TestCount
2 parents 9858425 + efbcc04 commit 73171a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+104
-26
lines changed

src/PhpAlly.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ public function checkMany($content, $ruleIds = [], $options = [])
3333
}
3434

3535
$rule = new $className($document, $options);
36-
$rule->check();
36+
$issueCount = $rule->check();
3737

38+
$report->setIssueCounts($ruleId, $issueCount, $rule->getTotalTests());
3839
$report->setIssues($rule->getIssues());
3940
$report->setErrors($rule->getErrors());
4041
} catch (\Exception $e) {

src/PhpAllyReport.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class PhpAllyReport implements \JsonSerializable {
66
protected $issues = [];
77
protected $errors = [];
88
protected $html = '';
9+
protected $issueCounts = [];
910

1011
public function __construct()
1112
{
@@ -16,6 +17,7 @@ public function toArray()
1617
return [
1718
'issues' => $this->getIssues(),
1819
'errors' => $this->getErrors(),
20+
'issueCounts' => $this->getIssueCounts(),
1921
];
2022
}
2123

@@ -59,4 +61,14 @@ public function setErrors($errors)
5961
$this->errors = array_merge($this->errors, $errors);
6062
}
6163

64+
public function getIssueCounts()
65+
{
66+
return $this->issueCounts;
67+
}
68+
69+
public function setIssueCounts($ruleId, $issueCount, $total) {
70+
$ruleId = str_replace(['CidiLabs\\PhpAlly\\Rule\\','App\\Rule\\'], '', $ruleId);
71+
$this->issueCounts[$ruleId] = array('issueCount' => $issueCount, "totalCount" => $total);
72+
}
73+
6274
}

src/Rule/AnchorLinksToMultiMediaRequireTranscript.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public function check()
3232
$this->setIssue($a);
3333
}
3434
}
35+
$this->totalTests++;
3536
}
3637

3738
return count($this->issues);

src/Rule/AnchorLinksToSoundFilesNeedTranscripts.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ public function check()
3434
$this->setIssue($a);
3535
}
3636
}
37-
}
37+
$this->totalTests++;
38+
}
3839

3940
return count($this->issues);
4041
}

src/Rule/AnchorMustContainText.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function check()
2525
if (!$this->elementContainsReadableText($a) && ($a->hasAttribute('href'))) {
2626
$this->setIssue($a);
2727
}
28+
$this->totalTests++;
2829
}
2930

3031
return count($this->issues);

src/Rule/AnchorSuspiciousLinkText.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function check()
2525
foreach ($this->getAllElements('a') as $a) {
2626
if (in_array(strtolower(trim($a->nodeValue)), $this->translation()) || $a->nodeValue == $a->getAttribute('href'))
2727
$this->setIssue($a);
28+
$this->totalTests++;
2829
}
2930

3031
return count($this->issues);

src/Rule/BaseFontIsNotUsed.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public function check()
2020
{
2121
foreach ($this->getAllElements('basefont') as $b) {
2222
$this->setIssue($b);
23+
$this->totalTests++;
2324
}
2425

2526
return count($this->issues);

src/Rule/BaseRule.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class BaseRule implements PhpAllyRuleInterface {
2525
protected $altTextLengthLimit;
2626
protected $minDocLengthForHeaders;
2727
protected $maxWordCount;
28+
protected $totalTests = 0;
2829

2930
public function __construct(DOMDocument $dom, $options = [])
3031
{
@@ -217,8 +218,6 @@ private function walkUpTreeForInheritance($element, $style) {
217218
}
218219

219220

220-
221-
222221
public function elementContainsReadableText($element)
223222
{
224223
if (is_a($element, 'DOMText')) {
@@ -266,6 +265,15 @@ public function getIssues()
266265
return $this->issues;
267266
}
268267

268+
public function getTotalTests()
269+
{
270+
return $this->totalTests;
271+
}
272+
public function IncrementTotalTests()
273+
{
274+
return $this->totalTests++;
275+
}
276+
269277
public function setError($errorMsg)
270278
{
271279
$this->errors[] = $errorMsg;
@@ -323,4 +331,6 @@ function propertyIsEqual($object, $property, $value, $trim = false, $lower = fal
323331
}
324332
return ($property_value == $value);
325333
}
334+
335+
326336
}

src/Rule/BlinkIsNotUsed.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public function check()
2121
{
2222
foreach ($this->getAllElements('blink') as $b) {
2323
$this->setIssue($b);
24+
$this->totalTests++;
2425
}
2526

2627
return count($this->issues);

src/Rule/BrokenLink.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function check()
2525
if ($href) {
2626
$links[$href] = $a;
2727
}
28+
$this->totalTests++;
2829
}
2930
$this->checkLink($links);
3031

0 commit comments

Comments
 (0)