最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

oembed - How do I phpunit test a post output process?

programmeradmin0浏览0评论

I like to know how to test the html output of a post. Like WP would output it on the frontend in reality.

My specific case at this point is to test oembed caching as I want to test re-caching. AFAIK WP does only cache oembed results if they are associated with a post. So I can not just run some text though the_content filter. I like to test the real post processioning for this and in general for other cases that may come up.

So far in my search I only found tutorials how to create a post in unit testing but not how to actually run tests on it.

I like to know how to test the html output of a post. Like WP would output it on the frontend in reality.

My specific case at this point is to test oembed caching as I want to test re-caching. AFAIK WP does only cache oembed results if they are associated with a post. So I can not just run some text though the_content filter. I like to test the real post processioning for this and in general for other cases that may come up.

So far in my search I only found tutorials how to create a post in unit testing but not how to actually run tests on it.

Share Improve this question edited Feb 12, 2020 at 5:05 NextGenThemes asked Jan 31, 2020 at 17:23 NextGenThemesNextGenThemes 7458 silver badges28 bronze badges 1
  • Did you find the solution? I need the way to archieve this, too. – Terry Lin Commented Nov 12, 2020 at 4:59
Add a comment  | 

1 Answer 1

Reset to default 0

In your test, you can create a post, start output buffering with ob_start(), output post content as usual, get output buffer into your variable with ob_end_clean().

Now your can process real post output string and compare it with the expected value.

发布评论

评论列表(0)

  1. 暂无评论