Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
73 lines
2.7 KiB
PHP
73 lines
2.7 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace YakNet\AccessibilityConsole\Tests\Reporting;
|
||
|
|
|
||
|
|
use PHPUnit\Framework\TestCase;
|
||
|
|
use Symfony\Component\Console\Input\ArrayInput;
|
||
|
|
use Symfony\Component\Console\Output\BufferedOutput;
|
||
|
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||
|
|
use YakNet\AccessibilityConsole\Core\Severity;
|
||
|
|
use YakNet\AccessibilityConsole\Core\Violation;
|
||
|
|
use YakNet\AccessibilityConsole\Core\WCAGStandard;
|
||
|
|
use YakNet\AccessibilityConsole\Reporting\SarifFormatter;
|
||
|
|
|
||
|
|
class SarifFormatterTest extends TestCase
|
||
|
|
{
|
||
|
|
public function testRendersValidSarifJson(): void
|
||
|
|
{
|
||
|
|
$formatter = new SarifFormatter();
|
||
|
|
$violations = [
|
||
|
|
new Violation(
|
||
|
|
'WCAG_1_1_1_IMG_ALT',
|
||
|
|
'Images must have alternative text.',
|
||
|
|
Severity::ERROR,
|
||
|
|
WCAGStandard::A,
|
||
|
|
'<img src="test.jpg">',
|
||
|
|
['file' => 'templates/home.blade.php', 'line' => 14, 'column' => 5],
|
||
|
|
'Add alt="" attribute'
|
||
|
|
),
|
||
|
|
new Violation(
|
||
|
|
'WCAG_1_4_3_CONTRAST',
|
||
|
|
'Insufficient color contrast.',
|
||
|
|
Severity::WARNING,
|
||
|
|
WCAGStandard::AA,
|
||
|
|
'<span style="color:#ccc">Text</span>',
|
||
|
|
['file' => 'templates/home.blade.php', 'line' => 20, 'column' => 1]
|
||
|
|
),
|
||
|
|
];
|
||
|
|
|
||
|
|
$json = $formatter->render($violations);
|
||
|
|
$this->assertJson($json);
|
||
|
|
|
||
|
|
$decoded = json_decode($json, true);
|
||
|
|
$this->assertIsArray($decoded);
|
||
|
|
$this->assertSame('2.1.0', $decoded['version']);
|
||
|
|
$this->assertSame('YakNet Accessibility Console', $decoded['runs'][0]['tool']['driver']['name']);
|
||
|
|
$this->assertCount(2, $decoded['runs'][0]['results']);
|
||
|
|
|
||
|
|
$firstResult = $decoded['runs'][0]['results'][0];
|
||
|
|
$this->assertSame('WCAG_1_1_1_IMG_ALT', $firstResult['ruleId']);
|
||
|
|
$this->assertSame('error', $firstResult['level']);
|
||
|
|
$this->assertSame('templates/home.blade.php', $firstResult['locations'][0]['physicalLocation']['artifactLocation']['uri']);
|
||
|
|
$this->assertSame(14, $firstResult['locations'][0]['physicalLocation']['region']['startLine']);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testFormatOutputsToSymfonyStyle(): void
|
||
|
|
{
|
||
|
|
$formatter = new SarifFormatter();
|
||
|
|
$violations = [];
|
||
|
|
|
||
|
|
$input = new ArrayInput([]);
|
||
|
|
$output = new BufferedOutput();
|
||
|
|
$io = new SymfonyStyle($input, $output);
|
||
|
|
|
||
|
|
$exitCode = $formatter->format($violations, 0, $io);
|
||
|
|
$this->assertSame(0, $exitCode);
|
||
|
|
|
||
|
|
$content = $output->fetch();
|
||
|
|
$this->assertJson($content);
|
||
|
|
$decoded = json_decode($content, true);
|
||
|
|
$this->assertIsArray($decoded);
|
||
|
|
$this->assertEmpty($decoded['runs'][0]['results']);
|
||
|
|
}
|
||
|
|
}
|