@@ -13,6 +13,27 @@ import { recipeInputMountPathMap, rewriteInputMountPathArgs } from "../packages/
1313
1414const woocommerceAutoload = "/wordpress/wp-content/plugins/woocommerce/vendor/autoload_packages.php"
1515
16+ function phpunitRecipeArgs ( options : Omit < Parameters < typeof buildWordPressPhpunitRecipe > [ 0 ] , "pluginSlug" > ) : string [ ] {
17+ return buildWordPressPhpunitRecipe ( { pluginSlug : "demo-plugin" , ...options } ) . workflow . steps [ 0 ] . args
18+ }
19+
20+ const projectRecipeWithoutAutoload = phpunitRecipeArgs ( { bootstrapMode : "project" } )
21+ assert . ok ( projectRecipeWithoutAutoload . includes ( "autoload-file=" ) )
22+ assert . ok ( ! projectRecipeWithoutAutoload . some ( ( arg ) => arg === "autoload-file-role=harness" ) , "project mode without an autoload file must not require the harness" )
23+
24+ const managedRecipe = phpunitRecipeArgs ( { } )
25+ assert . ok ( managedRecipe . includes ( "autoload-file=/wp-codebox-vendor/autoload.php" ) )
26+ assert . ok ( managedRecipe . includes ( "autoload-file-role=harness" ) )
27+
28+ const explicitAutoloadRecipe = phpunitRecipeArgs ( {
29+ bootstrapMode : "project" ,
30+ autoloadFile : "/wp-codebox-vendor/autoload.php" ,
31+ projectAutoloadFile : "/workspace/project/vendor/autoload.php" ,
32+ } )
33+ assert . ok ( explicitAutoloadRecipe . includes ( "autoload-file=/wp-codebox-vendor/autoload.php" ) )
34+ assert . ok ( explicitAutoloadRecipe . includes ( "autoload-file-role=harness" ) )
35+ assert . ok ( explicitAutoloadRecipe . includes ( "project-autoload-file=/workspace/project/vendor/autoload.php" ) )
36+
1637function extractPhpFunction ( source : string , functionName : string ) : string {
1738 const start = source . indexOf ( `function ${ functionName } (` )
1839 assert . notEqual ( start , - 1 )
@@ -198,15 +219,15 @@ assert.deepEqual(recipe.inputs.mounts?.filter((mount) => mount.target === "/wp-c
198219] )
199220
200221assert . deepEqual ( recipe . workflow . steps [ 0 ] . args . filter ( ( arg ) => arg . includes ( "autoload-file=" ) ) , [
201- "autoload-file=/wp-codebox-vendor/autoload.php " ,
222+ "autoload-file=" ,
202223 `project-autoload-file=${ woocommerceAutoload } ` ,
203224] )
204- assert . ok ( recipe . workflow . steps [ 0 ] . args . includes ( "autoload-file-role=harness" ) , "modern PHPUnit recipes explicitly preserve harness autoload intent " )
225+ assert . ok ( ! recipe . workflow . steps [ 0 ] . args . includes ( "autoload-file-role=harness" ) , "project mode without an explicit autoload file preserves project-owned harness setup " )
205226assert . deepEqual ( rewriteInputMountPathArgs ( recipe . workflow . steps [ 0 ] . args , recipeInputMountPathMap ( recipe ) ) . filter ( ( arg ) => arg . includes ( "autoload-file=" ) ) , [
206- "autoload-file=/tmp/wp-codebox-inputs/0-wp-codebox-vendor-73845ca47d2f/autoload.php " ,
227+ "autoload-file=" ,
207228 `project-autoload-file=${ woocommerceAutoload } ` ,
208229] )
209- assert . ok ( rewriteInputMountPathArgs ( recipe . workflow . steps [ 0 ] . args , recipeInputMountPathMap ( recipe ) ) . includes ( "autoload-file-role=harness" ) , "CLI path canonicalization preserves autoload intent" )
230+ assert . ok ( ! rewriteInputMountPathArgs ( recipe . workflow . steps [ 0 ] . args , recipeInputMountPathMap ( recipe ) ) . includes ( "autoload-file-role=harness" ) , "CLI path canonicalization preserves absent harness autoload intent" )
210231assert . ok ( recipe . workflow . steps [ 0 ] . args . includes ( "cwd=/home/example/public_html" ) )
211232assert . ok ( recipe . workflow . steps [ 0 ] . args . includes ( "test-root=/home/example/public_html/bin/tests/phpunit" ) )
212233assert . ok ( recipe . workflow . steps [ 0 ] . args . includes ( "phpunit-xml=/home/example/public_html/bin/tests/phpunit/phpunit.xml.dist" ) )
0 commit comments