LoginSignup
0
1

More than 5 years have passed since last update.

PHPUnit チートシート

Last updated at Posted at 2017-11-30

PHPUnitチートシート

コマンドを何度も調べたりするのが面倒なのでメモを作成。

参照

PHPUnit マニュアル
PHPでテスト自動化を実現しよう(PHPUnit Jenkins Selenium 活用編) Kindle版

XMLファイル

phpunit.xml
<phpunit>
    <filter>
        <whitelist processUncoverdFilesFormWhitelist="true">
            <directory suffix=".php">.</directory>
        </whitelist>
    </filter>
</phpunit>

実行コマンド

phpunit --coverage-html html <dir>
phpunit --whitelist <dir> 

Mock生成

$mock = $this->getMockBuilder(クラス名::class)->setMethods(['配列でメソッド名'])->getMock();
$mock->expects($this->once())->method('メッソド名')->will($this->returnValue(戻り値));
0
1
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
0
1