(t *testing.T)
| 482 | } |
| 483 | |
| 484 | func TestValidateTypes(t *testing.T) { |
| 485 | tests := []struct { |
| 486 | name string |
| 487 | function phpFunction |
| 488 | expectError bool |
| 489 | errorMsg string |
| 490 | }{ |
| 491 | { |
| 492 | name: "valid scalar parameters only", |
| 493 | function: phpFunction{ |
| 494 | Name: "validFunction", |
| 495 | ReturnType: phpString, |
| 496 | Params: []phpParameter{ |
| 497 | {Name: "stringParam", PhpType: phpString}, |
| 498 | {Name: "intParam", PhpType: phpInt}, |
| 499 | {Name: "floatParam", PhpType: phpFloat}, |
| 500 | {Name: "boolParam", PhpType: phpBool}, |
| 501 | }, |
| 502 | }, |
| 503 | expectError: false, |
| 504 | }, |
| 505 | { |
| 506 | name: "valid nullable scalar parameters", |
| 507 | function: phpFunction{ |
| 508 | Name: "nullableFunction", |
| 509 | ReturnType: phpString, |
| 510 | Params: []phpParameter{ |
| 511 | {Name: "stringParam", PhpType: phpString, IsNullable: true}, |
| 512 | {Name: "intParam", PhpType: phpInt, IsNullable: true}, |
| 513 | }, |
| 514 | }, |
| 515 | expectError: false, |
| 516 | }, |
| 517 | { |
| 518 | name: "valid void return type", |
| 519 | function: phpFunction{ |
| 520 | Name: "voidFunction", |
| 521 | ReturnType: phpVoid, |
| 522 | Params: []phpParameter{ |
| 523 | {Name: "stringParam", PhpType: phpString}, |
| 524 | }, |
| 525 | }, |
| 526 | expectError: false, |
| 527 | }, |
| 528 | { |
| 529 | name: "valid array parameter and return", |
| 530 | function: phpFunction{ |
| 531 | Name: "arrayFunction", |
| 532 | ReturnType: phpArray, |
| 533 | Params: []phpParameter{ |
| 534 | {Name: "arrayParam", PhpType: phpArray}, |
| 535 | {Name: "stringParam", PhpType: phpString}, |
| 536 | }, |
| 537 | }, |
| 538 | expectError: false, |
| 539 | }, |
| 540 | { |
| 541 | name: "valid nullable array parameter", |
nothing calls this directly
no test coverage detected