|
| 1 | +<?php |
| 2 | +function envlite_test_make_fixture_repo(): string { |
| 3 | + $dir = envlite_test_tmpdir('smoke'); |
| 4 | + // Minimum tree to satisfy Phase 0's CWD check and Phases 5–8. |
| 5 | + mkdir("$dir/src/wp-includes", 0755, true); |
| 6 | + mkdir("$dir/tests/phpunit/includes", 0755, true); |
| 7 | + mkdir("$dir/src/wp-content/plugins/sqlite-database-integration", 0755, true); |
| 8 | + file_put_contents("$dir/package.json", '{}'); |
| 9 | + file_put_contents("$dir/composer.json", '{}'); |
| 10 | + file_put_contents("$dir/tests/phpunit/includes/bootstrap.php", '<?php'); |
| 11 | + // Real samples, copied from the test repo so substitutions are exercised. |
| 12 | + $repoRoot = dirname(__DIR__, 3); |
| 13 | + copy("$repoRoot/wp-config-sample.php", "$dir/wp-config-sample.php"); |
| 14 | + copy("$repoRoot/wp-tests-config-sample.php", "$dir/wp-tests-config-sample.php"); |
| 15 | + // Pre-stage the SQLite plugin so Phase 5 hits the skip-download branch. |
| 16 | + file_put_contents( |
| 17 | + "$dir/src/wp-content/plugins/sqlite-database-integration/db.copy", |
| 18 | + "<?php\n// {SQLITE_IMPLEMENTATION_FOLDER_PATH}\nreturn 'stub';\n" |
| 19 | + ); |
| 20 | + return $dir; |
| 21 | +} |
| 22 | + |
| 23 | +function test_smoke_phases5_through_8_then_clean() { |
| 24 | + $dir = envlite_test_make_fixture_repo(); |
| 25 | + |
| 26 | + // Pre-record the plugin tree as envlite-owned so Phase 5 takes the skip branch. |
| 27 | + $manifest = ['src/wp-content/plugins/sqlite-database-integration' => 'dir']; |
| 28 | + envlite_manifest_save($dir, $manifest); |
| 29 | + |
| 30 | + // Drive Phases 5–8 with --force (no TTY in test). |
| 31 | + envlite_phase5_install($dir, true); |
| 32 | + envlite_phase6_install($dir, true); |
| 33 | + envlite_phase7_install($dir, 8421, true); |
| 34 | + envlite_phase8_install($dir, true); |
| 35 | + |
| 36 | + // Assert artifacts present. |
| 37 | + envlite_assert(is_file("$dir/src/wp-content/db.php")); |
| 38 | + envlite_assert(is_file("$dir/wp-tests-config.php")); |
| 39 | + envlite_assert(is_file("$dir/src/wp-config.php")); |
| 40 | + envlite_assert(is_file("$dir/router.php")); |
| 41 | + |
| 42 | + // Manifest contains all four file entries plus the plugin dir. |
| 43 | + $m = envlite_manifest_load($dir); |
| 44 | + envlite_assert(isset($m['src/wp-content/db.php'])); |
| 45 | + envlite_assert(isset($m['wp-tests-config.php'])); |
| 46 | + envlite_assert(isset($m['src/wp-config.php'])); |
| 47 | + envlite_assert(isset($m['router.php'])); |
| 48 | + envlite_assert(isset($m['src/wp-content/plugins/sqlite-database-integration'])); |
| 49 | + |
| 50 | + // wp-config.php picked up the port. |
| 51 | + envlite_assert(str_contains(file_get_contents("$dir/src/wp-config.php"), 'http://127.0.0.1:8421')); |
| 52 | + |
| 53 | + // Now drive clean (force, no TTY). |
| 54 | + $paths = envlite_clean_collect($m); |
| 55 | + envlite_clean_apply($dir, $paths); |
| 56 | + @unlink("$dir/.envlite/manifest"); |
| 57 | + @rmdir("$dir/.envlite"); |
| 58 | + |
| 59 | + envlite_assert(!is_file("$dir/router.php")); |
| 60 | + envlite_assert(!is_file("$dir/wp-tests-config.php")); |
| 61 | + envlite_assert(!is_file("$dir/src/wp-config.php")); |
| 62 | + envlite_assert(!is_file("$dir/src/wp-content/db.php")); |
| 63 | + envlite_assert(!is_dir("$dir/src/wp-content/plugins/sqlite-database-integration")); |
| 64 | + envlite_assert(!is_dir("$dir/.envlite")); |
| 65 | +} |
0 commit comments