How do I phpunit test a post output process?

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.

Topic unit-tests oembed testing posts Wordpress

Category Web


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.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.