LoginSignup
2
2

More than 5 years have passed since last update.

SymfonyでPhakeを使う

Last updated at Posted at 2012-03-16
# 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();
    }
}
---------------------------------------------------------
2
2
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
2
2