"value":"\n <p>When writing a test, something that I like to do is start by writing the first assertion first, and then work backwards.<\/p>\n\n<p>My first assertion might be <code>self::assertTrue($result)<\/code>.<\/p>\n\n<p>If I ran this test, it would fail because of the undefined <code>$result<\/code> variable - but it's clear to me what I need next by asking, \"Where does <code>$result<\/code> come from?\".<\/p>\n\n<p>If I need to call a method on another class and get the result, I'll add it before the assertion. Then I repeat the process and ask, \"What do I need for this to work?\".<\/p>\n\n<p>Maybe I need to create some users or content in the application for the class to query and return a result based on it, so I'll create those.<\/p>\n\n<p>With this approach, I'm not making any assumptions about the test's prerequisites, and I usually find that I end up with cleaner and more focused tests.<\/p>\n\n ",
"format":"full_html",
"processed":"\n <p>When writing a test, something that I like to do is start by writing the first assertion first, and then work backwards.<\/p>\n\n<p>My first assertion might be <code>self::assertTrue($result)<\/code>.<\/p>\n\n<p>If I ran this test, it would fail because of the undefined <code>$result<\/code> variable - but it's clear to me what I need next by asking, \"Where does <code>$result<\/code> come from?\".<\/p>\n\n<p>If I need to call a method on another class and get the result, I'll add it before the assertion. Then I repeat the process and ask, \"What do I need for this to work?\".<\/p>\n\n<p>Maybe I need to create some users or content in the application for the class to query and return a result based on it, so I'll create those.<\/p>\n\n<p>With this approach, I'm not making any assumptions about the test's prerequisites, and I usually find that I end up with cleaner and more focused tests.<\/p>\n\n ",