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 first unit test

Yii provides an empty UserTest class for us, so we're going to start working from there. Head over to tests/codeception/unit/models/ and open the UserTest.php file.

So now our question is: what are we going to implement at this point? Well, the answer will be quite simple, once we've understood what the aim of the unit tests is.

Unit tests, as well as functional and acceptance tests, are a black box testing system: The tests will simply use the interface provided by the object and will make sure that the outputs are as expected. Since the implementation doesn't count if this changes slightly, or even radically, the tests should still pass assuming the interface remained the same.

White box testing, which is provided ...

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