Last active
April 14, 2017 08:59
-
-
Save gskema/95ddf38b6187881e43b42128b8806079 to your computer and use it in GitHub Desktop.
PHPUnit setMethods explained by an example
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 Banana | |
{ | |
public function a() | |
{ | |
return 1; | |
} | |
public function b() | |
{ | |
return 2; | |
} | |
} | |
$this->getMockBuilder(Banana::class)->getMock(); // a: null, b: null | |
$this->getMockBuilder(Banana::class)->setMethods([])->getMock(); // a: null, b: null | |
$this->getMockBuilder(Banana::class)->setMethods(null)->getMock(); // a: 1, b: 2 | |
$this->getMockBuilder(Banana::class)->setMethods(['a'])->getMock(); // a: null, b: 2 | |
$this->getMockBuilder(Banana::class)->setMethods(['b'])->getMock(); // a: 1, b: null | |
$this->getMockBuilder(Banana::class)->setMethods(['a', 'b'])->getMock(); // a: null, b: null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment