O'Reilly logo

Learn CakePHP: With Unit Testing, Second Edition by Rādhārādhya Dāsa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Sándor Gömöri 2016

Rādhārādhya Dāsa, Learn CakePHP, 10.1007/978-1-4842-1212-7_8

8. Model Tests

Rādhārādhya Dāsa

(1)Somogyvamos, Hungary

A337704_2_En_8_Figa_HTML.jpg

We’re big fans of fat models

OK. I won’t torture you anymore. Let’s write our first unit test.

Use the following sample code in your UserFixture.php file.

 1  <?php             2  namespace App\Test\Fixture;             3               4  use Cake\TestSuite\Fixture\TestFixture;             5               6  class UsersFixture extends TestFixture             7  {             8               9     public $import = ['model' => 'Users'];             10                  11     public $records = [             12          [             13              'id' => 1,             14              'username' => 'rrd',             15              'password' => 'Gouranga',             16              'role' ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required