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

Function TestPrinterPrintFileInlineHtml

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

Source from the content-addressed store, hash-verified

71}
72
73func TestPrinterPrintFileInlineHtml(t *testing.T) {
74 o := bytes.NewBufferString("")
75
76 p := printer.NewPrinter(o)
77 p.Print(&node.Root{
78 Stmts: []node.Node{
79 &stmt.InlineHtml{Value: "<div>HTML</div>"},
80 &stmt.Expression{
81 Expr: &expr.Variable{
82 FreeFloating: freefloating.Collection{
83 freefloating.Start: []freefloating.String{
84 {
85 StringType: freefloating.TokenType,
86 Value: "$",
87 },
88 },
89 },
90 VarName: &node.Identifier{
91 Value: "a",
92 },
93 },
94 },
95 &stmt.InlineHtml{Value: "<div>HTML</div>"},
96 &stmt.Expression{
97 Expr: &expr.Variable{
98 FreeFloating: freefloating.Collection{
99 freefloating.Start: []freefloating.String{
100 {
101 StringType: freefloating.TokenType,
102 Value: "$",
103 },
104 },
105 },
106 VarName: &node.Identifier{
107 Value: "a",
108 },
109 },
110 },
111 },
112 })
113
114 expected := `<div>HTML</div><?php $a;?><div>HTML</div><?php $a;`
115 actual := o.String()
116
117 if expected != actual {
118 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
119 }
120}
121
122// node
123

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…