Unit Test Generator For Basic Model Crud Operations.
UnitTestYiis auto-generates unit tests for basic Create, Read, Update and Delete actions on a given Model.
Yii 1.4 or above.
You must have a fixture for the given Model you wish to generate a test on.
- Place the `CrudUnit' directory into your extensions directory
- Place the file `CreateUnitTestCommand.php' into your 'commands/shell' directory.
- In your `config/test.php' add the import statement bellow
- Open your terminal and enter yiic shell
- Type createunittest
- You will be prompted to enter your Model name
- Enter the model name and hit enter.
- You will be prompted to enter the name of your fixture file without the
- Enter the fixture file name and hit enter.
- You will be prompted to enter your fixture key prefix
(Example `user_' as in ('user_1'=>array('id'=>1, etc..), user_2=>array('id'=>2, ...), ...).
- Enter the fixture key prefix and hit enter
- Yo will be asked "Are there attributes of '$modelName' that are contained in
fixture '$fixtureName' modified by beforeSave or other action(s)? [Yes|No]:"
- Enter 'yes' or 'no' and hit enter.
- Run your tests!
Update 1.3 ¶
NOW SUPPORTS MULTI-COLUMN-PRIMARY-KEYS
- Added more detailed messages on test failures
- Added a status flag for turning off data consistency checks on inserts and
updates. Useful when data is modified by methods like beforeSave().
- Everyone should download the latest version.