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

Function TestPrinterPrintStmtAnonymousClass

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

Source from the content-addressed store, hash-verified

3049}
3050
3051func TestPrinterPrintStmtAnonymousClass(t *testing.T) {
3052 o := bytes.NewBufferString("")
3053
3054 p := printer.NewPrinter(o)
3055 p.Print(&stmt.Class{
3056 Modifiers: []node.Node{&node.Identifier{Value: "abstract"}},
3057 ArgumentList: &node.ArgumentList{
3058 Arguments: []node.Node{
3059 &node.Argument{
3060 Expr: &expr.Variable{
3061 VarName: &node.Identifier{Value: "a"},
3062 },
3063 },
3064 &node.Argument{
3065 Expr: &expr.Variable{
3066 VarName: &node.Identifier{Value: "b"},
3067 },
3068 },
3069 },
3070 },
3071 Extends: &stmt.ClassExtends{
3072 ClassName: &name.Name{Parts: []node.Node{&name.NamePart{Value: "Bar"}}},
3073 },
3074 Implements: &stmt.ClassImplements{
3075 InterfaceNames: []node.Node{
3076 &name.Name{Parts: []node.Node{&name.NamePart{Value: "Baz"}}},
3077 &name.Name{Parts: []node.Node{&name.NamePart{Value: "Quuz"}}},
3078 },
3079 },
3080 Stmts: []node.Node{
3081 &stmt.ClassConstList{
3082 Modifiers: []node.Node{&node.Identifier{Value: "public"}},
3083 Consts: []node.Node{
3084 &stmt.Constant{
3085 ConstantName: &node.Identifier{Value: "FOO"},
3086 Expr: &scalar.String{Value: "'bar'"},
3087 },
3088 },
3089 },
3090 },
3091 })
3092
3093 expected := `abstract class($a,$b) extends Bar implements Baz,Quuz{public const FOO='bar';}`
3094 actual := o.String()
3095
3096 if expected != actual {
3097 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
3098 }
3099}
3100
3101func TestPrinterPrintStmtClassConstList(t *testing.T) {
3102 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…