In this recipe, we will learn how to create test data that we can use to test our application without altering real data, and how to create our own unit tests to cover model functionality.
To go through this recipe, we need a basic application skeleton to work with and have the SimpleTest library installed. Go through the entire recipe, Setting up the test framework.
1. Create a file named
article_fixture.php
and place it in yourapp/tests/fixtures
folder with the following contents:<?php class ArticleFixture extends CakeTestFixture { public $import = 'Article'; public $records = array( array( 'id' => 1, 'title' => 'Article 1', 'body' => 'Body for Article 1' ), array( 'id' => 2, 'title' => 'Article 2', 'body' => 'Body for Article 2' ) ); } ?>
2. Create a file named
user_fixture.php
and place it in yourapp/tests/fixtures
folder with the following contents:<?php class UserFixture extends CakeTestFixture...