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

Function TestPrinterPrintPropertyList

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

Source from the content-addressed store, hash-verified

3939}
3940
3941func TestPrinterPrintPropertyList(t *testing.T) {
3942 o := bytes.NewBufferString("")
3943
3944 p := printer.NewPrinter(o)
3945 p.Print(&stmt.PropertyList{
3946 Modifiers: []node.Node{
3947 &node.Identifier{Value: "public"},
3948 &node.Identifier{Value: "static"},
3949 },
3950 Type: &name.Name{
3951 Parts: []node.Node{
3952 &name.NamePart{
3953 Value: "Foo",
3954 },
3955 },
3956 },
3957 Properties: []node.Node{
3958 &stmt.Property{
3959 Variable: &expr.Variable{
3960 VarName: &node.Identifier{Value: "a"},
3961 },
3962 Expr: &scalar.String{Value: "'a'"},
3963 },
3964 &stmt.Property{
3965 Variable: &expr.Variable{
3966 VarName: &node.Identifier{Value: "b"},
3967 },
3968 },
3969 },
3970 })
3971
3972 expected := `public static Foo $a='a',$b;`
3973 actual := o.String()
3974
3975 if expected != actual {
3976 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
3977 }
3978}
3979
3980func TestPrinterPrintProperty(t *testing.T) {
3981 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…