Exemplo n.º 1
0
 /**
  * @param UserId $id
  * @param string $name
  * @param int    $age
  */
 public function __construct(UserId $id, $name, $age)
 {
     parent::__construct($id);
     $this->name = $name;
     $this->fullName = StringLiteral::fromNative($name);
     $this->age = $age;
     $this->phonenumbers = new ArrayList();
     $this->roles = new ArraySet();
     $this->languagesLevel = new ArrayHashMap();
     $this->addresses = new ArraySet();
     $this->friends = new ArraySet();
 }
Exemplo n.º 2
0
 /**
  * Test get.
  */
 public function testGet()
 {
     parent::testGet();
     $this->given($repository = $this->randomRepository())->and($unique = $this->uniqueValue())->and($friend = new User(UserId::next(), 'Ivan', 32))->and($friend1 = new User(UserId::next(), 'Karel', 32))->and($repository->persist($friend))->and($repository->persist($friend1))->and($unique->addFriend($friend))->and($unique->addFriend($friend1))->and($repository->persist($unique))->when($object = $repository->get($unique->id()))->then()->object($object->fullName())->isEqualTo(StringLiteral::fromNative('Methuselah'))->integer($object->languagesLevel()->get('english'))->isEqualTo(10)->boolean($object->mainRole()->is(Role::ROLE_ADMIN))->isTrue()->array($object->roles()->toArray())->contains(Role::ROLE_ADMIN)->array($object->phonenumbers()->toArray())->contains('+34 685 165 267')->string($object->fax()->number())->isEqualTo('+34-208-1234567')->array($object->addresses()->toArray())->object[0]->isInstanceOf(Address::class)->string($object->addresses()->toArray()[0]->name())->isEqualTo('Home')->object($object->addresses()->toArray()[0]->coordinate())->isEqualTo(Coordinate::fromLatLng(41.390205, 2.154007))->integer($object->friends()->count())->isEqualTo(2);
 }
Exemplo n.º 3
0
 public function testCompareTo()
 {
     $this->given($one = $this->fromNative(1), $number = $this->fromNative($this->randomNativeNumber()), $greather = $number->add($one), $less = $number->sub($one))->then->variable($number->compareTo($number))->isEqualTo(0)->variable($number->compareTo($greather))->isEqualTo(-1)->variable($number->compareTo($less))->isEqualTo(1)->exception(function () use($number) {
         $number->toInteger()->compareTo(StringLiteral::fromNative('foo'));
     })->isInstanceOf(\InvalidArgumentException::class);
 }
Exemplo n.º 4
0
 /**
  * @param string $value
  *
  * @return SequenceId
  */
 public static function fromNative($value)
 {
     return new self(StringLiteral::fromNative($value));
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 protected function fromNative($value)
 {
     return StringLiteral::fromNative($value);
 }