From the course: Learning CakePHP 3
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Testing a CakePHP behavior - CakePHP Tutorial
From the course: Learning CakePHP 3
Testing a CakePHP behavior
- [Voiceover] We've tested the major parts of our CakePHP application. However, we still have a portion of the model layer to test which is a behavior. We wrote a Users Find Behavior that adds a custom find to find the records that match a certain User ID. To test this, we can load in our bookmarks and varify that we have a number of bookmarks that match a certain User ID. So, to start, let's open up the Users Find Behavior Test Class which is at: Test, TestCase, Model, Behavior, UsersFindBehaviorTest.php. Okay, if we look at this class, we need to add a few things from what we've worked with in the past. We need to load in an instance of the bookmarks Table Class to be able to perform our find and we need to load in the Fixture for bookmarks. Let's start with the first part, loading in the instance of the bookmarks table class. We did this in the bookmarks controller test class so we can open up that file and copy that code, and use it. Open up the file at Test, TestCase, Controller,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.