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

Using the User model

Let's start by having a look at how the User model is used in Yii.

You can open the file located at /models/User.php.

The first thing to notice is that the User class extends from a generic Yii Object class and implements IdentityInterface:

// User.php

namespace app\models;

use yii\base\Object;
use yii\web\IdentityInterface;

class User extends Object implements IdentityInterface
{
    // ...

The yii\base\Object class is the parent class of all classes, which implements the concept of virtual attributes, with the use of dynamically invoked getters and setters, while yii\web\IdentityInterface provides the signature for methods we need to implement in our class to provide the authentication mechanism.

You will also notice by the private ...

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