package builders import ( "archive/zip" "context" "os" "runtime" "strings" "testing" "dappco.re/go/core/build/internal/ax" "dappco.re/go/core/build/pkg/build" "dappco.re/go/core/io" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) func setupFakePHPToolchain(t *testing.T, binDir string) { t.Helper() script := `#!/bin/sh set -eu log_file="${PHP_BUILD_LOG_FILE:-}" if [ -n "$log_file" ]; then printf '%s\n' "$(basename "$0")" >> "$log_file" printf '%s\n' "$@" >> "$log_file" printf '%s\n' "GOOS=${GOOS:-}" >> "$log_file" printf '%s\n' "GOARCH=${GOARCH:-}" >> "$log_file" printf '%s\n' "OUTPUT_DIR=${OUTPUT_DIR:-}" >> "$log_file" printf '%s\n' "TARGET_DIR=${TARGET_DIR:-}" >> "$log_file" env | sort >> "$log_file" fi output_dir="${OUTPUT_DIR:-dist}" platform_dir="${TARGET_DIR:-$output_dir/${GOOS:-}_${GOARCH:-}}" mkdir -p "$platform_dir" if [ "${1:-}" = "run-script" ] && [ "${2:-}" = "build" ]; then artifact="${platform_dir}/${NAME:-phpapp}" printf 'fake php artifact\n' > "$artifact" chmod +x "$artifact" fi ` require.NoError(t, ax.WriteFile(ax.Join(binDir, "composer"), []byte(script), 0o755)) } func setupPHPTestProject(t *testing.T, withBuildScript bool) string { t.Helper() dir := t.TempDir() composerJSON := `{"name":"test/php-app"}` if withBuildScript { composerJSON = `{"name":"test/php-app","scripts":{"build":"php build.php"}}` } require.NoError(t, ax.WriteFile(ax.Join(dir, "composer.json"), []byte(composerJSON), 0o644)) require.NoError(t, ax.WriteFile(ax.Join(dir, "index.php"), []byte("