I want to test a method. This method used the static method verifyPassword() in an abstract class.
class Authentication {
...
public function onUserAuthenticate($credentials) {
….
$checkedIn = UHelper::verifyPassword($credentials);
…
}
Now I created a mock object in my test method, because I want not test the verifyPassword() with this test.
class AuthenticationTest {
..
public function testonUserAuthenticate {
...
$uhelper = $this->getMockForAbstractClass(\UHelper::class);
$uhelper->expects($this->any())
->method('verifyPassword')
->with($mypassword)
->will($this->returnValue(true));
$this->class = new \Authentication();
$this->class->onUserAuthenticate($credentials);
..
}
How can I accomplish, that my mock object is used in the test method when I run $this->class->onUserAuthenticate($credentials) ?
verifyPassword is a call to a static methode in the abstract class UHelper, so I do not have a setUHelper method anywhere.
hat I'm trying to do is make variable class Authentication in ther call of the method onUserAuthenticate use the stub $uhelper. That is not answered in the related question.