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:
@@ -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'. */
|
||||
|
||||
Reference in New Issue
Block a user