O'Reilly logo

Learning Yii Testing by Matteo Pescarin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Listening for calls with an observer

As User::validatePassword() is now using Security::validatePassword() in its implementation in a transparent way, we don't want to expose any of this when setting the password to whoever is going to use the User model.

So, we'd like to think that when setting the password, our implementation will use Security::generatePasswordHash() in some way, so that when calling User::validatePassword(), we close the circle and everything should work without having to worry too much about encryption schemes and what not.

An immediate, somewhat logical, but quite abused way to implement a test that could cover this bit is the following:

public function testSetPasswordEncryptsThePasswordCorrectly() { $clearTextPassword = 'some ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required