An important but often overlooked aspect of software development is testing our application to ensure that it performs as expected. There are three basic ways in which we can test our applications:
Unit testing
Functional testing
Acceptance testing
Unit testing enables us to test individual sections of code before coupling it with our application. Functional testing allows us to test the functional aspects of code within a simulated browser, and acceptance testing allows us to test our application within a real browser and verify that it does what we built it to do. With Yii2, we can use a tool called Codeception to create and execute unit, functional, and acceptance testing for our application. In this chapter, we'll cover how to create and run unit, functional, and acceptance testing in Yii2. In addition to these three types of testing, we can mock our data using fixtures, which we can use to bring our application to a fixed state before testing.