(t *testing.T)
| 269 | } |
| 270 | |
| 271 | func TestBasicFunction(t *testing.T) { |
| 272 | suite := setupTest(t) |
| 273 | |
| 274 | sourceFile := filepath.Join("..", "..", "testdata", "integration", "basic_function.go") |
| 275 | sourceFile, err := filepath.Abs(sourceFile) |
| 276 | require.NoError(t, err) |
| 277 | defer suite.cleanupGeneratedFiles(sourceFile) |
| 278 | |
| 279 | targetFile, err := suite.createGoModule(sourceFile) |
| 280 | require.NoError(t, err) |
| 281 | |
| 282 | err = suite.runExtensionInit(targetFile) |
| 283 | require.NoError(t, err, "extension-init should succeed") |
| 284 | |
| 285 | baseDir := filepath.Dir(targetFile) |
| 286 | baseName := strings.TrimSuffix(filepath.Base(targetFile), ".go") |
| 287 | |
| 288 | expectedFiles := []string{ |
| 289 | baseName + ".stub.php", |
| 290 | baseName + "_arginfo.h", |
| 291 | baseName + ".h", |
| 292 | baseName + ".c", |
| 293 | baseName + ".go", |
| 294 | "README.md", |
| 295 | } |
| 296 | |
| 297 | for _, file := range expectedFiles { |
| 298 | fullPath := filepath.Join(baseDir, file) |
| 299 | assert.FileExists(t, fullPath, "Generated file should exist: %s", file) |
| 300 | } |
| 301 | |
| 302 | _, err = suite.compileFrankenPHP(filepath.Dir(targetFile)) |
| 303 | require.NoError(t, err, "FrankenPHP compilation should succeed") |
| 304 | |
| 305 | err = suite.verifyPHPSymbols( |
| 306 | []string{"test_uppercase", "test_add_numbers", "test_multiply", "test_is_enabled"}, |
| 307 | []string{}, |
| 308 | []string{}, |
| 309 | ) |
| 310 | require.NoError(t, err, "all functions should be accessible from PHP") |
| 311 | |
| 312 | err = suite.verifyFunctionBehavior(`<?php |
| 313 | $result = test_uppercase("hello world"); |
| 314 | if ($result !== "HELLO WORLD") { |
| 315 | echo "FAIL: test_uppercase expected 'HELLO WORLD', got '$result'"; |
| 316 | exit(1); |
| 317 | } |
| 318 | |
| 319 | $result = test_uppercase(""); |
| 320 | if ($result !== "") { |
| 321 | echo "FAIL: test_uppercase with empty string expected '', got '$result'"; |
| 322 | exit(1); |
| 323 | } |
| 324 | |
| 325 | $sum = test_add_numbers(5, 7); |
| 326 | if ($sum !== 12) { |
| 327 | echo "FAIL: test_add_numbers(5, 7) expected 12, got $sum"; |
| 328 | exit(1); |
nothing calls this directly
no test coverage detected