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

Function TestPrinterPrintTrait

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

Source from the content-addressed store, hash-verified

4331}
4332
4333func TestPrinterPrintTrait(t *testing.T) {
4334 o := bytes.NewBufferString("")
4335
4336 p := printer.NewPrinter(o)
4337 p.Print(&stmt.Trait{
4338 TraitName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
4339 Stmts: []node.Node{
4340 &stmt.ClassMethod{
4341 Modifiers: []node.Node{&node.Identifier{Value: "public"}},
4342 MethodName: &node.Identifier{Value: "foo"},
4343 Params: []node.Node{},
4344 Stmt: &stmt.StmtList{
4345 Stmts: []node.Node{
4346 &stmt.Expression{Expr: &expr.Variable{
4347 VarName: &node.Identifier{Value: "a"},
4348 }},
4349 },
4350 },
4351 },
4352 },
4353 })
4354
4355 expected := `trait Foo{public function foo(){$a;}}`
4356 actual := o.String()
4357
4358 if expected != actual {
4359 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
4360 }
4361}
4362
4363func TestPrinterPrintStmtTry(t *testing.T) {
4364 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…