|
| 1 | +const { describe, it } = require("node:test"); |
| 2 | +const assert = require("node:assert"); |
| 3 | +const { parsePHPFile } = require("../lib/extractors/php.js"); |
| 4 | + |
| 5 | +describe("parsePHPFile", () => { |
| 6 | + it("correctly extracts headers from standard docblock (/** ... */)", () => { |
| 7 | + const phpContent = `<?php |
| 8 | +/** |
| 9 | + * Plugin Name: My Plugin |
| 10 | + * Description: A basic WordPress plugin template with translation support. |
| 11 | + * Version: 1.0 |
| 12 | + * Author: Your Name |
| 13 | + * Text Domain: my-plugin |
| 14 | + * Domain Path: /languages |
| 15 | + */`; |
| 16 | + const result = parsePHPFile(phpContent); |
| 17 | + assert.deepStrictEqual(result, { |
| 18 | + name: "My Plugin", |
| 19 | + description: "A basic WordPress plugin template with translation support.", |
| 20 | + version: "1.0", |
| 21 | + author: "Your Name", |
| 22 | + textDomain: "my-plugin", |
| 23 | + domainPath: "/languages", |
| 24 | + }); |
| 25 | + }); |
| 26 | + |
| 27 | + it("correctly extracts headers from simple comment block (/* ... */)", () => { |
| 28 | + const phpContent = `<?php |
| 29 | +/* |
| 30 | +Plugin Name: My Plugin |
| 31 | +Description: A basic WordPress plugin template with translation support. |
| 32 | +Version: 1.0 |
| 33 | +Author: Your Name |
| 34 | +Text Domain: my-plugin |
| 35 | +Domain Path: /languages |
| 36 | +*/`; |
| 37 | + const result = parsePHPFile(phpContent); |
| 38 | + assert.deepStrictEqual(result, { |
| 39 | + name: "My Plugin", |
| 40 | + description: "A basic WordPress plugin template with translation support.", |
| 41 | + version: "1.0", |
| 42 | + author: "Your Name", |
| 43 | + textDomain: "my-plugin", |
| 44 | + domainPath: "/languages", |
| 45 | + }); |
| 46 | + }); |
| 47 | +}); |
0 commit comments