WP-CLI を gitによる更新する手順と、最新バージョン(v0.26.0alpha 開発中バージョン)についてのご紹介。
Happy Friday! Use
wp scaffold theme-tests
to generate PHPUnit tests for your theme https://t.co/IgWVYh2OzW— WP-CLI (@wpcli) 2016年11月11日
例によって VVV を導入している前提です。
ホストOSで以下のコマンドを実行し、VMにログインします。
1 2 3 4 |
[host]$ cd path/to/your/vvv [host]$ vagrant up # VM を立ち上げてない場合は、立ち上げる [host]$ vagrant ssh |
gitで WP-CLI のソースを取ってきます:
コンフリクトが発生する場合は、それを一旦コミットするなどして、解消しておきます。
1 2 3 4 5 |
[vm]$ cd /srv/www/wp-cli [vm]$ /srv/www/wp-cli [vm]$ git fetch [vm]$ git merge master |
バージョンアップされたか確認する:
1 2 3 4 |
[vm]$ cd /srv/www/wpken.net [vm]$ wp --version WP-CLI 0.26.0-alpha |
OKです。
新機能
wp scaffold theme-tests
とすると、テーマをPHPUnitでテストするためのファイルが生成されます。plugin-tests
はこれまで存在していたのですが、テーマ用のscaffoldコマンドは今回始めて登場しました。
wp scaffold theme-tests
の書式はこのようになっています:
1 2 |
wp scaffold theme-tests [<theme>] [--dir=<dirname>] [--ci=<provider>] [--force] |
1 2 3 |
$ cd /srv/www/wpken.net $ wp scaffold theme-tests wpwand |
これにより、 /home/users/1/ciao.jp-giris/web/wpken.netwp-content/themes/wpwand/
ディレクトリに tests
というフォルダが作成され、そこには PHPUnitを起動するためのPHPスクリプトが配置されます。
VVVには既にphpunitが使えるようになっているので、テストを実行してみます。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
$ cd /home/users/1/ciao.jp-giris/web/wpken.netwp-content/themes/wpwand/ $ phpunit tests Installing... Running as single site... To run multisite, use -c tests/phpunit/multisite.xml Not running ajax tests. To execute these, use --group ajax. Not running ms-files tests. To execute these, use --group ms-files. Not running external-http tests. To execute these, use --group external-http. PHPUnit 4.8.27 by Sebastian Bergmann and contributors. Time: 2.27 seconds, Memory: 26.25MB No tests executed! |
まだテストが一つもないので、ワーニングになりましたが、うまく動作するようです。
以上。 WP-CLIのgitによる更新とscaffoldの新機能についてのご紹介でした。
No comment yet, add your voice below!