Created
January 4, 2016 13:46
-
-
Save msysyamamoto/cba1c471636bb4d0daa5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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