| 511 | } |
| 512 | |
| 513 | func TestClassParserGoTypeMismatch(t *testing.T) { |
| 514 | tests := []struct { |
| 515 | name string |
| 516 | input string |
| 517 | expectedClasses int |
| 518 | expectedMethods int |
| 519 | hasWarning bool |
| 520 | }{ |
| 521 | { |
| 522 | name: "method parameter count mismatch should be rejected", |
| 523 | input: `package main |
| 524 | |
| 525 | //export_php:class TestClass |
| 526 | type TestClass struct { |
| 527 | Name string |
| 528 | } |
| 529 | |
| 530 | //export_php:method TestClass::countMismatch(string $name, int $count): string |
| 531 | func (tc *TestClass) countMismatch(name *C.zend_string) unsafe.Pointer { |
| 532 | return nil |
| 533 | }`, |
| 534 | expectedClasses: 1, |
| 535 | expectedMethods: 0, |
| 536 | hasWarning: true, |
| 537 | }, |
| 538 | { |
| 539 | name: "method parameter type mismatch should be rejected", |
| 540 | input: `package main |
| 541 | |
| 542 | //export_php:class TestClass |
| 543 | type TestClass struct { |
| 544 | Name string |
| 545 | } |
| 546 | |
| 547 | //export_php:method TestClass::typeMismatch(string $name, int $count): string |
| 548 | func (tc *TestClass) typeMismatch(name *C.zend_string, count string) unsafe.Pointer { |
| 549 | return nil |
| 550 | }`, |
| 551 | expectedClasses: 1, |
| 552 | expectedMethods: 0, |
| 553 | hasWarning: true, |
| 554 | }, |
| 555 | { |
| 556 | name: "method return type mismatch should be rejected", |
| 557 | input: `package main |
| 558 | |
| 559 | //export_php:class TestClass |
| 560 | type TestClass struct { |
| 561 | Name string |
| 562 | } |
| 563 | |
| 564 | //export_php:method TestClass::returnMismatch(string $name): int |
| 565 | func (tc *TestClass) returnMismatch(name *C.zend_string) string { |
| 566 | return "" |
| 567 | }`, |
| 568 | expectedClasses: 1, |
| 569 | expectedMethods: 0, |
| 570 | hasWarning: true, |