Skip to content

Instantly share code, notes, and snippets.

@msysyamamoto
Created January 4, 2016 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msysyamamoto/cba1c471636bb4d0daa5 to your computer and use it in GitHub Desktop.
Save msysyamamoto/cba1c471636bb4d0daa5 to your computer and use it in GitHub Desktop.
<?php
class SomeClass
{
public function doSomething() {}
}
class SomeTest extends PHPUnit_Framework_TestCase
{
/**
* @dataProvider provider
*/
public function testStubWithProvider($stub)
{
// $stub->doSomething を呼ばないのでテストは失敗するはず
}
public function provider()
{
// SomeClass::doSomething が1回呼ばれることをテストするモックオブジェクトを生成
$stub = $this->getMockBuilder('SomeClass')->getMock();
$stub->expects($this->once())->method('doSomething');
return [[$stub]];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment