Files
XC_VM/tests/Unit/MassExpiryTest.php
T
obscuremindandClaude Opus 5.5 5be4b10b20 fix(lines): a mass edit with no expiry date leaves each line's own
With Expiry ticked and no date, new DateTime('') is now: every selected
line, MAG or Enigma device expired at once. The single edit had the
guard; the three mass edits did not. They now share
LineService::massExpiry(): a date, no expiry, or (no date, not a date)
nothing changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AneTzAHPPkYWPQjwyZ2td9
2026-10-10 14:07:22 +00:00

24 lines
1.0 KiB
PHP

<?php
use PHPUnit\Framework\TestCase;
use XcVm\Domain\Line\LineService;
/**
* The expiry a mass edit of lines, MAG or Enigma devices sets. With the box
* ticked and no date, `new DateTime('')` is now: every selected line expired
* at once. No date now leaves each line's own expiry.
*/
final class MassExpiryTest extends TestCase {
public function testNoDateLeavesEachLinesOwnExpiry(): void {
$this->assertFalse(LineService::massExpiry(['c_exp_date' => 'on', 'exp_date' => '']));
$this->assertFalse(LineService::massExpiry(['c_exp_date' => 'on', 'exp_date' => ' ']));
$this->assertFalse(LineService::massExpiry(['c_exp_date' => 'on']));
$this->assertFalse(LineService::massExpiry(['c_exp_date' => 'on', 'exp_date' => 'not a date']));
}
public function testADateOrNoExpiryIsSet(): void {
$this->assertSame((new DateTime('2027-01-31'))->format('U'), LineService::massExpiry(['exp_date' => '2027-01-31']));
$this->assertNull(LineService::massExpiry(['exp_date' => '', 'no_expire' => 'on']), 'no expiry asked for');
}
}