(t *testing.T)
| 237 | } |
| 238 | |
| 239 | func TestValidateClassProperty(t *testing.T) { |
| 240 | tests := []struct { |
| 241 | name string |
| 242 | prop phpClassProperty |
| 243 | expectError bool |
| 244 | }{ |
| 245 | { |
| 246 | name: "valid property", |
| 247 | prop: phpClassProperty{ |
| 248 | Name: "validProperty", |
| 249 | PhpType: phpString, |
| 250 | GoType: "string", |
| 251 | }, |
| 252 | expectError: false, |
| 253 | }, |
| 254 | { |
| 255 | name: "valid nullable property", |
| 256 | prop: phpClassProperty{ |
| 257 | Name: "nullableProperty", |
| 258 | PhpType: phpInt, |
| 259 | GoType: "*int", |
| 260 | IsNullable: true, |
| 261 | }, |
| 262 | expectError: false, |
| 263 | }, |
| 264 | { |
| 265 | name: "empty property name", |
| 266 | prop: phpClassProperty{ |
| 267 | Name: "", |
| 268 | PhpType: phpString, |
| 269 | }, |
| 270 | expectError: true, |
| 271 | }, |
| 272 | { |
| 273 | name: "invalid property name", |
| 274 | prop: phpClassProperty{ |
| 275 | Name: "123invalid", |
| 276 | PhpType: phpString, |
| 277 | }, |
| 278 | expectError: true, |
| 279 | }, |
| 280 | { |
| 281 | name: "invalid property type", |
| 282 | prop: phpClassProperty{ |
| 283 | Name: "validName", |
| 284 | PhpType: phpType("invalidType"), |
| 285 | }, |
| 286 | expectError: true, |
| 287 | }, |
| 288 | } |
| 289 | |
| 290 | validator := Validator{} |
| 291 | for _, tt := range tests { |
| 292 | t.Run(tt.name, func(t *testing.T) { |
| 293 | err := validator.validateClassProperty(tt.prop) |
| 294 | |
| 295 | if tt.expectError { |
| 296 | assert.Error(t, err, "validateClassProperty() should return an error") |
nothing calls this directly
no test coverage detected