|
| 1 | +<?php |
| 2 | + |
| 3 | +define( 'ABSPATH', __DIR__ ); |
| 4 | + |
| 5 | +require_once __DIR__ . '/../packages/wordpress-plugin/src/trait-wp-codebox-abilities-browser-blueprint.php'; |
| 6 | + |
| 7 | +final class WP_Codebox_Post_Runtime_Blueprint_Smoke { |
| 8 | + use WP_Codebox_Abilities_Browser_Blueprint; |
| 9 | + |
| 10 | + /** @param array<string,mixed> $blueprint @param array<string,mixed> $post_runtime @return array<string,mixed> */ |
| 11 | + public static function merge( array $blueprint, array $post_runtime ): array { |
| 12 | + $method = new ReflectionMethod( self::class, 'browser_blueprint_with_post_runtime' ); |
| 13 | + return $method->invoke( null, $blueprint, $post_runtime ); |
| 14 | + } |
| 15 | +} |
| 16 | + |
| 17 | +$runtime_blueprint = array( |
| 18 | + 'preferredVersions' => array( 'php' => '8.3' ), |
| 19 | + 'features' => array( 'networking' => false ), |
| 20 | + 'steps' => array( |
| 21 | + array( 'step' => 'login' ), |
| 22 | + array( 'step' => 'installPlugin', 'pluginData' => array( 'url' => 'runtime.zip' ) ), |
| 23 | + ), |
| 24 | +); |
| 25 | +$post_runtime = array( |
| 26 | + 'features' => array( 'networking' => true ), |
| 27 | + 'steps' => array( array( 'step' => 'runPHP', 'code' => '<?php import_site();' ) ), |
| 28 | +); |
| 29 | + |
| 30 | +$merged = WP_Codebox_Post_Runtime_Blueprint_Smoke::merge( $runtime_blueprint, $post_runtime ); |
| 31 | +$steps = array_column( $merged['steps'] ?? array(), 'step' ); |
| 32 | + |
| 33 | +if ( array( 'login', 'installPlugin', 'runPHP' ) !== $steps ) { |
| 34 | + fwrite( STDERR, 'Post-runtime blueprint steps were not appended after runtime materialization.' . PHP_EOL ); |
| 35 | + exit( 1 ); |
| 36 | +} |
| 37 | +if ( true !== ( $merged['features']['networking'] ?? null ) ) { |
| 38 | + fwrite( STDERR, 'Post-runtime blueprint features did not override the base feature.' . PHP_EOL ); |
| 39 | + exit( 1 ); |
| 40 | +} |
| 41 | +if ( $runtime_blueprint !== WP_Codebox_Post_Runtime_Blueprint_Smoke::merge( $runtime_blueprint, array() ) ) { |
| 42 | + fwrite( STDERR, 'Empty post-runtime blueprint should preserve the runtime blueprint.' . PHP_EOL ); |
| 43 | + exit( 1 ); |
| 44 | +} |
| 45 | + |
| 46 | +fwrite( STDOUT, 'OK: post-runtime blueprint ordering smoke passed.' . PHP_EOL ); |
0 commit comments