In this recipe, we will learn how to prepare our CakePHP application with all the elements needed to create our own unit tests, setting up the foundation for the rest of the recipes in this chapter.
To go through the recipes included in this chapter, we need some data to work with. Create the following tables by issuing these SQL statements:
CREATE TABLE `articles`( `id`INT UNSIGNED NOT NULL AUTO_INCREMENT, `title` VARCHAR(255) NOT NULL, `body` TEXT NOT NULL, PRIMARY KEY(`id`) ); CREATE TABLE `users`( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `username` VARCHAR(255) NOT NULL, PRIMARY KEY(`id`) ); CREATE TABLE `votes`( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT, `article_id` INT NOT NULL, `user_id` INT NOT NULL, `vote` INT UNSIGNED NOT NULL, PRIMARY KEY(`id`), FOREIGN KEY `votes__articles`(`article_id`) REFERENCES `articles`(`id`), FOREIGN KEY `votes__users`(`user_id`) REFERENCES `users`(`id`) );
Create a controller in a file named articles_controller...