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

Function TestPrinterPrintInterface

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

Source from the content-addressed store, hash-verified

3836}
3837
3838func TestPrinterPrintInterface(t *testing.T) {
3839 o := bytes.NewBufferString("")
3840
3841 p := printer.NewPrinter(o)
3842 p.Print(&stmt.Interface{
3843 InterfaceName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
3844 Extends: &stmt.InterfaceExtends{
3845 InterfaceNames: []node.Node{
3846 &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}},
3847 &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}},
3848 },
3849 },
3850 Stmts: []node.Node{
3851 &stmt.ClassMethod{
3852 Modifiers: []node.Node{&node.Identifier{Value: "public"}},
3853 MethodName: &node.Identifier{Value: "foo"},
3854 Params: []node.Node{},
3855 Stmt: &stmt.StmtList{
3856 Stmts: []node.Node{
3857 &stmt.Expression{Expr: &expr.Variable{
3858 VarName: &node.Identifier{Value: "a"},
3859 }},
3860 },
3861 },
3862 },
3863 },
3864 })
3865
3866 expected := `interface Foo extends Bar,Baz{public function foo(){$a;}}`
3867 actual := o.String()
3868
3869 if expected != actual {
3870 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
3871 }
3872}
3873
3874func TestPrinterPrintLabel(t *testing.T) {
3875 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…