From 681163be9750982ccb945228f1166bf2605d7937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=85=E5=BF=B5?= Date: Tue, 20 Oct 2026 17:26:17 +0800 Subject: [PATCH] =?UTF-8?q?test(fixtures):=20=E8=84=B1=E6=95=8F=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=20WXR/sitemap/=E5=AA=92=E4=BD=93=E5=A4=B9=E5=85=B7?= =?UTF-8?q?=EF=BC=88=E5=85=A8=E8=99=9A=E6=9E=84=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Code --- tests/fixtures/README.md | 31 +++++++++++ tests/fixtures/media/README.md | 8 +++ tests/fixtures/media/fixture-a.png | Bin 0 -> 70 bytes tests/fixtures/media/fixture-b.png | Bin 0 -> 70 bytes tests/fixtures/sitemap/mini-sitemap.xml | 7 +++ tests/fixtures/wxr/mini.xml | 67 ++++++++++++++++++++++++ 6 files changed, 113 insertions(+) create mode 100644 tests/fixtures/README.md create mode 100644 tests/fixtures/media/README.md create mode 100644 tests/fixtures/media/fixture-a.png create mode 100644 tests/fixtures/media/fixture-b.png create mode 100644 tests/fixtures/sitemap/mini-sitemap.xml create mode 100644 tests/fixtures/wxr/mini.xml diff --git a/tests/fixtures/README.md b/tests/fixtures/README.md new file mode 100644 index 0000000..3574c4e --- /dev/null +++ b/tests/fixtures/README.md @@ -0,0 +1,31 @@ +# tests/fixtures 测试夹具 + +## 来源声明 + +本目录所有夹具内容均为**完全虚构**:域名一律为 `fixture.example`,文章、产品、 +分类、附件、SEO 文案等均为手写编造,**不包含任何来自真实站点(如 hesupipe) +的数据**,也未复制 `storage/wxr/` 下的任何真实导出内容。 + +## 目录说明 + +- `wxr/mini.xml`:最小 WXR(WordPress eXtended RSS)导出夹具。 +- `sitemap/mini-sitemap.xml`:最小 sitemap 夹具。 +- `media/`:1×1 PNG 媒体占位(`fixture-a.png`、`fixture-b.png`), + 命名与 WXR 中 attachment 的 `wp:attachment_url` 对应。 + +## 覆盖的结构变体 + +`wxr/mini.xml` 覆盖阶段 2 WXR 流式解析器需要处理的结构: + +- `.html` 后缀 permalink 与目录式 permalink 混用 +- Yoast SEO meta(`_yoast_wpseo_title`、`_yoast_wpseo_metadesc`) +- 特色图(`_thumbnail_id`)与产品图库(`_product_image_gallery`) +- PHP serialized postmeta(`wppop_sections`) +- `wp:term`(category / product_cat 两种 taxonomy) +- attachment 条目(`wp:attachment_url`、`status=inherit`) +- post / product(CPT) / page 多种 post_type + +## 用途 + +这些夹具是**阶段 2 WXR 流式解析器与 sitemap 解析的标准测试输入**(契约输入), +内容视为契约,修改需同步更新相关测试。 diff --git a/tests/fixtures/media/README.md b/tests/fixtures/media/README.md new file mode 100644 index 0000000..3363993 --- /dev/null +++ b/tests/fixtures/media/README.md @@ -0,0 +1,8 @@ +# media/ 媒体占位 + +本目录下的图片为**虚构占位文件**,与任何真实站点数据无关。 + +- `fixture-a.png`、`fixture-b.png`:1×1 像素的最小合法 PNG 占位图。 +- 命名与 `tests/fixtures/wxr/mini.xml` 中 attachment 的 `wp:attachment_url` + (`https://fixture.example/wp-content/uploads/2026/10/fixture-{a,b}.png`)一一对应, + 供阶段 2 解析器测试做媒体引用核对使用。 diff --git a/tests/fixtures/media/fixture-a.png b/tests/fixtures/media/fixture-a.png new file mode 100644 index 0000000000000000000000000000000000000000..613754cfaf74a7a2d86984231479d5671731f18a GIT binary patch literal 70 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k92}1TpU9xZY8HA{D|jgU}|SSG{)78&qol`;+0KfSU_W%F@ literal 0 HcmV?d00001 diff --git a/tests/fixtures/media/fixture-b.png b/tests/fixtures/media/fixture-b.png new file mode 100644 index 0000000000000000000000000000000000000000..613754cfaf74a7a2d86984231479d5671731f18a GIT binary patch literal 70 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k92}1TpU9xZY8HA{D|jgU}|SSG{)78&qol`;+0KfSU_W%F@ literal 0 HcmV?d00001 diff --git a/tests/fixtures/sitemap/mini-sitemap.xml b/tests/fixtures/sitemap/mini-sitemap.xml new file mode 100644 index 0000000..afdbbe5 --- /dev/null +++ b/tests/fixtures/sitemap/mini-sitemap.xml @@ -0,0 +1,7 @@ + + + https://fixture.example/ + https://fixture.example/news/fixture-news-a.html + https://fixture.example/products/fixture-product/ + https://fixture.example/about-us/ + diff --git a/tests/fixtures/wxr/mini.xml b/tests/fixtures/wxr/mini.xml new file mode 100644 index 0000000..16c9334 --- /dev/null +++ b/tests/fixtures/wxr/mini.xml @@ -0,0 +1,67 @@ + + + + Fixture Sitehttps://fixture.example + 1.2 + + + <![CDATA[Fixture News A]]> + https://fixture.example/news/fixture-news-a.html + Mon, 05 Oct 2026 09:00:00 +0000 + + https://fixture.example/?p=101 + Body with link and

]]>
+ + 101 + + + + + + + + + +
+ + + <![CDATA[Fixture Product]]> + https://fixture.example/products/fixture-product/ + 111 + + Product body

]]>
+ + + Tab

";}}]]>
+
+ + + <![CDATA[Fixture About]]>https://fixture.example/about-us/ + 121 + + About body

]]>
+
+ + + + + + + + + + + <![CDATA[fixture-a]]>https://fixture.example/?attachment_id=201 + 201 + https://fixture.example/wp-content/uploads/2026/10/fixture-a.png + + <![CDATA[fixture-b]]>https://fixture.example/?attachment_id=202 + 202 + https://fixture.example/wp-content/uploads/2026/10/fixture-b.png + +
+