Book Image

Learning Yii Testing

Book Image

Learning Yii Testing

Overview of this book

Table of Contents (16 chapters)
Learning Yii Testing
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Dealing with external dependencies


We left our suite of unit tests at an almost complete status. What we had left to cover with tests was the validatePassword() method from our User model class.

The problem that this method is giving us is that we are planning to use our beloved security component, kindly provided by Yii, to encrypt and decrypt the password and verify its correctness. This component is available throughout the life of the application via Yii::$app->getSecurity().

The yii\base\Security class exposes a series of methods to help you strengthen your application. The use we will make of it is quite limited, but I would recommend reading a bit more about it on the official documentation available at http://www.yiiframework.com/doc-2.0/guide-security-authentication.html and the following sections that will cover all aspects of authentication, encryption, and so forth.

Let's then define how we think our implementation should work for this method. The documented use for validating...