我上过这门课
<?php
class Password
{
protected function checkPassword()
{
$this->callExit();
}
protected function callExit()
{
exit;
}
}
这是我的测试:
public function testAuthorizeExitsWhenPasswordNotSet()
{
$badCode = $this->getMockBuilder(Password::class)
->setMethods(array('callExit'))
->getMock();
$badCode->expects($this->once())
->method('callExit');
$badCode->checkPassword();
}
在前面的类中,callExit
方法是Password类。我的问题是,我可以测试不属于Password
类的方法吗?
例如在checkPassword
方法中:
protected function checkPassword()
{
$user = new User;
$this->callExit();
$user->fillOut();
}
我想为fillOut
方法做一个模拟,我该怎么做?
帮帮我!!
https://stackoverflow.com/questions/44079046
复制相似问题