38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace Tests\Feature;
|
||
|
|
|
||
|
|
use App\Services\AccessibilityAnalyzer;
|
||
|
|
use Tests\TestCase;
|
||
|
|
|
||
|
|
class AccessibilityAnalyzerTest extends TestCase
|
||
|
|
{
|
||
|
|
public function test_analyzer_detects_missing_alt_tags(): void
|
||
|
|
{
|
||
|
|
$analyzer = new AccessibilityAnalyzer();
|
||
|
|
$content = [
|
||
|
|
['type' => 'image', 'data' => ['url' => 'test.jpg']], // missing alt
|
||
|
|
['type' => 'image', 'data' => ['url' => 'test2.jpg', 'alt' => 'Descriptive text']],
|
||
|
|
];
|
||
|
|
|
||
|
|
$issues = $analyzer->analyze($content);
|
||
|
|
|
||
|
|
$this->assertCount(1, $issues);
|
||
|
|
$this->assertEquals('Image block is missing alternative text (alt tag).', $issues[0]['message']);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function test_analyzer_detects_heading_skips(): void
|
||
|
|
{
|
||
|
|
$analyzer = new AccessibilityAnalyzer();
|
||
|
|
$content = [
|
||
|
|
['type' => 'heading', 'data' => ['level' => 1]],
|
||
|
|
['type' => 'heading', 'data' => ['level' => 3]], // skipped H2
|
||
|
|
];
|
||
|
|
|
||
|
|
$issues = $analyzer->analyze($content);
|
||
|
|
|
||
|
|
$this->assertCount(1, $issues);
|
||
|
|
$this->assertStringContainsString('Skipped heading level', $issues[0]['message']);
|
||
|
|
}
|
||
|
|
}
|