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

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, fill it with the data we would need, and then implement the user model on top of it with the required methods from the interface.

Note

There is more to be said about migrations and the documentation about it is being improved and expanded every...