(t *testing.T)
| 142 | } |
| 143 | |
| 144 | func TestDocumentationGenerator_GenerateMarkdown(t *testing.T) { |
| 145 | tests := []struct { |
| 146 | name string |
| 147 | generator *Generator |
| 148 | contains []string |
| 149 | notContains []string |
| 150 | }{ |
| 151 | { |
| 152 | name: "function with parameters", |
| 153 | generator: &Generator{ |
| 154 | BaseName: "testextension", |
| 155 | Functions: []phpFunction{ |
| 156 | { |
| 157 | Name: "processData", |
| 158 | ReturnType: phpArray, |
| 159 | Params: []phpParameter{ |
| 160 | {Name: "data", PhpType: phpString}, |
| 161 | {Name: "options", PhpType: phpArray, IsNullable: true}, |
| 162 | {Name: "count", PhpType: phpInt, HasDefault: true, DefaultValue: "10"}, |
| 163 | }, |
| 164 | Signature: "processData(string $data, ?array $options, int $count = 10): array", |
| 165 | }, |
| 166 | }, |
| 167 | Classes: []phpClass{}, |
| 168 | }, |
| 169 | contains: []string{ |
| 170 | "# testextension Extension", |
| 171 | "## Functions", |
| 172 | "### processData", |
| 173 | "**Parameters:**", |
| 174 | "- `data` (string)", |
| 175 | "- `options` (array) (nullable)", |
| 176 | "- `count` (int) (default: 10)", |
| 177 | "**Returns:** array", |
| 178 | }, |
| 179 | }, |
| 180 | { |
| 181 | name: "nullable return type", |
| 182 | generator: &Generator{ |
| 183 | BaseName: "nullableext", |
| 184 | Functions: []phpFunction{ |
| 185 | { |
| 186 | Name: "maybeGetValue", |
| 187 | ReturnType: phpString, |
| 188 | IsReturnNullable: true, |
| 189 | Params: []phpParameter{}, |
| 190 | Signature: "maybeGetValue(): ?string", |
| 191 | }, |
| 192 | }, |
| 193 | Classes: []phpClass{}, |
| 194 | }, |
| 195 | contains: []string{ |
| 196 | "**Returns:** string (nullable)", |
| 197 | }, |
| 198 | }, |
| 199 | { |
| 200 | name: "class with properties", |
| 201 | generator: &Generator{ |
nothing calls this directly
no test coverage detected