Yii Framework 1.1 Updates

February 9, 2010
The Yii Book If you like my writing on the Yii framework, you'll love "The Yii Book"!

Version 1.1 of the Yii framework was released just recently. I’m going back through the series I wrote on learning Yii and updating it for the latest version. Here’s what I found so far…From my Configuring Yii post…

Yii now creates two bootstrap files in the Web root directory: index.php and index-test.php. They are exactly the same except that index-test.php includes a different configuration file: /protected/config/test.php instead of /protected/config/main.php. However, the test configuration file just includes the main configuration file, then also enables the CDbFixtureManager component. This component is used to perform unit testing, a new addition in Yii 1.1.

Unit testing is all the rage in programming the past few years and it goes like this: you define very specific tests for different aspects of an application, then you run the application against those tests to confirm that things work as they should. As you build up and even refactor your code, you can continue to run those same tests to confirm that you haven’t broken some functionality in the process of adding new.

Anyway, Yii is suggesting now that you run your site through index-test.php to use unit testing during development stage, then switch to index.php for the live stage. Even if you don’t use unit testing, this is a nice model for having two configuration files: one for development and testing and one for live settings.

From my Creating Models, Views, and Controllers in Yii post…

The files generated by the CRUD commend have changed. You still get the controller and all of the View files, but the show.php file is now called view.php and the list.php file is now index.php. Both are still used to show the specifics of an individual record and list them all, respectively. There’s also a new View file called _view.php. This is a little template to display the information for a specific record. It’ll be used by view.php. Also three files for unit testing purposes are generated and stored in three subdirectories of protected/tests.

It looks like supporting unit testing is the main change thus far (for what you’ll see as you just get started). I’ve gone through five of the eight posts in the series and everything still works, you just get more stuff now. I’ll try to write up a post on unit testing separately and in a couple of days I’ll go through the separate Models, Controllers, and Views posts to check them for changes (at the very least, we know that some of the View files have changed names).