public function testCreateHome()
 {
     $entity = new Phone();
     $entity->setType(Phone::PHONE_TYPE_HOME)->setCountryCode(44)->setNumber('02123456789');
     $this->assertEquals(Phone::PHONE_TYPE_HOME, $entity->getType());
     $this->assertEquals(44, $entity->getCountryCode());
     $this->assertEquals('02123456789', $entity->getNumber());
     $this->assertJson(json_encode($entity->toArray()));
     $this->assertJsonStringEqualsJsonString(json_encode($entity->toArray()), json_encode(array('type' => 'L', 'countryCode' => 44, 'number' => '02123456789')));
 }
Beispiel #2
0
 public function addPhone(Phone $phone)
 {
     $phones = $this->phones;
     $exists = function ($index, $el) use($phones, $phone) {
         if ($el->toArray() == $phone->toArray()) {
             return true;
         }
         return false;
     };
     if (!$this->phones->exists($exists)) {
         $this->phones->add($phone);
     }
     return $this;
 }