(t *testing.T)
| 359 | } |
| 360 | |
| 361 | func TestGoFileGenerator_ComplexScenario(t *testing.T) { |
| 362 | sourceContent := `package example |
| 363 | |
| 364 | import ( |
| 365 | "fmt" |
| 366 | "strings" |
| 367 | "encoding/json" |
| 368 | "github.com/dunglas/frankenphp/internal/extensions/types" |
| 369 | ) |
| 370 | |
| 371 | //export_php: processData(input string, options array): array |
| 372 | func processData(input *go_string, options *go_nullable) *go_value { |
| 373 | data := CStringToGoString(input) |
| 374 | processed := internalProcess(data) |
| 375 | return types.Array([]any{processed}) |
| 376 | } |
| 377 | |
| 378 | //export_php: validateInput(data string): bool |
| 379 | func validateInput(data *go_string) *go_value { |
| 380 | input := CStringToGoString(data) |
| 381 | isValid := len(input) > 0 && validateFormat(input) |
| 382 | return types.Bool(isValid) |
| 383 | } |
| 384 | |
| 385 | func internalProcess(data string) string { |
| 386 | return strings.ToUpper(data) |
| 387 | } |
| 388 | |
| 389 | func validateFormat(input string) bool { |
| 390 | return !strings.Contains(input, "invalid") |
| 391 | } |
| 392 | |
| 393 | func jsonHelper(data any) ([]byte, error) { |
| 394 | return json.Marshal(data) |
| 395 | } |
| 396 | |
| 397 | func debugPrint(msg string) { |
| 398 | fmt.Printf("DEBUG: %s\n", msg) |
| 399 | }` |
| 400 | |
| 401 | sourceFile := createTempSourceFile(t, sourceContent) |
| 402 | |
| 403 | functions := []phpFunction{ |
| 404 | { |
| 405 | Name: "processData", |
| 406 | ReturnType: phpArray, |
| 407 | GoFunction: `func processData(input *go_string, options *go_nullable) *go_value { |
| 408 | data := CStringToGoString(input) |
| 409 | processed := internalProcess(data) |
| 410 | return Array([]any{processed}) |
| 411 | }`, |
| 412 | }, |
| 413 | { |
| 414 | Name: "validateInput", |
| 415 | ReturnType: phpBool, |
| 416 | GoFunction: `func validateInput(data *go_string) *go_value { |
| 417 | input := CStringToGoString(data) |
| 418 | isValid := len(input) > 0 && validateFormat(input) |
nothing calls this directly
no test coverage detected