fix calendar page
API CI/CD / Validate (composer + pint) (push) Successful in 3m9s
API CI/CD / Test (PHPUnit) (push) Failing after 2m0s
API CI/CD / Build frontend assets (push) Failing after 1m55s
API CI/CD / Security audit (push) Failing after 55s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
API CI/CD / Validate (composer + pint) (push) Successful in 3m9s
API CI/CD / Test (PHPUnit) (push) Failing after 2m0s
API CI/CD / Build frontend assets (push) Failing after 1m55s
API CI/CD / Security audit (push) Failing after 55s
API CI/CD / Deploy to shared hosting (PHP) (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Web;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminCalendarPageTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$compiledPath = storage_path('framework/views');
|
||||
if (! is_dir($compiledPath)) {
|
||||
mkdir($compiledPath, 0777, true);
|
||||
}
|
||||
|
||||
config([
|
||||
'app.key' => 'base64:'.base64_encode(random_bytes(32)),
|
||||
'app.cipher' => 'AES-256-CBC',
|
||||
'view.compiled' => $compiledPath,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_admin_calendar_view_lists_school_calendar_events_for_selected_year(): void
|
||||
{
|
||||
$this->seedAdminContext();
|
||||
|
||||
DB::table('calendar_events')->insert([
|
||||
'title' => 'Back to School Night',
|
||||
'date' => '2025-09-14',
|
||||
'description' => 'Families meet teachers.',
|
||||
'notify_parent' => 1,
|
||||
'notify_admin' => 1,
|
||||
'notify_teacher' => 1,
|
||||
'no_school' => 0,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'notification_sent' => 0,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('calendar_events')->insert([
|
||||
'title' => 'Other Year Event',
|
||||
'date' => '2026-09-13',
|
||||
'description' => 'Should not render for the selected year.',
|
||||
'notify_parent' => 1,
|
||||
'notify_admin' => 1,
|
||||
'notify_teacher' => 1,
|
||||
'no_school' => 0,
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2026-2027',
|
||||
'notification_sent' => 0,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$response = $this->actingAs(User::query()->findOrFail(1))
|
||||
->get('/app/administrator/calendar_view?school_year=2025-2026');
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertSee('School Calendar');
|
||||
$response->assertSee('Add School Calendar Entry');
|
||||
$response->assertSee('Notify Parent');
|
||||
$response->assertSee('No School');
|
||||
$response->assertSee('Back to School Night');
|
||||
$response->assertSee('Families meet teachers.');
|
||||
$response->assertDontSee('Other Year Event');
|
||||
}
|
||||
|
||||
private function seedAdminContext(): void
|
||||
{
|
||||
DB::table('configuration')->insert([
|
||||
['config_key' => 'school_year', 'config_value' => '2025-2026'],
|
||||
['config_key' => 'semester', 'config_value' => 'Fall'],
|
||||
]);
|
||||
|
||||
DB::table('roles')->insert([
|
||||
'id' => 1,
|
||||
'name' => 'administrator',
|
||||
'slug' => 'administrator',
|
||||
'is_active' => 1,
|
||||
]);
|
||||
|
||||
DB::table('users')->insert([
|
||||
'id' => 1,
|
||||
'school_id' => 1,
|
||||
'firstname' => 'Admin',
|
||||
'lastname' => 'User',
|
||||
'gender' => 'Female',
|
||||
'cellphone' => '5555555555',
|
||||
'email' => 'admin-calendar@example.com',
|
||||
'address_street' => '123 Main',
|
||||
'city' => 'City',
|
||||
'state' => 'ST',
|
||||
'zip' => '12345',
|
||||
'accept_school_policy' => 1,
|
||||
'is_verified' => 1,
|
||||
'status' => 'Active',
|
||||
'is_suspended' => 0,
|
||||
'failed_attempts' => 0,
|
||||
'password' => bcrypt('secret'),
|
||||
'semester' => 'Fall',
|
||||
'school_year' => '2025-2026',
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
DB::table('user_roles')->insert([
|
||||
'user_id' => 1,
|
||||
'role_id' => 1,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user