fix(maintenance): v0.19.4 — composer GD-rung tests, layout-key cleanup, carried P3s (#160)
QA: APPROVE-WITH-P2-NOTES @ c0929be (qa-reviews/prautoblogger/2026-06-12-c0929be.md)
CEO greenlight: 2026-06-12 in chat.
Agent-Session: cto-maint-v0194-merge-20260612
This commit is contained in:
@@ -322,4 +322,43 @@ class ImageComposerTest extends BaseTestCase {
|
||||
$this->assertStringStartsWith( 'prautoblogger_', $key );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ladder rung 2 forced via the override filter ('gd'): compose() emits the
|
||||
* pass-through featured variant as first element, and fires exactly one WARNING.
|
||||
* The Imagick renderer must never be called on this rung.
|
||||
*
|
||||
* Source: QA verdict 2026-06-11-6f76df1.md P2-1 and CTO handoff
|
||||
* convo/prautoblogger/threads/2026-06-maintenance-v0194/01-cto-maintenance-handoff.md item 1.
|
||||
*/
|
||||
public function test_gd_rung_emits_passthrough_featured_and_single_warning(): void {
|
||||
Filters\expectApplied( 'prautoblogger_image_compose_capability' )->andReturn( 'gd' );
|
||||
|
||||
// Imagick renderer must not be invoked on the gd rung.
|
||||
$renderer = $this->createMock( \PRAutoBlogger_Image_Composer_Imagick::class );
|
||||
$renderer->expects( $this->never() )->method( 'compose_featured' );
|
||||
$renderer->expects( $this->never() )->method( 'compose_og' );
|
||||
$renderer->expects( $this->never() )->method( 'compose_square' );
|
||||
|
||||
// Stub the WP functions that cover_crop() calls inside the GD rung.
|
||||
// get_temp_dir() is called first; wp_get_image_editor() returning WP_Error
|
||||
// makes cover_crop() return null for every role → compose_variants() returns []
|
||||
// → the GD rung emits only the pass-through featured (array_merge($passthrough, [])).
|
||||
// This is the real degradation-to-passthrough path the test is designed to assert.
|
||||
Functions\when( 'get_temp_dir' )->justReturn( sys_get_temp_dir() . '/' );
|
||||
Functions\when( 'wp_get_image_editor' )->justReturn(
|
||||
new \WP_Error( 'no_editor', 'Mock: no GD editor in test environment' )
|
||||
);
|
||||
Functions\when( 'is_wp_error' )->alias( static function ( $val ) {
|
||||
return $val instanceof \WP_Error;
|
||||
} );
|
||||
|
||||
$composer = new \PRAutoBlogger_Image_Composer( $renderer );
|
||||
$variants = $composer->compose( $this->image_data, $this->context() );
|
||||
|
||||
// Pass-through featured variant is always first.
|
||||
$this->assertNotEmpty( $variants );
|
||||
$this->assertSame( 'featured', $variants[0]['role'] );
|
||||
$this->assertSame( 'raw_base_bytes', $variants[0]['bytes'] );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user