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

Function TestIncludeOnce

node/expr/t_include_test.go:75–131  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

73}
74
75func TestIncludeOnce(t *testing.T) {
76 src := `<? include_once $a;`
77
78 expected := &node.Root{
79 Position: &position.Position{
80 StartLine: 1,
81 EndLine: 1,
82 StartPos: 3,
83 EndPos: 19,
84 },
85 Stmts: []node.Node{
86 &stmt.Expression{
87 Position: &position.Position{
88 StartLine: 1,
89 EndLine: 1,
90 StartPos: 3,
91 EndPos: 19,
92 },
93 Expr: &expr.IncludeOnce{
94 Position: &position.Position{
95 StartLine: 1,
96 EndLine: 1,
97 StartPos: 3,
98 EndPos: 18,
99 },
100 Expr: &expr.Variable{
101 Position: &position.Position{
102 StartLine: 1,
103 EndLine: 1,
104 StartPos: 16,
105 EndPos: 18,
106 },
107 VarName: &node.Identifier{
108 Position: &position.Position{
109 StartLine: 1,
110 EndLine: 1,
111 StartPos: 16,
112 EndPos: 18,
113 },
114 Value: "a",
115 },
116 },
117 },
118 },
119 },
120 }
121
122 php7parser := php7.NewParser([]byte(src), "7.4")
123 php7parser.Parse()
124 actual := php7parser.GetRootNode()
125 assert.DeepEqual(t, expected, actual)
126
127 php5parser := php5.NewParser([]byte(src), "5.6")
128 php5parser.Parse()
129 actual = php5parser.GetRootNode()
130 assert.DeepEqual(t, expected, actual)
131}
132

Callers

nothing calls this directly

Calls 4

ParseMethod · 0.95
GetRootNodeMethod · 0.95
NewParserFunction · 0.92
NewParserFunction · 0.92

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…