June 2017
Intermediate to advanced
394 pages
8h 52m
English
Test Data Builders are just normal Builders with default values used exclusively in your test suites so that you don't have to specify irrelevant parameters on specific test cases:
class AuthorBuilder{ private $username; private $email ; private $fullName; private function __construct() { $this->username = new Username('johndoe'); $this->email = new Email('john@doe.com'); $this->fullName = new FullName('John', 'Doe'); } public static function anAuthor() { return new self(); } public function withFullName(FullName $aFullName) { $this->fullName = $aFullName; return $this; } public function withUsername(Username $aUsername) { $this->username = $aUsername; return $this; } public function withEmail(Email $anEmail) { $this->email ...