I have this class
<?php
class Password
{
protected function checkPassword()
{
$this->callExit();
}
protected function callExit()
{
exit;
}
}
and this is my test:
public function testAuthorizeExitsWhenPasswordNotSet()
{
$badCode = $this->getMockBuilder(Password::class)
->setMethods(array('callExit'))
->getMock();
$badCode->expects($this->once())
->method('callExit');
$badCode->checkPassword();
}
In the earlier class the callExit method is of Password class. My question is, Can I test methods that aren't of the Password class ?
For example in checkPassword method:
protected function checkPassword()
{
$user = new User;
$this->callExit();
$user->fillOut();
}
I want to do a mock for fillOut method, How do I it?
Help me plis !!
Aucun commentaire:
Enregistrer un commentaire