public function testBuildingEntity() { $entity = new Email(); $this->assertInstanceOf('Expressly\\Entity\\Email', $entity->setEmail('*****@*****.**')); $this->assertInstanceOf('Expressly\\Entity\\Email', $entity->setAlias('default')); $this->assertEquals('*****@*****.**', $entity->getEmail()); $this->assertEquals('default', $entity->getAlias()); $this->assertJson(json_encode($entity->toArray())); $this->assertJsonStringEqualsJsonString(json_encode($entity->toArray()), json_encode(array('email' => '*****@*****.**', 'alias' => 'default'))); }
public function addEmail(Email $email) { $emails = $this->emails; $exists = function ($index, $el) use($emails, $email) { if ($el->toArray() == $email->toArray()) { return true; } return false; }; if (!$this->emails->exists($exists)) { $this->emails->add($email); } return $this; }