Some checks failed
CI / Coding Standards (push) Failing after 2m31s
CI / PHPStan (push) Failing after 50s
CI / Tests (PHP 8.1) (push) Successful in 50s
CI / Tests (PHP 8.2) (push) Successful in 48s
CI / Tests (PHP 8.3) (push) Successful in 40s
CI / No Debug Code (push) Successful in 2s
- Custom DB tables for availability slots and lesson bookings - Instructor (wp-admin) and student (front-end) roles with custom capabilities - REST API under us-scheduler/v1 for availability CRUD and booking - [us_booking] and [us_student_login] shortcodes for student front end - PHPUnit + Brain\Monkey unit test suite (29 tests) - Gitea Actions CI: lint, PHPStan, tests on PHP 8.1/8.2/8.3, no-debug check - Feature docs under docs/features/ 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\Model;
|
|
|
|
use Unsupervised\Schedular\Model\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);
|
|
}
|
|
}
|