MCPcopy Index your code
hub / github.com/php/frankenphp / TestGoFileGenerator_BuildContent

Function TestGoFileGenerator_BuildContent

internal/extgen/gofile_test.go:90–283  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func TestGoFileGenerator_BuildContent(t *testing.T) {
91 tests := []struct {
92 name string
93 baseName string
94 sourceFile string
95 functions []phpFunction
96 classes []phpClass
97 contains []string
98 notContains []string
99 }{
100 {
101 name: "simple extension",
102 baseName: "simple",
103 sourceFile: createTempSourceFile(t, `package main
104
105//export_php: test(): void
106func test() {
107 // simple function
108}`),
109 functions: []phpFunction{
110 {
111 Name: "test",
112 ReturnType: phpVoid,
113 GoFunction: "func test() {\n\t// simple function\n}",
114 },
115 },
116 contains: []string{
117 "package main",
118 `#include "simple.h"`,
119 `import "C"`,
120 "func init()",
121 "frankenphp.RegisterExtension(",
122 "//export go_test",
123 "func go_test()",
124 "test()", // wrapper calls original function
125 },
126 },
127 {
128 name: "extension with complex imports",
129 baseName: "complex",
130 sourceFile: createTempSourceFile(t, `package main
131
132import (
133 "fmt"
134 "strings"
135 "encoding/json"
136 "github.com/dunglas/frankenphp/internal/extensions/types"
137)
138
139//export_php: process(data string): string
140func process(data *go_string) *go_value {
141 return types.String(fmt.Sprintf("processed: %s", CStringToGoString(data)))
142}`),
143 functions: []phpFunction{
144 {
145 Name: "process",
146 ReturnType: phpString,
147 GoFunction: `func process(data *go_string) *go_value {

Callers

nothing calls this directly

Calls 2

buildContentMethod · 0.95
createTempSourceFileFunction · 0.85

Tested by

no test coverage detected