Adopt reusable CI standard + PHPUnit suite (#8)
* feat(ci): adopt estate CI + add PHPUnit suite from scratch (v1.2.0) - Add PHPUnit 9.6 test suite (WP stubs, tests: stubs) — 40 tests across 4 files: MathTest: 25 tests covering all PRC_Math public methods and calculate() orchestrator with real peptide scenarios (BPC-157/TB-500/Semaglutide/MK-677/ Ipamorelin) plus edge cases (zero water, negative inputs, floor rounding, rounding precision, mcg↔mg conversion). DefaultPresetsTest: 11 tests — all 8 expected slugs, required keys per preset (dataProvider), dose_unit validity, min<max range, source field, spot-checks. RestControllerTest: 7 tests — calculate() 200 + correct values (mcg+mg), get_presets() 200, get_preset() 200 for known slug / WP_Error for unknown. PresetProviderTest: 4 tests — fallback to defaults sans PR Core, slug key present, cache invalidation, idempotent invalidation. - Add phpunit.xml.dist + tests/bootstrap.php (WP function/class stubs). - Add composer test script: vendor/bin/phpunit --configuration phpunit.xml.dist. - Add phpunit/phpunit ^9.6 + yoast/phpunit-polyfills ^2.0 to require-dev. - Replace standalone ci.yml with thin caller to estate reusable workflow: uses: peptiderepo/peptide-e2e/.github/workflows/ci.yml@main with: tests: stubs, has_js: true permissions: contents: write (required for phpcbf commit-back) workflow_call (required for deploy.yml gate). - deploy.yml unchanged — already gates on ./ci.yml + uses shared deploy-app.yml. - Version bump 1.1.0 → 1.2.0. Agent-Session: claude/adopt-ci-20260616 * style: auto-fix PHPCS violations via phpcbf * fix(ci): resolve latent PHPCS + JS lint failures Latent debt surfaced by the reusable PHPCS job (previously continue-on-error). PHPCS fixes (all pre-existing, not introduced by this PR): - Add @package PeptideReconstitutionCalculator to file docblocks in all 12 PHP files (previously missing; phpcbf cannot insert missing docblock tags). - Replace two short-ternary ?: operators in class-prc-preset-provider.php with full ternary (Universal.Operators.DisallowShortTernary.Found; lines 136+152). JS lint fix: - Add package.json + package-lock.json (no deps; lint script = node --check) so the reusable lint-js job's npm ci / cache: npm steps succeed. The calculator ships vanilla JS with no build toolchain — package.json is the minimal stub the reusable workflow requires for has_js: true. Agent-Session: claude/adopt-ci-20260616 * style: auto-fix PHPCS violations via phpcbf * fix(phpcs): suppress intentional warnings with phpcs:ignore annotations uninstall.php: direct wpdb->query() intentional in uninstall (no caching available); add phpcs:ignore DirectDatabaseQuery.DirectQuery and NoCaching. class-prc-rest-controller.php get_presets(): request param required by WP REST API callback contract; add phpcs:ignore UnusedFunctionParameter. Agent-Session: claude/adopt-ci-20260616 --------- Co-authored-by: peptiderepo <bot@peptiderepo.com> Co-authored-by: peptiderepo <peptiderepo@users.noreply.github.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
* Dependencies: None.
|
||||
*
|
||||
* @see class-prc-preset-provider.php — Merges these with live PR Core data.
|
||||
* @package PeptideReconstitutionCalculator
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
@@ -27,11 +28,11 @@ class PRC_Default_Presets {
|
||||
* @return array<int, array<string, mixed>>
|
||||
*/
|
||||
public static function get_all(): array {
|
||||
return [
|
||||
[
|
||||
return array(
|
||||
array(
|
||||
'slug' => 'bpc-157',
|
||||
'name' => 'BPC-157',
|
||||
'vial_sizes_mg' => [ 5, 10 ],
|
||||
'vial_sizes_mg' => array( 5, 10 ),
|
||||
'default_vial_mg' => 5,
|
||||
'recommended_water_ml' => 2.0,
|
||||
'dose_range_min' => 200,
|
||||
@@ -41,11 +42,11 @@ class PRC_Default_Presets {
|
||||
'evidence_strength' => 'observational',
|
||||
'dosing_row_count' => 0,
|
||||
'source' => 'default',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'slug' => 'tb-500',
|
||||
'name' => 'TB-500',
|
||||
'vial_sizes_mg' => [ 2, 5, 10 ],
|
||||
'vial_sizes_mg' => array( 2, 5, 10 ),
|
||||
'default_vial_mg' => 5,
|
||||
'recommended_water_ml' => 2.0,
|
||||
'dose_range_min' => 2000,
|
||||
@@ -55,11 +56,11 @@ class PRC_Default_Presets {
|
||||
'evidence_strength' => 'preclinical',
|
||||
'dosing_row_count' => 0,
|
||||
'source' => 'default',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'slug' => 'semaglutide',
|
||||
'name' => 'Semaglutide',
|
||||
'vial_sizes_mg' => [ 2, 5, 10 ],
|
||||
'vial_sizes_mg' => array( 2, 5, 10 ),
|
||||
'default_vial_mg' => 5,
|
||||
'recommended_water_ml' => 2.0,
|
||||
'dose_range_min' => 0.25,
|
||||
@@ -69,11 +70,11 @@ class PRC_Default_Presets {
|
||||
'evidence_strength' => 'meta-analysis',
|
||||
'dosing_row_count' => 0,
|
||||
'source' => 'default',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'slug' => 'cjc-1295-dac',
|
||||
'name' => 'CJC-1295 (DAC)',
|
||||
'vial_sizes_mg' => [ 2, 5 ],
|
||||
'vial_sizes_mg' => array( 2, 5 ),
|
||||
'default_vial_mg' => 2,
|
||||
'recommended_water_ml' => 1.0,
|
||||
'dose_range_min' => 1000,
|
||||
@@ -83,11 +84,11 @@ class PRC_Default_Presets {
|
||||
'evidence_strength' => 'preclinical',
|
||||
'dosing_row_count' => 0,
|
||||
'source' => 'default',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'slug' => 'ipamorelin',
|
||||
'name' => 'Ipamorelin',
|
||||
'vial_sizes_mg' => [ 2, 5 ],
|
||||
'vial_sizes_mg' => array( 2, 5 ),
|
||||
'default_vial_mg' => 5,
|
||||
'recommended_water_ml' => 2.0,
|
||||
'dose_range_min' => 100,
|
||||
@@ -97,11 +98,11 @@ class PRC_Default_Presets {
|
||||
'evidence_strength' => 'preclinical',
|
||||
'dosing_row_count' => 0,
|
||||
'source' => 'default',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'slug' => 'pt-141',
|
||||
'name' => 'PT-141 (Bremelanotide)',
|
||||
'vial_sizes_mg' => [ 2, 10 ],
|
||||
'vial_sizes_mg' => array( 2, 10 ),
|
||||
'default_vial_mg' => 10,
|
||||
'recommended_water_ml' => 2.0,
|
||||
'dose_range_min' => 500,
|
||||
@@ -111,11 +112,11 @@ class PRC_Default_Presets {
|
||||
'evidence_strength' => 'rct-large',
|
||||
'dosing_row_count' => 0,
|
||||
'source' => 'default',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'slug' => 'mk-677',
|
||||
'name' => 'MK-677 (Ibutamoren)',
|
||||
'vial_sizes_mg' => [ 15, 30 ],
|
||||
'vial_sizes_mg' => array( 15, 30 ),
|
||||
'default_vial_mg' => 30,
|
||||
'recommended_water_ml' => 3.0,
|
||||
'dose_range_min' => 10,
|
||||
@@ -125,11 +126,11 @@ class PRC_Default_Presets {
|
||||
'evidence_strength' => 'rct-small',
|
||||
'dosing_row_count' => 0,
|
||||
'source' => 'default',
|
||||
],
|
||||
[
|
||||
),
|
||||
array(
|
||||
'slug' => 'ghrp-6',
|
||||
'name' => 'GHRP-6',
|
||||
'vial_sizes_mg' => [ 5, 10 ],
|
||||
'vial_sizes_mg' => array( 5, 10 ),
|
||||
'default_vial_mg' => 5,
|
||||
'recommended_water_ml' => 2.0,
|
||||
'dose_range_min' => 100,
|
||||
@@ -139,7 +140,7 @@ class PRC_Default_Presets {
|
||||
'evidence_strength' => 'preclinical',
|
||||
'dosing_row_count' => 0,
|
||||
'source' => 'default',
|
||||
],
|
||||
];
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user