@@ -847,14 +847,28 @@ static function ( string $url ) use ( &$invalid_receipt_requests ): array {
847847file_put_contents ( $ archive . '/assets/app.js ' , 'console.log("spacefast") ' );
848848$ manifest = Spacefast_Static_Publisher ::manifest ( $ archive );
849849check (
850- array ( 'assets/app.js ' , 'index.html ' ) === array_column ( $ manifest , 'path ' ),
850+ array ( 'assets/app.js ' , 'index.html ' , ' sf.jsonc ' ) === array_column ( $ manifest , 'path ' ),
851851 'builds a sorted snapshot manifest from generated files '
852852);
853853check (
854854 hash_file ( 'sha256 ' , $ archive . '/index.html ' ) === $ manifest [1 ]['sha256 ' ],
855855 'hashes the generated bytes instead of trusting exporter metadata '
856856);
857857check ( 'text/javascript ' === $ manifest [0 ]['contentType ' ], 'declares generated asset media types in the publish manifest ' );
858+ check ( 'application/json ' === $ manifest [2 ]['contentType ' ], 'declares the generated Spacefast config as JSON ' );
859+ check (
860+ 'public ' === ( json_decode ( file_get_contents ( $ archive . '/sf.jsonc ' ), true )['access ' ] ?? '' ),
861+ 'makes a static WordPress export publicly readable by default '
862+ );
863+ $ custom_archive = sys_get_temp_dir () . '/spacefast-wordpress-custom-config- ' . uniqid ();
864+ mkdir ( $ custom_archive );
865+ file_put_contents ( $ custom_archive . '/index.html ' , '<h1>Custom</h1> ' );
866+ file_put_contents ( $ custom_archive . '/sf.jsonc ' , '{"access":{"public":["/docs/**"]}} ' );
867+ Spacefast_Static_Publisher ::manifest ( $ custom_archive );
868+ check (
869+ '{"access":{"public":["/docs/**"]}} ' === file_get_contents ( $ custom_archive . '/sf.jsonc ' ),
870+ 'preserves an explicit Spacefast access configuration '
871+ );
858872check ( 'image/png ' === Spacefast_Client ::content_type_for_file ( '/tmp/preview.png ' ), 'sends binary uploads with their media type ' );
859873check (
860874 'application/octet-stream ' === Spacefast_Client ::content_type_for_file ( '/tmp/unknown.custom ' ),
@@ -883,7 +897,7 @@ static function ( string $url, array $args ) use ( &$static_requests ): array {
883897 'id ' => 'upl_static ' ,
884898 'mode ' => 'dist ' ,
885899 'expiresAt ' => '2030-01-01T00:00:00.000Z ' ,
886- 'summary ' => array ( 'upload ' => 1 , 'reused ' => 0 , 'ignored ' => 0 ),
900+ 'summary ' => array ( 'upload ' => 1 , 'reused ' => 1 , 'ignored ' => 0 ),
887901 'targets ' => array (
888902 array (
889903 'path ' => 'assets/app.js ' ,
@@ -905,10 +919,10 @@ static function ( string $url, array $args ) use ( &$static_requests ): array {
905919 'id ' => 'upl_static ' ,
906920 'mode ' => 'dist ' ,
907921 'expiresAt ' => '2030-01-01T00:00:00.000Z ' ,
908- 'summary ' => array ( 'upload ' => 2 , 'reused ' => 0 , 'ignored ' => 0 ),
909- 'targets ' => array (
910- array (
911- 'path ' => 'index.html ' ,
922+ 'summary ' => array ( 'upload ' => 2 , 'reused ' => 1 , 'ignored ' => 0 ),
923+ 'targets ' => array (
924+ array (
925+ 'path ' => 'sf.jsonc ' ,
912926 'method ' => 'PUT ' ,
913927 'url ' => 'https://uploads.example.test/file ' ,
914928 'headers ' => array ( 'X-Upload ' => 'signed ' ),
@@ -945,9 +959,13 @@ static function ( string $url, string $method, array $headers, string $file ) us
945959 'attributes the published version to its public WordPress site '
946960);
947961check (
948- str_ends_with ( $ static_requests [1 ][3 ], '/index.html ' ),
962+ str_ends_with ( $ static_requests [1 ][3 ], '/sf.jsonc ' ),
949963 'uploads only the file named by the opaque server target '
950964);
965+ check (
966+ 'public ' === ( json_decode ( file_get_contents ( $ static_requests [1 ][3 ] ), true )['access ' ] ?? '' ),
967+ 'uploads the generated public-access declaration with the export '
968+ );
951969check (
952970 str_ends_with ( $ static_requests [3 ][3 ], '/assets/app.js ' ),
953971 'uploads the next opaque target after resuming '
@@ -1034,7 +1052,11 @@ public function run_static_export() { self::$runs++; return true; }
10341052unlink ( $ archive . '/assets/app.js ' );
10351053rmdir ( $ archive . '/assets ' );
10361054unlink ( $ archive . '/index.html ' );
1055+ unlink ( $ archive . '/sf.jsonc ' );
10371056rmdir ( $ archive );
1057+ unlink ( $ custom_archive . '/index.html ' );
1058+ unlink ( $ custom_archive . '/sf.jsonc ' );
1059+ rmdir ( $ custom_archive );
10381060Spacefast_Static_Publisher ::reset ();
10391061
10401062fwrite ( STDOUT , "Spacefast WordPress behavior tests: PASS \n" );
0 commit comments