'
.'Conferência de prazos — QA'
.'C:/synthetic/php.exe"C:/synthetic/deadlines.php" --once';
}
test('task file encoding matches its UTF16 declaration without changing any task content', function () {
$xml = syntheticWindowsTaskXml();
$bytes = WindowsTaskXml::encode($xml);
expect(in_array(substr($bytes, 0, 2), ["\xFF\xFE", "\xFE\xFF"], true))->toBeTrue()
->and(WindowsTaskXml::parse($bytes)->documentElement->C14N())->toBe(WindowsTaskXml::parse($xml)->documentElement->C14N());
});
test('native console task XML with a mismatched declaration preserves accents and action arguments', function () {
$xml = syntheticWindowsTaskXml();
$console = str_replace('encoding="UTF-8"', 'encoding="UTF-16"', $xml);
$document = WindowsTaskXml::parse($console);
expect($document->documentElement->C14N())->toBe(WindowsTaskXml::parse($xml)->documentElement->C14N())
->and($document->getElementsByTagName('Description')->item(0)->textContent)->toBe('Conferência de prazos — QA')
->and($document->getElementsByTagName('Arguments')->item(0)->textContent)->toBe('"C:/synthetic/deadlines.php" --once');
});
test('invalid or unrelated XML is refused before task registration', function () {
foreach (['', ''] as $xml) {
expect(fn () => WindowsTaskXml::encode($xml))->toThrow(LogicException::class, 'WINDOWS_TASK_XML_INVALID');
}
});