MCPcopy Create free account
hub / github.com/z7zmey/php-parser / TestPrinterPrintMethodCall

Function TestPrinterPrintMethodCall

printer/printer_test.go:2042–2073  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2040}
2041
2042func TestPrinterPrintMethodCall(t *testing.T) {
2043 o := bytes.NewBufferString("")
2044
2045 p := printer.NewPrinter(o)
2046 p.Print(&expr.MethodCall{
2047 Variable: &expr.Variable{
2048 VarName: &node.Identifier{Value: "foo"},
2049 },
2050 Method: &node.Identifier{Value: "bar"},
2051 ArgumentList: &node.ArgumentList{
2052 Arguments: []node.Node{
2053 &node.Argument{
2054 Expr: &expr.Variable{
2055 VarName: &node.Identifier{Value: "a"},
2056 },
2057 },
2058 &node.Argument{
2059 Expr: &expr.Variable{
2060 VarName: &node.Identifier{Value: "b"},
2061 },
2062 },
2063 },
2064 },
2065 })
2066
2067 expected := `$foo->bar($a,$b)`
2068 actual := o.String()
2069
2070 if expected != actual {
2071 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
2072 }
2073}
2074
2075func TestPrinterPrintNew(t *testing.T) {
2076 o := bytes.NewBufferString("")

Callers

nothing calls this directly

Calls 3

PrintMethod · 0.95
NewPrinterFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…