- Convert 17 hand-rolled tests to PHPUnit TestCases (tests: stubs pattern) P0 security tests preserved: key-leak/encryption (KeyStoreTest), capture-allowlist/executor-path sentinel (CaptureWriterTest) - Add phpunit.xml.dist + update tests/bootstrap.php (Composer autoloader first) - Add phpunit/phpunit ^9.6 + yoast/phpunit-polyfills ^2.0 to require-dev - composer test -> vendor/bin/phpunit --configuration phpunit.xml.dist - ci.yml: thin caller of peptide-e2e reusable CI (tests: stubs, has_js: true, workflow_call trigger, permissions: contents: write) - deploy.yml: estate pattern caller of peptide-e2e deploy-app.yml@main (target_path: wp-content/plugins/pr-vision, gated on reusable CI) Pull-deploy on Hostinger stays as break-glass - Add cto-review.yml (Haiku-only, A/B panel dropped 2026-06-12) - Add main-push-audit.yml (direct-push tripwire) Agent-Session: claude-adopt-ci-20260616
69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
<?php
|
|
/**
|
|
* Tests for PRV_Cron: scheduling, clearing, and registration.
|
|
*
|
|
* @package PrVision
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* @covers PRV_Cron
|
|
* @covers PRV_Activator
|
|
* @covers PRV_Deactivator
|
|
*/
|
|
class CronTest extends TestCase {
|
|
|
|
protected function setUp(): void {
|
|
prv_test_reset();
|
|
}
|
|
|
|
public function test_schedule_weekly_adds_event(): void {
|
|
$this->assertFalse( PRV_Cron::is_scheduled() );
|
|
PRV_Cron::schedule_weekly();
|
|
$this->assertTrue( PRV_Cron::is_scheduled() );
|
|
}
|
|
|
|
public function test_schedule_weekly_is_idempotent(): void {
|
|
PRV_Cron::schedule_weekly();
|
|
PRV_Cron::schedule_weekly();
|
|
$events = $GLOBALS['prv_test_state']['cron_events'];
|
|
$this->assertCount( 1, $events );
|
|
}
|
|
|
|
public function test_clear_schedule_removes_event(): void {
|
|
PRV_Cron::schedule_weekly();
|
|
PRV_Cron::clear_schedule();
|
|
$this->assertFalse( PRV_Cron::is_scheduled() );
|
|
}
|
|
|
|
public function test_clear_schedule_safe_when_nothing_scheduled(): void {
|
|
PRV_Cron::clear_schedule();
|
|
$this->assertFalse( PRV_Cron::is_scheduled() );
|
|
}
|
|
|
|
public function test_register_hooks_registers_cron_hook_action(): void {
|
|
$cron = new PRV_Cron();
|
|
$cron->register_hooks();
|
|
$hooks = array_column( $GLOBALS['prv_test_state']['actions'], 'hook' );
|
|
$this->assertContains( PRV_CRON_HOOK, $hooks );
|
|
}
|
|
|
|
public function test_prv_cron_hook_constant_value(): void {
|
|
$this->assertSame( 'prv_weekly_probe', PRV_CRON_HOOK );
|
|
}
|
|
|
|
public function test_activator_schedules_cron(): void {
|
|
PRV_Activator::activate();
|
|
$this->assertTrue( PRV_Cron::is_scheduled() );
|
|
}
|
|
|
|
public function test_deactivator_clears_cron(): void {
|
|
PRV_Activator::activate();
|
|
PRV_Deactivator::deactivate();
|
|
$this->assertFalse( PRV_Cron::is_scheduled() );
|
|
}
|
|
}
|