(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestValidateFunction(t *testing.T) { |
| 10 | tests := []struct { |
| 11 | name string |
| 12 | function phpFunction |
| 13 | expectError bool |
| 14 | }{ |
| 15 | { |
| 16 | name: "valid function", |
| 17 | function: phpFunction{ |
| 18 | Name: "validFunction", |
| 19 | ReturnType: phpString, |
| 20 | Params: []phpParameter{ |
| 21 | {Name: "param1", PhpType: phpString}, |
| 22 | {Name: "param2", PhpType: phpInt}, |
| 23 | }, |
| 24 | }, |
| 25 | expectError: false, |
| 26 | }, |
| 27 | { |
| 28 | name: "valid function with nullable return", |
| 29 | function: phpFunction{ |
| 30 | Name: "nullableReturn", |
| 31 | ReturnType: phpString, |
| 32 | IsReturnNullable: true, |
| 33 | Params: []phpParameter{ |
| 34 | {Name: "data", PhpType: phpArray}, |
| 35 | }, |
| 36 | }, |
| 37 | expectError: false, |
| 38 | }, |
| 39 | { |
| 40 | name: "valid function with array parameter", |
| 41 | function: phpFunction{ |
| 42 | Name: "arrayFunction", |
| 43 | ReturnType: phpArray, |
| 44 | Params: []phpParameter{ |
| 45 | {Name: "items", PhpType: phpArray}, |
| 46 | {Name: "filter", PhpType: phpString}, |
| 47 | }, |
| 48 | }, |
| 49 | expectError: false, |
| 50 | }, |
| 51 | { |
| 52 | name: "valid function with nullable array parameter", |
| 53 | function: phpFunction{ |
| 54 | Name: "nullableArrayFunction", |
| 55 | ReturnType: phpString, |
| 56 | Params: []phpParameter{ |
| 57 | {Name: "items", PhpType: phpArray, IsNullable: true}, |
| 58 | {Name: "name", PhpType: phpString}, |
| 59 | }, |
| 60 | }, |
| 61 | expectError: false, |
| 62 | }, |
| 63 | { |
| 64 | name: "valid function with array parameter", |
| 65 | function: phpFunction{ |
| 66 | Name: "arrayFunction", |
nothing calls this directly
no test coverage detected