Welcome to PHPUnit! PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.
class TwitterClient { public function tweet($message) { return true; } } $hoge = new TwitterClient(); $hoge->tweet('大å¿ãªã'); // trueãè¿ã class ClientContainerTest extends PHPUnit_Framework_TestCase { public function test_ã¢ãã¯ãæ¸ãã¦ã¿ã() { $hoge = $this->getMock('TwitterClient', array('tweet')); $hoge->expects($this->any()) ->method('tweet') ->will($this->returnValue(true)); $hoge->tweet('大å¿ãªã'); // true
composerã§PHPUnitãã¤ã³ã¹ãã¼ã«ãããã£ããã§ããã ä¸è¨ã¨ã©ã¼ãçºçã ç°å¢ã¯ OS: CentOS6.4 PHPï¼ 5.4.17 composer.jsonã®å 容ã¯ãããªæãã§ããã£ã¦æ®éã { "require-dev": { "phpunit/phpunit": "3.7.*" }, "config": { "bin-dir": "/usr/local/bin/" } } ãã¨ã©ã¼å 容ã [root@luffy ~]# composer install Loading composer repositories with package information Installing dependencies (including require-dev) Your requirements could not be resolved to an installable
注æ ãã®ããã¥ã¡ã³ãã¯ããã§ã«ãµãã¼ããçµäºãããã¼ã¸ã§ã³ã® PHPUnit ã«é¢ãããã®ã§ãã ææ°çã® PHPUnit ã®ããã¥ã¡ã³ã㯠ãã¡ãã«ããã¾ãã ãªãã¸ã§ã¯ãã«å¯¾ããã³ã¼ã«ãæ£ããè¡ããããã©ããã調ã¹ãããã¨ãããã§ãããã ãã®æ¹æ³ãããã§èª¬æãã¾ããããã§ã¯ãå¥ã®ãªãã¸ã§ã¯ãã観å¯ãã¦ãã ãããªãã¸ã§ã¯ãã®ç¹å®ã®ã¡ã½ãã (ãã®ä¾ã§ã¯ update()) ãæ£ããã³ã¼ã«ããããã©ããã調ã¹ããã®ã¨ãã¾ãã ä¾ 10.1 ã§ã¯ãã¾ã PHPUnit_Framework_TestCase ã¯ã©ã¹ã® getMock() ã¡ã½ãã (表 20.7 ãåç §ãã ãã) ã使ç¨ã㦠Observer ã®ã¢ãã¯ãªãã¸ã§ã¯ããä½æãã¾ãã getMock() ã¡ã½ããã®äºçªç®ã® (ãªãã·ã§ã³ã®) ãã©ã¡ã¼ã¿ã«é åãæå®ãã¦ããã®ã§ãObserver ã¯ã©ã¹ã®ä¸ã® update()
PHPUnitã§ãã¹ãããããIntelliJï¼PHPStormï¼ã§ãå®è¡ã§ããããã«ãã¦ã¿ã ãããããã¹ãã¨ããåå¼·ããªãã¨ãªã¨æã£ããããã®ã§ã¨ãããã PHPUnit ãå°å ¥ãã¦ãç°¡åãªã³ã¼ãã®ãã¹ããæ¸ãã¨ãã¾ã§ãã£ã¦ã¿ã¾ãã ã¤ãã§ã«IntelliJï¼PHPStormï¼ã§ãå®è¡ã§ããããã«è¨å®ãã¦ã¿ã¾ããã æ稿æ¥2013å¹´05æ20æ¥ æ´æ°æ¥2013å¹´05æ20æ¥ PHPUnitã®ã¤ã³ã¹ãã¼ã« PHPUnitã¯PEARããã¤ã³ã¹ãã¼ã«ãã¾ãã PHPã®ç°å¢å¤æ°ãè¨å®ãã¦ããªãå ´åã¯ãC:\xampp\phpãã§è¨å®ãã¦ããã¾ãã 管ç権éã§ããã³ããï¼ã¿ã¼ããã«ï¼ãèµ·åãã¾ãã ã¾ãã¯PEARã®ã¢ãããã¼ãã pear upgrade PEAR ç¶ãã¦PHPUnitã®ã¤ã³ã¹ãã¼ã«ã pear config-set auto_discover 1 pear install pe
ãç¥ãã
é害
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}