# vendor/phake にインストール
$ git clone https://github.com/jaz303/phake.git vendor/phake
# app/bootsrap_test.php をつくる
---------------------------------------------------------
<?php
require_once __DIR__.'/bootstrap.php.cache';
require_once __DIR__.'/../vendor/phake/tests/bootstrap.php';
---------------------------------------------------------
# app/phpunit.xml.dist に bootstrap_test.php を指定する
---------------------------------------------------------
<phpunit
...
bootstrap = "bootstrap_test.php" >
---------------------------------------------------------
# Phakeを使ってテストを書く
---------------------------------------------------------
<?php
namespace AppBundle\Tests;
use AppBundle\Foo;
use Phake;
class FooTest extends \PHPUnit_Framework_TestCase
{
public function testFoo()
{
$foo = new Foo();
$bar = Phake::mock('AppBundle\Bar');
$foo->executeBar($bar);
Phake::verify($bar)->mustBeCalled();
}
}
---------------------------------------------------------
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme