MCPcopy Create free account
hub / github.com/php/frankenphp / TestCFileGenerator_GetTemplateContent

Function TestCFileGenerator_GetTemplateContent

internal/extgen/cfile_test.go:147–204  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func TestCFileGenerator_GetTemplateContent(t *testing.T) {
148 tests := []struct {
149 name string
150 baseName string
151 classes []phpClass
152 contains []string
153 notContains []string
154 }{
155 {
156 name: "extension without classes",
157 baseName: "myext",
158 contains: []string{
159 `#include "myext.h"`,
160 `#include "myext_arginfo.h"`,
161 "PHP_MINIT_FUNCTION(myext)",
162 "myext_module_entry",
163 "return SUCCESS;",
164 },
165 },
166 {
167 name: "extension with classes",
168 baseName: "complex_name",
169 classes: []phpClass{
170 {Name: "TestClass", GoStruct: "TestStruct"},
171 {Name: "AnotherClass", GoStruct: "AnotherStruct"},
172 },
173 contains: []string{
174 `#include "complex_name.h"`,
175 `#include "complex_name_arginfo.h"`,
176 "PHP_MINIT_FUNCTION(complex_name)",
177 "complex_name_module_entry",
178 "register_all_classes()",
179 "register_class_TestClass();",
180 "register_class_AnotherClass();",
181 },
182 },
183 }
184
185 for _, tt := range tests {
186 t.Run(tt.name, func(t *testing.T) {
187 generator := &Generator{
188 BaseName: tt.baseName,
189 Classes: tt.classes,
190 }
191 cGen := cFileGenerator{generator}
192 content, err := cGen.getTemplateContent()
193 require.NoError(t, err)
194
195 for _, expected := range tt.contains {
196 assert.Contains(t, content, expected, "Template content should contain '%s'", expected)
197 }
198
199 for _, notExpected := range tt.notContains {
200 assert.NotContains(t, content, notExpected, "Template content should NOT contain '%s'", notExpected)
201 }
202 })
203 }
204}

Callers

nothing calls this directly

Calls 1

getTemplateContentMethod · 0.95

Tested by

no test coverage detected