WordPressで任意の$postオブジェクトを現在の$postとしてセットして、the_content()等の出力内容をテストWordPressPHPUnitWP_UnitTestCase 以下のようなテストをしたいときに便利。 ショートコードが期待通りに発火する? the_contentなどのフィルターフックが発火してる? テストの流れ。 テスト用の投稿を保存 get_post()で$postオブジェクトを取得する。 setup_postdata()で現在のカレントの$postにセットする。 the_content()などのテンプレートタグの出力をテストする。 <?php class Sample_Test extends WP_UnitTestCase { /** * @test */ function sample_test() { $args = array( 'post_ti