MCPcopy Create free account
hub / github.com/php/frankenphp / TestParameterParser_Integration

Function TestParameterParser_Integration

internal/extgen/paramparser_test.go:645–674  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

643}
644
645func TestParameterParser_Integration(t *testing.T) {
646 pp := &ParameterParser{}
647
648 params := []phpParameter{
649 {Name: "name", PhpType: phpString, HasDefault: false},
650 {Name: "count", PhpType: phpInt, HasDefault: true, DefaultValue: "10"},
651 {Name: "enabled", PhpType: phpBool, HasDefault: true, DefaultValue: "true"},
652 }
653
654 info := pp.analyzeParameters(params)
655 assert.Equal(t, 1, info.RequiredCount)
656 assert.Equal(t, 3, info.TotalCount)
657
658 declarations := pp.generateParamDeclarations(params)
659 expectedDeclarations := []string{
660 "zend_string *name = NULL;",
661 "zend_long count = 10;",
662 "zend_bool enabled = 1;",
663 }
664 for _, expected := range expectedDeclarations {
665 assert.Contains(t, declarations, expected)
666 }
667
668 parsing := pp.generateParamParsing(params, info.RequiredCount)
669 assert.Contains(t, parsing, "ZEND_PARSE_PARAMETERS_START(1, 3)")
670 assert.Contains(t, parsing, "Z_PARAM_OPTIONAL")
671
672 goCallParams := pp.generateGoCallParams(params)
673 assert.Equal(t, "name, (long) count, (int) enabled", goCallParams)
674}

Callers

nothing calls this directly

Calls 4

analyzeParametersMethod · 0.95
generateParamParsingMethod · 0.95
generateGoCallParamsMethod · 0.95

Tested by

no test coverage detected