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

Implementing the ActiveRecord class and its methods

Now, we can try the tests and see them not passing before we go through the implementation of the class. So, just run the following command, as we learned in the previous chapter:

$ cd tests
$ ../vendor/bin/codecept run unit

It's very probable that the preceding command will fail with the following error:

PHP Fatal error:  Call to undefined method app\models\User::tableName()

This is because our class has not yet been regenerated as ActiveRecord.

In the next section, we will start the work of making our tests pass by starting with the migrations to move some information into the database and progress from there.

Dealing with migrations

So, the best step forward is to define a user table in the database, ...

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