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

Function TestPrintInterface

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

Source from the content-addressed store, hash-verified

3427}
3428
3429func TestPrintInterface(t *testing.T) {
3430 o := bytes.NewBufferString("")
3431
3432 p := printer.NewPrettyPrinter(o, " ")
3433 p.Print(&stmt.Namespace{
3434 Stmts: []node.Node{
3435 &stmt.Interface{
3436 InterfaceName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Foo"}}},
3437 Extends: &stmt.InterfaceExtends{
3438 InterfaceNames: []node.Node{
3439 &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}},
3440 &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}},
3441 },
3442 },
3443 Stmts: []node.Node{
3444 &stmt.ClassMethod{
3445 Modifiers: []node.Node{&node.Identifier{Value: "public"}},
3446 MethodName: &node.Identifier{Value: "foo"},
3447 Params: []node.Node{},
3448 Stmt: &stmt.StmtList{
3449 Stmts: []node.Node{
3450 &stmt.Expression{Expr: &expr.Variable{VarName: &node.Identifier{Value: "a"}}},
3451 },
3452 },
3453 },
3454 },
3455 },
3456 },
3457 })
3458
3459 expected := `namespace {
3460 interface Foo extends Bar, Baz
3461 {
3462 public function foo()
3463 {
3464 $a;
3465 }
3466 }
3467}`
3468 actual := o.String()
3469
3470 if expected != actual {
3471 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
3472 }
3473}
3474
3475func TestPrintLabel(t *testing.T) {
3476 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…