@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use App\Services\DeadlineTaskGuiAction;
|
||||
|
||||
function syntheticDeadlineGuiXml(): string
|
||||
{
|
||||
return '<Task xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"><Settings><MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>'
|
||||
.'<ExecutionTimeLimit>PT1M</ExecutionTimeLimit></Settings><Actions><Exec><Command>C:/synthetic/php.exe</Command>'
|
||||
.'<Arguments>"C:/synthetic/deadlines.php" --once</Arguments><WorkingDirectory>C:/synthetic</WorkingDirectory></Exec></Actions></Task>';
|
||||
}
|
||||
|
||||
test('silent deadline correction preserves arguments working directory overlap and limits', function () {
|
||||
$xml = syntheticDeadlineGuiXml();
|
||||
$after = DeadlineTaskGuiAction::replacement($xml, 'C:/synthetic/php.exe', 'C:/synthetic/php-win.exe');
|
||||
expect($after)->toContain('php-win.exe')->toContain('"C:/synthetic/deadlines.php" --once')->toContain('IgnoreNew')->toContain('PT1M');
|
||||
DeadlineTaskGuiAction::assertConserved($xml, $after, 'C:/synthetic/php.exe', 'C:/synthetic/php-win.exe');
|
||||
DeadlineTaskGuiAction::assertConserved($xml, str_replace('><', ">\r\n <", $after), 'C:/synthetic/php.exe', 'C:/synthetic/php-win.exe');
|
||||
expect(DeadlineTaskGuiAction::canonical(str_replace('><', ">\r\n <", $xml)))->toBe(DeadlineTaskGuiAction::canonical($xml));
|
||||
expect(fn () => DeadlineTaskGuiAction::assertConserved($xml, str_replace('PT1M', 'PT5M', $after), 'C:/synthetic/php.exe', 'C:/synthetic/php-win.exe'))
|
||||
->toThrow(LogicException::class, 'DEADLINE_TASK_GUI_UNRELATED_DEFINITION_CHANGE');
|
||||
});
|
||||
|
||||
test('silent deadline correction refuses another executable directory or multiple actions', function () {
|
||||
$xml = syntheticDeadlineGuiXml();
|
||||
expect(fn () => DeadlineTaskGuiAction::replacement($xml, 'C:/synthetic/php.exe', 'C:/other/php-win.exe'))->toThrow(LogicException::class, 'DEADLINE_TASK_GUI_EXECUTABLE_PAIR');
|
||||
expect(fn () => DeadlineTaskGuiAction::replacement(str_replace('</Actions>', '<Exec><Command>other</Command></Exec></Actions>', $xml), 'C:/synthetic/php.exe', 'C:/synthetic/php-win.exe'))
|
||||
->toThrow(LogicException::class, 'DEADLINE_TASK_GUI_ACTION_MISMATCH');
|
||||
});
|
||||
Reference in New Issue
Block a user