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

Component testing of the model


Testing the validation of a model and any further data manipulation, until it reaches the database and comes back, is the basic step in Yii to ensure that the model has clear and well-defined validation rules implemented. This is effectively useful when it comes down to preventing clients from being able to pass additional or wrong data, when interacting with the system.

If you care about security, this is something you might need to investigate a bit further, if you haven't done it already.

Tip

I'd like to stress the position we've taken in the previous statement: We're taking the consumer/client perspective. At this particular moment, we don't know how things are going to be implemented, so it's better to focus on the usage of the model.

So, let's get back to /tests/codeception/unit/ models/UserTest.php: The file should already be there, and it's more or less what you would get by running the following command:

$ ../vendor/bin/codecept generate:phpunit unit models...