test: fix Runware tests to use real Encryption class path

The composer classmap autoloader loads the real PRAutoBlogger_Encryption
before our eval() stub runs, so class_exists() is always true and the stub
is never installed. Two consequences:

1. Provider tests set 'enc:fake-key' and the real decrypt() path ran,
   calling wp_salt() which isn't stubbed. Switched to plaintext keys
   so is_encrypted() short-circuits and no crypto runs.
2. Support test for the decrypt path now uses a real encrypt/decrypt
   round-trip with a stubbed wp_salt() returning a deterministic
   32-char salt. This exercises the actual code path users hit in
   production, not a lying stub.

Removes the dead eval() stubs that were being skipped anyway.
This commit is contained in:
peptiderepo
2026-04-21 15:59:36 +00:00
parent 2cacaa3512
commit 8bedecd2dd
2 changed files with 14 additions and 24 deletions

View File

@@ -21,7 +21,7 @@ class RunwareImageProviderTest extends BaseTestCase {
Functions\when( 'get_option' )->alias( function ( $key, $default = false ) {
static $options = [
'prautoblogger_runware_api_key' => 'enc:fake-key',
'prautoblogger_runware_api_key' => 'rw-plain-test-key',
'prautoblogger_image_model' => 'runware:100@1',
];
return $options[ $key ] ?? $default;
@@ -33,15 +33,7 @@ class RunwareImageProviderTest extends BaseTestCase {
Functions\when( 'wp_generate_uuid4' )->justReturn( '11111111-2222-3333-4444-555555555555' );
if ( ! class_exists( 'PRAutoBlogger_Encryption' ) ) {
eval( '
class PRAutoBlogger_Encryption {
public static function is_encrypted( $v ) { return 0 === strpos( $v, "enc:" ); }
public static function decrypt( $v ) { return "rw-test-key-123"; }
public static function encrypt( $v ) { return "enc:" . $v; }
}
' );
}
}
/** Provider name is 'runware'. */