Chapter 6 of the Symfony for PHP developers track
Never again!
6 exercises · 1,460 XP · about 4 h
WebTestCasecreateClient()submitFormAssertionsTest databaseFixturesCrawlerUnit testTestCase#[DataProvider]expectExceptionloginUser()Security tests401 / 403Roles and votersjsonRequest()API testsJSONAccess tokenReliable testsTest dataPrecise assertions
The chapter's exercises
-
The first safety net
Exercise 1 · 220 XP · 4 objectives checked by tests
Gorm has done the math. Since the website opened, Pippin has “improved” the tavern four times, and four times everything broke. Each time, they only found out because a customer complained.
WebTestCasecreateClient()submitFormAssertions
-
Data to test with
Exercise 2 · 230 XP · 4 objectives checked by tests
Gorm's second project: the menu for a budget (/menu?budget=5). Broke adventurers count on it: no way it should offer them a stew at 12 gold pieces.
Test databaseFixturesCrawler
-
The bill, please
Exercise 3 · 230 XP · 5 objectives checked by tests
No more mental arithmetic: Gorm has had an Addition (bill) service written, which calculates each table's bill. Its rules fit in three lines:
Unit testTestCase#[DataProvider]expectException
-
Who is allowed?
Exercise 4 · 240 XP · 5 objectives checked by tests
The tavern's security has already given way once (remember the stolen keys). Now Gorm wants tests that check every access rule, for every role:
loginUser()Security tests401 / 403Roles and voters
-
Testing the API
Exercise 5 · 240 XP · 5 objectives checked by tests
The scrolls' API has become the tavern's main reservation channel. A regression there would be costly. And a leak of a guild's seal would be even costlier.
jsonRequest()API testsJSONAccess token
-
🐉 Boss: the lying tests
Exercise 6 · 300 XP · 5 objectives checked by tests
Pippin has heard about tests. He wrote some, proudly: “All green, boss!”
Reliable testsTest dataPrecise assertions