LoginSignup
20
22

More than 5 years have passed since last update.

WordPress Theme開発でPHPUnitを使う

Last updated at Posted at 2015-06-30

WordPress Theme開発でもPHPUnitでのテストが行えないかなと思ってたので作ってみました。
wp-theme-phpunit

tests/bootstrap.php
function _manually_load_plugin() {
    register_theme_directory( dirname( __FILE__ ) . '/../../' );
    switch_theme('your-theme');
}


ポイントはここです。your-themeの部分を自身の開発中のTheme名に変更して、PHPUnitを実行させればOKです。

wp-plugin-unittest-dependency-patten

こいつと組み合わせれば、自作のテーマに必要なプラグインもインストールした上でPHPUnitを実行できるようになります。

クライアントに納品用のサイトとかを作るときは、プラグインもそれぞれクライアントの要望によって変わってくるとおもいますが、この方法使えば、サイト全体の仕様に対してPHPUnitのテストが実行できるようになりますね。

では良い、CIライフを!

20
22
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
22