You'll see a common pattern while writing your tests. This is because building Entities and complex Aggregates can be a very tedious and repetitive process. Inevitably, complexity and duplication will start creeping into your test suite. Consider the following Entity:
class Author
{
private $username;
private $email ;
private $fullName;
public function __construct(
Username $aUsername,
FullName $aFullName,
Email $anEmail
) {
$this->username = $aUsername;
$this->email = $anEmail ;
$this->fullName = $aFullName;
}
// ...
}
Somewhere in your system, you'll end up with a test looking like this:
class MyTest extends PHPUnit_Framework_TestCase
{
/**
* @test
*/
public function itDoesSomething()
{
$author = new Author(
new Username('johndoe'),
new FullName('John&apos...