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
1 Answer
Reset to default 0In 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.