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

- 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:
2026-03-30 12:44:46 -03:00
commit 0fbafc9d18
41 changed files with 2249 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
<?php
declare(strict_types=1);
namespace Unsupervised\Schedular\Tests\Unit\Roles;
use Brain\Monkey\Functions;
use Unsupervised\Schedular\Roles\RoleManager;
use Unsupervised\Schedular\Tests\Unit\TestCase;
class RoleManagerTest extends TestCase
{
public function testRegisterAddsInitHook(): void
{
Functions\expect('add_action')
->once()
->with('init', \Mockery::any());
(new RoleManager())->register();
}
public function testCreateRolesSkipsExistingRoles(): void
{
Functions\when('get_role')->alias(static fn() => new \stdClass());
Functions\expect('add_role')->never();
(new RoleManager())->createRoles();
}
public function testCreateRolesAddsInstructorRoleWithCorrectCaps(): void
{
Functions\when('get_role')->alias(static function (string $role): ?object {
return $role === RoleManager::INSTRUCTOR ? null : new \stdClass();
});
Functions\expect('add_role')
->once()
->with(
RoleManager::INSTRUCTOR,
\Mockery::any(),
\Mockery::on(static function (array $caps): bool {
return ($caps['read'] ?? false) === true
&& ($caps[RoleManager::CAP_MANAGE_AVAILABILITY] ?? false) === true
&& ($caps[RoleManager::CAP_VIEW_LESSONS] ?? false) === true;
})
);
(new RoleManager())->createRoles();
}
public function testCreateRolesAddsStudentRoleWithCorrectCaps(): void
{
Functions\when('get_role')->alias(static function (string $role): ?object {
return $role === RoleManager::STUDENT ? null : new \stdClass();
});
Functions\expect('add_role')
->once()
->with(
RoleManager::STUDENT,
\Mockery::any(),
\Mockery::on(static function (array $caps): bool {
return ($caps['read'] ?? false) === true
&& ($caps[RoleManager::CAP_BOOK_LESSON] ?? false) === true
&& ($caps[RoleManager::CAP_VIEW_LESSONS] ?? false) === true;
})
);
(new RoleManager())->createRoles();
}
}