Unit Testing Cake PHP
Unit Testing Cake PHP
removeBannedWords($text, $banned)
• users_controller = users_controller.test.php
• post = post.test.php
Group Tests
• Underscored and lowercase but any name
• models.group.php
• payment_processing.group.php
Classes involved
You
Classes involved
You
Classes involved
SimpleTest
UnitTestCase
WebTestCase
Mock
SimpleSocket
You SimpleTest
Classes involved
SimpleTest
UnitTestCase
WebTestCase
Mock
SimpleSocket
You SimpleTest
Classes involved
CakeTestCase UnitTestCase
CakeWebTestCase WebTestCase
CakeTestFixture Mock
CakeTestModel SimpleSocket
You SimpleTest
Classes involved
CakeTestCase UnitTestCase
CakeWebTestCase WebTestCase
CakeTestFixture Mock
CakeTestModel SimpleSocket
You SimpleTest
Classes involved
CakeTestCase
CakeWebTestCase WebTestCase
CakeTestFixture Mock
CakeTestModel SimpleSocket
You SimpleTest
Classes involved
CakeTestCase
CakeWebTestCase
CakeTestFixture Mock
CakeTestModel SimpleSocket
You SimpleTest
CakeTestCase
• Test case class that all App and Core test cases
should extend.
testAction($url, $params);
getTests()
type:
• Using Mock::generate()
• You can mock methods that don’t exist.
• This allows you to test methods that haven’t
been written.
Partial Mocking bird
Anything that went wrong (In most cases) MVC Whether your site withstands all
already Application flow security attacks.
Anything real money or human If your controller sets the right view
Your interface
lives depend on vars in trivial cases.
• Do regular breaks
• If testing does not help you start with a
problem, explain that problem to someone else
Things we skipped
• Testing Behaviors.
• Testing Components.
• Using CakeWebTestCase
May the green bar
be with you!