fix(ci): yoda condition + un-shadow capability-cache test expectations

- class-image-composer.php: swap the fingerprint comparison operands
  (WordPress.PHP.YodaConditions flagged the parenthesized null-coalesce
  expression on the right-hand side).
- ImageComposerTest: the two capability-cache tests asserted
  update_option calls via Functions\expect(), which the setUp
  Functions\when() stub shadows (Mockery dispatches the call to the
  first matching expectation), so the with()-matcher saw 0 calls once
  the CI runner's real imagick made the probe path live. Capture calls
  with a when() alias instead (the suite's house pattern) and assert on
  the captured writes - including autoload=false and the rewritten
  fingerprint. The matching-fingerprint test now genuinely asserts
  zero writes instead of a trivially-satisfied never().

No composer behavior change beyond the operand swap.

Agent-Session: engineer-prautoblogger-image-composer-20260611
This commit is contained in:
peptiderepo
2026-06-11 12:45:43 +07:00
parent 28947a0caa
commit 6f76df1ba5
2 changed files with 26 additions and 18 deletions

View File

@@ -176,7 +176,7 @@ class PRAutoBlogger_Image_Composer implements PRAutoBlogger_Image_Composer_Inter
);
$cached = get_option( self::OPTION_CAPABILITY, array() );
if ( is_array( $cached ) && $fingerprint === ( $cached['fingerprint'] ?? '' ) && isset( $cached['capability'] ) ) {
if ( is_array( $cached ) && ( $cached['fingerprint'] ?? '' ) === $fingerprint && isset( $cached['capability'] ) ) {
$capability = (string) $cached['capability'];
} else {
$capability = $this->probe_capability();