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

Function TestPrintMethodCall

printer/pretty_printer_test.go:1648–1673  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1646}
1647
1648func TestPrintMethodCall(t *testing.T) {
1649 o := bytes.NewBufferString("")
1650
1651 p := printer.NewPrettyPrinter(o, " ")
1652 p.Print(&expr.MethodCall{
1653 Variable: &expr.Variable{VarName: &node.Identifier{Value: "foo"}},
1654 Method: &node.Identifier{Value: "bar"},
1655 ArgumentList: &node.ArgumentList{
1656 Arguments: []node.Node{
1657 &node.Argument{
1658 Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}},
1659 },
1660 &node.Argument{
1661 Expr: &expr.Variable{VarName: &node.Identifier{Value: "b"}},
1662 },
1663 },
1664 },
1665 })
1666
1667 expected := `$foo->bar($a, $b)`
1668 actual := o.String()
1669
1670 if expected != actual {
1671 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
1672 }
1673}
1674
1675func TestPrintNew(t *testing.T) {
1676 o := bytes.NewBufferString("")

Callers

nothing calls this directly

Calls 3

PrintMethod · 0.95
NewPrettyPrinterFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…