- Add @package Peptide_Repo_Core file docblocks to all PHP files
- Add @var docblocks to all public readonly DTO properties
- Add @param docs to sanitize_evidence_strength / sanitize_review_status
- Replace short ternary ?: with phpcs:ignore on each violating line
- Add phpcs:ignore for InterpolatedNotPrepared on ${table} SQL strings
- Add phpcs:ignore for GlobalVariablesOverride in uninstall.php and card.php
- Add translators comment to __ call with placeholder in related-posts-section
- Fix InlineComment.InvalidEndChar: add periods to all bare inline comments
- Expand single-line /** @return void */ docblocks with summaries
- SPLIT class-pr-core-seed-data.php (was 360 lines):
→ class-pr-core-seed-data.php (149 lines, orchestration only)
→ class-pr-core-seed-fixtures.php (254 lines, static fixture data)
- SPLIT class-pr-core-peptide-cpt.php (was 309 lines):
→ class-pr-core-peptide-cpt.php (224 lines, CPT + hooks + sanitizers)
→ class-pr-core-peptide-meta-schema.php (133 lines, meta field defs)
- SPLIT class-pr-core-settings.php (was 340 lines after docblock expansion):
→ class-pr-core-settings.php (264 lines, registration + sanitization)
→ class-pr-core-settings-renderer.php (124 lines, render methods)
- All includes/ PHP files now <= 300 lines
Agent-Session: claude-adopt-ci-20260616
127 lines
5.3 KiB
PHP
127 lines
5.3 KiB
PHP
<?php
|
|
/**
|
|
* Unit tests for PR_Core_Verification_Scanner::compute_status().
|
|
*
|
|
* Ported from tests/unit/test-verification-scanner.php.
|
|
*
|
|
* Coverage:
|
|
* - Empty last_verified → overdue.
|
|
* - Days < 90% of threshold → current.
|
|
* - Days >= 90% and < 100% → due.
|
|
* - Days >= threshold → overdue.
|
|
* - Boundary at exactly 90% → due.
|
|
* - high velocity applies 60-day threshold from option.
|
|
* - low velocity applies 365-day constant (ignores option).
|
|
* - medium/default applies 180-day threshold from option.
|
|
* - Unknown velocity falls to medium/default.
|
|
*
|
|
* @package PeptideRepoCore\Tests
|
|
*/
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* Tests for PR_Core_Verification_Scanner::compute_status().
|
|
*/
|
|
class VerificationScannerTest extends TestCase {
|
|
|
|
protected function setUp(): void {
|
|
$GLOBALS['pr_core_options'] = [];
|
|
require_once PR_CORE_PLUGIN_DIR . 'includes/scanner/class-pr-core-verification-scanner.php';
|
|
}
|
|
|
|
// ── Helper ────────────────────────────────────────────────────────.
|
|
|
|
private function days_ago( int $days ): string {
|
|
return gmdate( 'Y-m-d', time() - ( $days * DAY_IN_SECONDS ) );
|
|
}
|
|
|
|
// ── Empty last_verified ───────────────────────────────────────────.
|
|
|
|
public function test_empty_last_verified_returns_overdue(): void {
|
|
$this->assertSame(
|
|
'overdue',
|
|
PR_Core_Verification_Scanner::compute_status( '', 'medium' )
|
|
);
|
|
}
|
|
|
|
// ── Medium velocity (default 180-day threshold) ───────────────────.
|
|
|
|
public function test_medium_160_days_is_current(): void {
|
|
$this->assertSame( 'current', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 160 ), 'medium' ) );
|
|
}
|
|
|
|
public function test_medium_163_days_is_due(): void {
|
|
$this->assertSame( 'due', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 163 ), 'medium' ) );
|
|
}
|
|
|
|
public function test_medium_180_days_is_overdue(): void {
|
|
$this->assertSame( 'overdue', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 180 ), 'medium' ) );
|
|
}
|
|
|
|
public function test_medium_200_days_is_overdue(): void {
|
|
$this->assertSame( 'overdue', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 200 ), 'medium' ) );
|
|
}
|
|
|
|
// ── 90% boundary exactness ────────────────────────────────────────.
|
|
|
|
public function test_boundary_89_days_threshold_100_is_current(): void {
|
|
$GLOBALS['pr_core_options'] = [ 'pr_core_default_threshold' => 100 ];
|
|
$this->assertSame( 'current', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 89 ), 'medium' ) );
|
|
}
|
|
|
|
public function test_boundary_90_days_threshold_100_is_due(): void {
|
|
$GLOBALS['pr_core_options'] = [ 'pr_core_default_threshold' => 100 ];
|
|
$this->assertSame( 'due', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 90 ), 'medium' ) );
|
|
}
|
|
|
|
public function test_boundary_100_days_threshold_100_is_overdue(): void {
|
|
$GLOBALS['pr_core_options'] = [ 'pr_core_default_threshold' => 100 ];
|
|
$this->assertSame( 'overdue', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 100 ), 'medium' ) );
|
|
}
|
|
|
|
// ── High velocity (60-day threshold from option) ──────────────────.
|
|
|
|
public function test_high_50_days_is_current(): void {
|
|
$GLOBALS['pr_core_options'] = [ 'pr_core_high_velocity_threshold' => 60 ];
|
|
$this->assertSame( 'current', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 50 ), 'high' ) );
|
|
}
|
|
|
|
public function test_high_55_days_is_due(): void {
|
|
$GLOBALS['pr_core_options'] = [ 'pr_core_high_velocity_threshold' => 60 ];
|
|
$this->assertSame( 'due', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 55 ), 'high' ) );
|
|
}
|
|
|
|
public function test_high_61_days_is_overdue(): void {
|
|
$GLOBALS['pr_core_options'] = [ 'pr_core_high_velocity_threshold' => 60 ];
|
|
$this->assertSame( 'overdue', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 61 ), 'high' ) );
|
|
}
|
|
|
|
// ── Low velocity (365-day constant — ignores option) ──────────────.
|
|
|
|
public function test_low_300_days_is_current(): void {
|
|
$GLOBALS['pr_core_options'] = [ 'pr_core_default_threshold' => 999 ];
|
|
$this->assertSame( 'current', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 300 ), 'low' ) );
|
|
}
|
|
|
|
public function test_low_340_days_is_due(): void {
|
|
$GLOBALS['pr_core_options'] = [ 'pr_core_default_threshold' => 999 ];
|
|
$this->assertSame( 'due', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 340 ), 'low' ) );
|
|
}
|
|
|
|
public function test_low_366_days_is_overdue(): void {
|
|
$GLOBALS['pr_core_options'] = [ 'pr_core_default_threshold' => 999 ];
|
|
$this->assertSame( 'overdue', PR_Core_Verification_Scanner::compute_status( $this->days_ago( 366 ), 'low' ) );
|
|
}
|
|
|
|
// ── Unknown velocity falls to medium/default ──────────────────────.
|
|
|
|
public function test_unknown_velocity_uses_default_threshold(): void {
|
|
$GLOBALS['pr_core_options'] = [ 'pr_core_default_threshold' => 180 ];
|
|
$this->assertSame(
|
|
'current',
|
|
PR_Core_Verification_Scanner::compute_status( $this->days_ago( 100 ), 'unknown' )
|
|
);
|
|
}
|
|
}
|