MCPcopy Create free account
hub / github.com/php/frankenphp / createGoModule

Method createGoModule

internal/extgen/integration_test.go:62–100  ·  view source on GitHub ↗
(sourceFile string)

Source from the content-addressed store, hash-verified

60}
61
62func (s *IntegrationTestSuite) createGoModule(sourceFile string) (string, error) {
63 s.t.Helper()
64
65 moduleDir := filepath.Join(s.tempDir, "module")
66 if err := os.MkdirAll(moduleDir, 0o755); err != nil {
67 return "", fmt.Errorf("failed to create module directory: %w", err)
68 }
69
70 // Get project root for replace directive
71 projectRoot, err := filepath.Abs(filepath.Join("..", ".."))
72 if err != nil {
73 return "", fmt.Errorf("failed to get project root: %w", err)
74 }
75
76 goModContent := fmt.Sprintf(`module %s
77
78go 1.26
79
80require github.com/dunglas/frankenphp v0.0.0
81
82replace github.com/dunglas/frankenphp => %s
83`, testModuleName, projectRoot)
84
85 if err := os.WriteFile(filepath.Join(moduleDir, "go.mod"), []byte(goModContent), 0o644); err != nil {
86 return "", fmt.Errorf("failed to create go.mod: %w", err)
87 }
88
89 sourceContent, err := os.ReadFile(sourceFile)
90 if err != nil {
91 return "", fmt.Errorf("failed to read source file: %w", err)
92 }
93
94 targetFile := filepath.Join(moduleDir, filepath.Base(sourceFile))
95 if err := os.WriteFile(targetFile, sourceContent, 0o644); err != nil {
96 return "", fmt.Errorf("failed to write source file: %w", err)
97 }
98
99 return targetFile, nil
100}
101
102func (s *IntegrationTestSuite) runExtensionInit(sourceFile string) error {
103 s.t.Helper()

Callers 7

TestBasicFunctionFunction · 0.80
TestConstantsFunction · 0.80
TestNamespaceFunction · 0.80
TestInvalidSignatureFunction · 0.80
TestTypeMismatchFunction · 0.80
TestCallableFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected