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

Function TestPrinterPrintAltForeach

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

Source from the content-addressed store, hash-verified

2689}
2690
2691func TestPrinterPrintAltForeach(t *testing.T) {
2692 o := bytes.NewBufferString("")
2693
2694 p := printer.NewPrinter(o)
2695 p.Print(&stmt.AltForeach{
2696 Expr: &expr.Variable{
2697 VarName: &node.Identifier{Value: "var"},
2698 },
2699 Key: &expr.Variable{
2700 VarName: &node.Identifier{Value: "key"},
2701 },
2702 Variable: &expr.Reference{Variable: &expr.Variable{
2703 VarName: &node.Identifier{Value: "val"},
2704 }},
2705 Stmt: &stmt.StmtList{
2706 Stmts: []node.Node{
2707 &stmt.Expression{Expr: &expr.Variable{
2708 VarName: &node.Identifier{Value: "d"},
2709 }},
2710 },
2711 },
2712 })
2713
2714 expected := `foreach($var as $key=>&$val):$d;endforeach;`
2715 actual := o.String()
2716
2717 if expected != actual {
2718 t.Errorf("\nexpected: %s\ngot: %s\n", expected, actual)
2719 }
2720}
2721
2722func TestPrinterPrintAltIf(t *testing.T) {
2723 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…