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

Function TestCFileIntegrationWithGenerators

internal/extgen/cfile_test.go:206–276  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

204}
205
206func TestCFileIntegrationWithGenerators(t *testing.T) {
207 tmpDir := t.TempDir()
208
209 functions := []phpFunction{
210 {
211 Name: "processData",
212 ReturnType: phpArray,
213 IsReturnNullable: true,
214 Params: []phpParameter{
215 {Name: "input", PhpType: phpString},
216 {Name: "options", PhpType: phpArray, HasDefault: true, DefaultValue: "[]"},
217 {Name: "callback", PhpType: phpObject, IsNullable: true},
218 },
219 },
220 {
221 Name: "validateInput",
222 ReturnType: phpBool,
223 Params: []phpParameter{
224 {Name: "data", PhpType: phpString, IsNullable: true},
225 {Name: "strict", PhpType: phpBool, HasDefault: true, DefaultValue: "false"},
226 },
227 },
228 }
229
230 classes := []phpClass{
231 {
232 Name: "DataProcessor",
233 GoStruct: "DataProcessorStruct",
234 Properties: []phpClassProperty{
235 {Name: "mode", PhpType: phpString},
236 {Name: "timeout", PhpType: phpInt, IsNullable: true},
237 {Name: "options", PhpType: phpArray},
238 },
239 },
240 {
241 Name: "Result",
242 GoStruct: "ResultStruct",
243 Properties: []phpClassProperty{
244 {Name: "success", PhpType: phpBool},
245 {Name: "data", PhpType: phpMixed, IsNullable: true},
246 {Name: "errors", PhpType: phpArray},
247 },
248 },
249 }
250
251 generator := &Generator{
252 BaseName: "integration_test",
253 BuildDir: tmpDir,
254 Functions: functions,
255 Classes: classes,
256 }
257
258 cGen := cFileGenerator{generator}
259 require.NoError(t, cGen.generate())
260
261 content, err := readFile(filepath.Join(tmpDir, "integration_test.c"))
262 require.NoError(t, err)
263

Callers

nothing calls this directly

Calls 2

generateMethod · 0.95
readFileFunction · 0.85

Tested by

no test coverage detected