release: v3.2.0 - Enterprise Edition with Live Web Dashboard, PDF/Excel Exporters, Framework Stubs & 110 WCAG Rules

This commit is contained in:
Enes Yakıştır
2026-07-31 00:13:31 +03:00
parent 58b1618d96
commit 73fbf485d2
36 changed files with 1420 additions and 11 deletions
+19
View File
@@ -0,0 +1,19 @@
<?php
namespace YakNet\AccessibilityConsole\Tests\Audit;
use PHPUnit\Framework\TestCase;
use YakNet\AccessibilityConsole\Audit\SiteCrawler;
class SiteCrawlerTest extends TestCase
{
public function testCrawlsBaseUrl(): void
{
$crawler = new SiteCrawler();
$result = $crawler->crawlAndAudit('https://yak.net.tr', 1);
$this->assertSame('https://yak.net.tr', $result['base_url']);
$this->assertSame(1, $result['pages_audited']);
$this->assertArrayHasKey('average_score', $result);
}
}
+20
View File
@@ -0,0 +1,20 @@
<?php
namespace YakNet\AccessibilityConsole\Tests\AutoFix;
use PHPUnit\Framework\TestCase;
use YakNet\AccessibilityConsole\AutoFix\HtmlRepairEngine;
class HtmlRepairEngineTest extends TestCase
{
public function testRepairsMissingLangAndSvg(): void
{
$html = '<html><body><svg class="icon"></svg><img src="test.png"></body></html>';
$result = HtmlRepairEngine::autoRepair($html);
$this->assertStringContainsString('<html lang="tr"', $result['repaired_html']);
$this->assertStringContainsString('<svg aria-hidden="true"', $result['repaired_html']);
$this->assertStringContainsString('<img alt=""', $result['repaired_html']);
$this->assertCount(3, $result['fixes_applied']);
}
}
@@ -0,0 +1,26 @@
<?php
namespace YakNet\AccessibilityConsole\Tests\Integrations;
use PHPUnit\Framework\TestCase;
use YakNet\AccessibilityConsole\Integrations\GitHubActionsReporter;
class GitHubActionsReporterTest extends TestCase
{
public function testFormatsGitHubAnnotations(): void
{
$scanResult = [
'violations' => [
[
'ruleId' => 'WCAG_1_1_1_SVG',
'description' => 'SVG missing alt',
'line' => 12,
'severity' => 'ERROR'
]
]
];
$output = GitHubActionsReporter::formatAnnotations($scanResult, 'index.html');
$this->assertStringContainsString('::error file=index.html,line=12::[WCAG_1_1_1_SVG]', $output);
}
}
@@ -0,0 +1,30 @@
<?php
namespace YakNet\AccessibilityConsole\Tests\Reporting;
use PHPUnit\Framework\TestCase;
use YakNet\AccessibilityConsole\Reporting\ExcelReportExporter;
class ExcelReportExporterTest extends TestCase
{
public function testExportsExcelBinaryContent(): void
{
$scanResult = [
'score' => 90,
'violations_count' => 1,
'violations' => [
[
'ruleId' => 'WCAG_3_1_1_LANG',
'description' => 'Missing lang attribute',
'htmlSnippet' => '<html>',
'suggestion' => 'Add lang="tr"',
'standard' => 'WCAG 2.1 A',
'severity' => 'ERROR'
]
]
];
$excelBinary = ExcelReportExporter::exportExcel($scanResult, 'https://example.com');
$this->assertNotEmpty($excelBinary);
}
}
@@ -0,0 +1,31 @@
<?php
namespace YakNet\AccessibilityConsole\Tests\Reporting;
use PHPUnit\Framework\TestCase;
use YakNet\AccessibilityConsole\Reporting\PdfReportGenerator;
class PdfReportGeneratorTest extends TestCase
{
public function testGeneratesPdfBinaryContent(): void
{
$scanResult = [
'score' => 95,
'violations_count' => 1,
'violations' => [
[
'ruleId' => 'WCAG_1_1_1_IMG_ALT',
'description' => 'Image missing alt text',
'htmlSnippet' => '<img src="test.jpg">',
'suggestion' => 'Add alt="Description"',
'standard' => 'WCAG 2.1 AA',
'severity' => 'ERROR'
]
]
];
$pdfBinary = PdfReportGenerator::generatePdf($scanResult, 'https://example.com');
$this->assertNotEmpty($pdfBinary);
$this->assertStringStartsWith('%PDF-', $pdfBinary);
}
}
@@ -0,0 +1,31 @@
<?php
namespace YakNet\AccessibilityConsole\Tests\Rules;
use PHPUnit\Framework\TestCase;
use YakNet\AccessibilityConsole\Core\Scanner;
use YakNet\AccessibilityConsole\Rules\ColorBlindnessContrast;
class ColorBlindnessContrastTest extends TestCase
{
public function testFlagsLowContrastUnderColorBlindnessSimulation(): void
{
$scanner = new Scanner();
$scanner->addRule(new ColorBlindnessContrast());
// Red text #ff0000 on Green background #00ff00 (Classic red/green colorblindness issue)
$violations = $scanner->scan('<div style="color: #ff0000; background-color: #00ff00;">Red on Green text</div>');
$this->assertGreaterThanOrEqual(1, count($violations));
$this->assertSame('WCAG_1_4_1_COLOR_BLINDNESS_CONTRAST', $violations[0]->ruleId);
}
public function testPassesHighContrastUnderColorBlindnessSimulation(): void
{
$scanner = new Scanner();
$scanner->addRule(new ColorBlindnessContrast());
// Black text #000000 on White background #ffffff
$violations = $scanner->scan('<div style="color: #000000; background-color: #ffffff;">Black on White text</div>');
$this->assertCount(0, $violations);
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace YakNet\AccessibilityConsole\Tests\Rules;
use PHPUnit\Framework\TestCase;
use YakNet\AccessibilityConsole\Core\Scanner;
use YakNet\AccessibilityConsole\Rules\ContentInfoParent;
class ContentInfoParentTest extends TestCase
{
public function testFlagsNestedFooterInSection(): void
{
$scanner = new Scanner();
$scanner->addRule(new ContentInfoParent());
$violations = $scanner->scan('<section><footer role="contentinfo"><p>Nested footer</p></footer></section>');
$this->assertGreaterThanOrEqual(1, count($violations));
$this->assertSame('WCAG_1_3_1_CONTENTINFO_PARENT', $violations[0]->ruleId);
}
public function testPassesTopLevelFooter(): void
{
$scanner = new Scanner();
$scanner->addRule(new ContentInfoParent());
$violations = $scanner->scan('<body><footer role="contentinfo"><p>Top level footer</p></footer></body>');
$this->assertCount(0, $violations);
}
}
@@ -0,0 +1,38 @@
<?php
namespace YakNet\AccessibilityConsole\Tests\Rules;
use PHPUnit\Framework\TestCase;
use YakNet\AccessibilityConsole\Core\Scanner;
use YakNet\AccessibilityConsole\Rules\ImageDimensionsAndScale;
class ImageDimensionsAndScaleTest extends TestCase
{
public function testFlagsMissingWidthAttribute(): void
{
$scanner = new Scanner();
$scanner->addRule(new ImageDimensionsAndScale());
$violations = $scanner->scan('<img src="test.jpg" alt="Test image">');
$this->assertGreaterThanOrEqual(1, count($violations));
$this->assertSame('WCAG_1_4_4_IMAGE_DIMENSIONS_SCALE', $violations[0]->ruleId);
}
public function testFlagsSmallInteractiveTouchTarget(): void
{
$scanner = new Scanner();
$scanner->addRule(new ImageDimensionsAndScale());
$violations = $scanner->scan('<a href="/"><img src="icon.png" alt="Home" width="12" height="12"></a>');
$this->assertGreaterThanOrEqual(1, count($violations));
}
public function testPassesValidImageDimensions(): void
{
$scanner = new Scanner();
$scanner->addRule(new ImageDimensionsAndScale());
$violations = $scanner->scan('<img src="test.jpg" alt="Test" width="300" height="200">');
$this->assertCount(0, $violations);
}
}
@@ -0,0 +1,29 @@
<?php
namespace YakNet\AccessibilityConsole\Tests\Rules;
use PHPUnit\Framework\TestCase;
use YakNet\AccessibilityConsole\Core\Scanner;
use YakNet\AccessibilityConsole\Rules\InputTypePasswordVisibility;
class InputTypePasswordVisibilityTest extends TestCase
{
public function testFlagsPasswordToggleWithoutAccessibleName(): void
{
$scanner = new Scanner();
$scanner->addRule(new InputTypePasswordVisibility());
$violations = $scanner->scan('<button class="toggle-password"></button>');
$this->assertGreaterThanOrEqual(1, count($violations));
$this->assertSame('WCAG_4_1_2_PASSWORD_VISIBILITY_TOGGLE', $violations[0]->ruleId);
}
public function testPassesPasswordToggleWithAriaLabel(): void
{
$scanner = new Scanner();
$scanner->addRule(new InputTypePasswordVisibility());
$violations = $scanner->scan('<button class="toggle-password" aria-label="Şifreyi göster"></button>');
$this->assertCount(0, $violations);
}
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace YakNet\AccessibilityConsole\Tests\Rules;
use PHPUnit\Framework\TestCase;
use YakNet\AccessibilityConsole\Core\Scanner;
use YakNet\AccessibilityConsole\Rules\TableNestedBanned;
class TableNestedBannedTest extends TestCase
{
public function testFlagsNestedTable(): void
{
$scanner = new Scanner();
$scanner->addRule(new TableNestedBanned());
$violations = $scanner->scan('<table><tr><td><table><tr><td>Nested table</td></tr></table></td></tr></table>');
$this->assertGreaterThanOrEqual(1, count($violations));
$this->assertSame('WCAG_1_3_1_TABLE_NESTED_BANNED', $violations[0]->ruleId);
}
public function testPassesSingleTable(): void
{
$scanner = new Scanner();
$scanner->addRule(new TableNestedBanned());
$violations = $scanner->scan('<table><tr><td>Single table data</td></tr></table>');
$this->assertCount(0, $violations);
}
}