class cash{ public function __construct(){} public function isCashed(){ //do something return 1; }}class sendMsg{ public function send(){ $cash = new cash(); $isCashed = $cash->isCashed(); return $isCashed; //do something }}
class sendMsgTest extension PHPUnit_Framework_TestCase{ public function testSend(){ $sendMsg = new sendMsg(); //如何mock一个cash }}
class cash 这个已经定义好了吗,还是没有定义?
class cash 这个已经定义好了吗,还是没有定义?
都已经定义好了,是对现有代码写测试,上面那个只是我简化了的个东西可以试试phpunit phpmock