Testing the application with functional tests
While unit tests are used to test standalone components or component groups, functional tests allow for the testing of the complete application, like black box testing. We don't know what is inside and can only provide an input and get/verify the output. In our case, the input is the actions the user carries out in a browser, such as clicking on buttons or links, loading pages, and so on, while the output is what happens in the browser.
For our example, we will create a simple "check all" widget with a single button that checks and unchecks all checkboxes on the current page.
Getting ready
Make sure that you have a ready-to-use application and the required testing tools as described in the Setting up the testing environment recipe of this chapter.
Don't forget to run the server.
Drop the widget code into
protected/components/ECheckAllWidget.phpas follows:<?php class ECheckAllWidget extends CWidget { public $checkedTitle = 'Uncheck all'; ...