All checks were successful
CI / Coding Standards (push) Successful in 43s
CI / PHPStan (push) Successful in 52s
CI / Tests (PHP 8.1) (push) Successful in 47s
CI / Tests (PHP 8.2) (push) Successful in 49s
CI / Tests (PHP 8.3) (push) Successful in 37s
CI / No Debug Code (push) Successful in 2s
All classes are now organised by domain (Availability, Booking, Auth). Each domain package contains its value object, repository, admin controller, REST endpoint, and any shortcode pages under a matching sub-namespace. Cross-cutting wiring (Plugin, AdminMenu, RestRegistrar, ShortcodeRegistrar, Schema) lives at src/ root. Tests mirror the domain structure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
69 lines
2.1 KiB
PHP
69 lines
2.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Unsupervised\Schedular\Tests\Unit\Availability;
|
|
|
|
use Unsupervised\Schedular\Availability\AvailabilitySlot;
|
|
use Unsupervised\Schedular\Tests\Unit\TestCase;
|
|
|
|
class AvailabilitySlotTest extends TestCase
|
|
{
|
|
public function testConstructorAndProperties(): void
|
|
{
|
|
$slot = new AvailabilitySlot(
|
|
instructorId: 5,
|
|
startDt: '2026-04-01 09:00:00',
|
|
endDt: '2026-04-01 10:00:00',
|
|
isBooked: false,
|
|
id: 42,
|
|
);
|
|
|
|
self::assertSame(5, $slot->instructorId);
|
|
self::assertSame('2026-04-01 09:00:00', $slot->startDt);
|
|
self::assertSame('2026-04-01 10:00:00', $slot->endDt);
|
|
self::assertFalse($slot->isBooked);
|
|
self::assertSame(42, $slot->id);
|
|
}
|
|
|
|
public function testFromRowMapsCorrectly(): void
|
|
{
|
|
$row = (object) [
|
|
'id' => '7',
|
|
'instructor_id' => '3',
|
|
'start_dt' => '2026-05-10 14:00:00',
|
|
'end_dt' => '2026-05-10 15:00:00',
|
|
'is_booked' => '1',
|
|
];
|
|
|
|
$slot = AvailabilitySlot::fromRow($row);
|
|
|
|
self::assertSame(7, $slot->id);
|
|
self::assertSame(3, $slot->instructorId);
|
|
self::assertTrue($slot->isBooked);
|
|
}
|
|
|
|
public function testToArrayContainsExpectedKeys(): void
|
|
{
|
|
$slot = new AvailabilitySlot(1, '2026-04-01 09:00:00', '2026-04-01 10:00:00', false, 10);
|
|
$arr = $slot->toArray();
|
|
|
|
self::assertArrayHasKey('id', $arr);
|
|
self::assertArrayHasKey('instructor_id', $arr);
|
|
self::assertArrayHasKey('start_dt', $arr);
|
|
self::assertArrayHasKey('end_dt', $arr);
|
|
self::assertArrayHasKey('is_booked', $arr);
|
|
}
|
|
|
|
public function testDefaultIsBookedIsFalse(): void
|
|
{
|
|
$slot = new AvailabilitySlot(1, '2026-04-01 09:00:00', '2026-04-01 10:00:00');
|
|
self::assertFalse($slot->isBooked);
|
|
}
|
|
|
|
public function testDefaultIdIsNull(): void
|
|
{
|
|
$slot = new AvailabilitySlot(1, '2026-04-01 09:00:00', '2026-04-01 10:00:00');
|
|
self::assertNull($slot->id);
|
|
}
|
|
}
|