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

Function TestPrinterPrintStmtClass

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

Source from the content-addressed store, hash-verified

3009}
3010
3011func TestPrinterPrintStmtClass(t *testing.T) {
3012 o := bytes.NewBufferString("")
3013
3014 p := printer.NewPrinter(o)
3015 p.Print(&stmt.Class{
3016 Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
3017 ClassName: &node.Identifier{Value: "Foo"},
3018 Extends: &stmt.ClassExtends{
3019 ClassName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}},
3020 },
3021 Implements: &stmt.ClassImplements{
3022 InterfaceNames: []node.Node{
3023 &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}},
3024 &name.Name{Parts: []node.Node{&name.NamePart{Value: "Quuz"}}},
3025 },
3026 },
3027 Stmts: []node.Node{
3028 &stmt.ClassConstList{
3029 Modifiers: []node.Node{
3030 &node.Identifier{Value: "public"},
3031 &node.Identifier{Value: "static"},
3032 },
3033 Consts: []node.Node{
3034 &stmt.Constant{
3035 ConstantName: &node.Identifier{Value: "FOO"},
3036 Expr: &scalar.String{Value: "'bar'"},
3037 },
3038 },
3039 },
3040 },
3041 })
3042
3043 expected := `abstract class Foo extends Bar implements Baz,Quuz{public static const FOO='bar';}`
3044 actual := o.String()
3045
3046 if expected != actual {
3047 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
3048 }
3049}
3050
3051func TestPrinterPrintStmtAnonymousClass(t *testing.T) {
3052 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…