Initial plugin scaffold: lesson scheduling WordPress plugin
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
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>
This commit is contained in:
68
tests/Unit/Model/LessonTest.php
Normal file
68
tests/Unit/Model/LessonTest.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Unsupervised\Schedular\Tests\Unit\Model;
|
||||
|
||||
use Unsupervised\Schedular\Model\Lesson;
|
||||
use Unsupervised\Schedular\Tests\Unit\TestCase;
|
||||
|
||||
class LessonTest extends TestCase
|
||||
{
|
||||
public function testStatusConstants(): void
|
||||
{
|
||||
self::assertSame('pending', Lesson::STATUS_PENDING);
|
||||
self::assertSame('confirmed', Lesson::STATUS_CONFIRMED);
|
||||
self::assertSame('cancelled', Lesson::STATUS_CANCELLED);
|
||||
}
|
||||
|
||||
public function testValidStatusesContainsAllThree(): void
|
||||
{
|
||||
self::assertContains(Lesson::STATUS_PENDING, Lesson::VALID_STATUSES);
|
||||
self::assertContains(Lesson::STATUS_CONFIRMED, Lesson::VALID_STATUSES);
|
||||
self::assertContains(Lesson::STATUS_CANCELLED, Lesson::VALID_STATUSES);
|
||||
self::assertCount(3, Lesson::VALID_STATUSES);
|
||||
}
|
||||
|
||||
public function testConstructorDefaults(): void
|
||||
{
|
||||
$lesson = new Lesson(slotId: 1, studentId: 2, instructorId: 3);
|
||||
|
||||
self::assertSame(Lesson::STATUS_PENDING, $lesson->status);
|
||||
self::assertNull($lesson->notes);
|
||||
self::assertNull($lesson->id);
|
||||
}
|
||||
|
||||
public function testFromRowMapsCorrectly(): void
|
||||
{
|
||||
$row = (object) [
|
||||
'id' => '99',
|
||||
'slot_id' => '10',
|
||||
'student_id' => '20',
|
||||
'instructor_id' => '30',
|
||||
'status' => 'confirmed',
|
||||
'notes' => 'Bring your guitar.',
|
||||
];
|
||||
|
||||
$lesson = Lesson::fromRow($row);
|
||||
|
||||
self::assertSame(99, $lesson->id);
|
||||
self::assertSame(10, $lesson->slotId);
|
||||
self::assertSame(20, $lesson->studentId);
|
||||
self::assertSame(30, $lesson->instructorId);
|
||||
self::assertSame('confirmed', $lesson->status);
|
||||
self::assertSame('Bring your guitar.', $lesson->notes);
|
||||
}
|
||||
|
||||
public function testToArrayContainsExpectedKeys(): void
|
||||
{
|
||||
$lesson = new Lesson(1, 2, 3, Lesson::STATUS_PENDING, 'Note', 5);
|
||||
$arr = $lesson->toArray();
|
||||
|
||||
self::assertArrayHasKey('id', $arr);
|
||||
self::assertArrayHasKey('slot_id', $arr);
|
||||
self::assertArrayHasKey('student_id', $arr);
|
||||
self::assertArrayHasKey('instructor_id', $arr);
|
||||
self::assertArrayHasKey('status', $arr);
|
||||
self::assertArrayHasKey('notes', $arr);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user