test(fixtures): 脱敏最小 WXR/sitemap/媒体夹具(全虚构)
Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
Vendored
+31
@@ -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 解析的标准测试输入**(契约输入),
|
||||
内容视为契约,修改需同步更新相关测试。
|
||||
Vendored
+8
@@ -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 解析器测试做媒体引用核对使用。
|
||||
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 70 B |
Vendored
BIN
Binary file not shown.
|
After Width: | Height: | Size: 70 B |
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
||||
<url><loc>https://fixture.example/</loc></url>
|
||||
<url><loc>https://fixture.example/news/fixture-news-a.html</loc></url>
|
||||
<url><loc>https://fixture.example/products/fixture-product/</loc></url>
|
||||
<url><loc>https://fixture.example/about-us/</loc></url>
|
||||
</urlset>
|
||||
Vendored
+67
@@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
|
||||
xmlns:content="http://purl.org/rss/1.0/modules/content/"
|
||||
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:wp="http://wordpress.org/export/1.2/">
|
||||
<channel>
|
||||
<title>Fixture Site</title><link>https://fixture.example</link>
|
||||
<wp:wxr_version>1.2</wp:wxr_version>
|
||||
<!-- 1 post with .html permalink, Yoast meta, thumbnail -->
|
||||
<item>
|
||||
<title><![CDATA[Fixture News A]]></title>
|
||||
<link>https://fixture.example/news/fixture-news-a.html</link>
|
||||
<pubDate>Mon, 05 Oct 2026 09:00:00 +0000</pubDate>
|
||||
<dc:creator><![CDATA[editor]]></dc:creator>
|
||||
<guid isPermaLink="false">https://fixture.example/?p=101</guid>
|
||||
<content:encoded><![CDATA[<p>Body with <a href="/products/fixture-product/">link</a> and <img src="https://fixture.example/wp-content/uploads/2026/10/fixture-a.png"/></p>]]></content:encoded>
|
||||
<excerpt:encoded><![CDATA[Fixture excerpt A]]></excerpt:encoded>
|
||||
<wp:post_id>101</wp:post_id>
|
||||
<wp:post_date><![CDATA[2026-10-05 09:00:00]]></wp:post_date>
|
||||
<wp:post_modified><![CDATA[2026-10-06 10:00:00]]></wp:post_modified>
|
||||
<wp:post_name><![CDATA[fixture-news-a]]></wp:post_name>
|
||||
<wp:post_type><![CDATA[post]]></wp:post_type>
|
||||
<wp:status><![CDATA[publish]]></wp:status>
|
||||
<category domain="category" nicename="company"><![CDATA[Company]]></category>
|
||||
<wp:postmeta><wp:meta_key><![CDATA[_thumbnail_id]]></wp:meta_key><wp:meta_value><![CDATA[201]]></wp:meta_value></wp:postmeta>
|
||||
<wp:postmeta><wp:meta_key><![CDATA[_yoast_wpseo_title]]></wp:meta_key><wp:meta_value><![CDATA[Fixture SEO Title A]]></wp:meta_value></wp:postmeta>
|
||||
<wp:postmeta><wp:meta_key><![CDATA[_yoast_wpseo_metadesc]]></wp:meta_key><wp:meta_value><![CDATA[Fixture SEO description A.]]></wp:meta_value></wp:postmeta>
|
||||
</item>
|
||||
<!-- 2 product CPT with gallery + wppop_sections(PHP serialized) -->
|
||||
<item>
|
||||
<title><![CDATA[Fixture Product]]></title>
|
||||
<link>https://fixture.example/products/fixture-product/</link>
|
||||
<wp:post_id>111</wp:post_id><wp:post_name><![CDATA[fixture-product]]></wp:post_name>
|
||||
<wp:post_type><![CDATA[product]]></wp:post_type><wp:status><![CDATA[publish]]></wp:status>
|
||||
<content:encoded><![CDATA[<p>Product body</p>]]></content:encoded>
|
||||
<wp:postmeta><wp:meta_key><![CDATA[_thumbnail_id]]></wp:meta_key><wp:meta_value><![CDATA[202]]></wp:meta_value></wp:postmeta>
|
||||
<wp:postmeta><wp:meta_key><![CDATA[_product_image_gallery]]></wp:meta_key><wp:meta_value><![CDATA[203,204]]></wp:meta_value></wp:postmeta>
|
||||
<wp:postmeta><wp:meta_key><![CDATA[wppop_sections]]></wp:meta_key><wp:meta_value><![CDATA[a:1:{i:0;a:2:{s:5:"title";s:7:"SpecsTab";s:7:"content";s:12:"<p>Tab</p>";}}]]></wp:meta_value></wp:postmeta>
|
||||
</item>
|
||||
<!-- 3 page -->
|
||||
<item>
|
||||
<title><![CDATA[Fixture About]]></title><link>https://fixture.example/about-us/</link>
|
||||
<wp:post_id>121</wp:post_id><wp:post_name><![CDATA[about-us]]></wp:post_name>
|
||||
<wp:post_type><![CDATA[page]]></wp:post_type><wp:status><![CDATA[publish]]></wp:status>
|
||||
<content:encoded><![CDATA[<p>About body</p>]]></content:encoded>
|
||||
</item>
|
||||
<!-- 4 term -->
|
||||
<wp:term>
|
||||
<wp:term_id><![CDATA[31]]></wp:term_id><wp:term_taxonomy><![CDATA[category]]></wp:term_taxonomy>
|
||||
<wp:term_slug><![CDATA[company]]></wp:term_slug><wp:term_name><![CDATA[Company]]></wp:term_name>
|
||||
</wp:term>
|
||||
<wp:term>
|
||||
<wp:term_id><![CDATA[32]]></wp:term_id><wp:term_taxonomy><![CDATA[product_cat]]></wp:term_taxonomy>
|
||||
<wp:term_slug><![CDATA[pipe-fittings]]></wp:term_slug><wp:term_name><![CDATA[Pipe Fittings]]></wp:term_name>
|
||||
</wp:term>
|
||||
<!-- 5 attachments -->
|
||||
<item><title><![CDATA[fixture-a]]></title><link>https://fixture.example/?attachment_id=201</link>
|
||||
<wp:post_id>201</wp:post_id><wp:post_type><![CDATA[attachment]]></wp:post_type><wp:status><![CDATA[inherit]]></wp:status>
|
||||
<wp:attachment_url>https://fixture.example/wp-content/uploads/2026/10/fixture-a.png</wp:attachment_url>
|
||||
</item>
|
||||
<item><title><![CDATA[fixture-b]]></title><link>https://fixture.example/?attachment_id=202</link>
|
||||
<wp:post_id>202</wp:post_id><wp:post_type><![CDATA[attachment]]></wp:post_type><wp:status><![CDATA[inherit]]></wp:status>
|
||||
<wp:attachment_url>https://fixture.example/wp-content/uploads/2026/10/fixture-b.png</wp:attachment_url>
|
||||
</item>
|
||||
</channel>
|
||||
</rss>
|
||||
Reference in New Issue
Block a user