Esempio n. 1
0
 /** @test */
 public function should_test_equality()
 {
     $one = new Admin($this->id, $this->email, $this->username);
     $two = new Admin($this->id, $this->email, $this->username);
     $three = new Admin(UserId::generate(), new Email('*****@*****.**'), new Username('other'));
     $this->assertTrue($one->equals($two));
     $this->assertFalse($one->equals($three));
 }
Esempio n. 2
0
 /**
  * Find a User by their id
  *
  * @param string $id
  * @return User
  */
 private function findUserById($id)
 {
     $user = $this->users->userById(UserId::fromString($id));
     if ($user) {
         return $user;
     }
     throw new ValueNotFoundException("{$id} is not a valid user id");
 }
Esempio n. 3
0
 /**
  * Load the fixtures
  *
  * @param ObjectManager $manager
  * @return void
  */
 public function load(ObjectManager $manager)
 {
     $user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('username'), new HashedPassword('qwerty'));
     $group = new Group(GroupId::generate(), 'Cribbb');
     $thread = new Thread(ThreadId::generate(), $group, 'Hello World');
     $post = new Post(PostId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'), $user, $thread, 'Hello world.');
     $manager->persist($post);
     $manager->flush();
 }
Esempio n. 4
0
 /** @test */
 public function should_register_new_user()
 {
     $this->repository->shouldReceive('userOfEmail')->once()->andReturn(null);
     $this->repository->shouldReceive('userOfUsername')->once()->andReturn(null);
     $this->repository->shouldReceive('nextIdentity')->once()->andReturn(UserId::generate());
     $this->repository->shouldReceive('add')->once();
     $user = $this->service->register('*****@*****.**', 'username', 'password');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
 }
Esempio n. 5
0
 /**
  * Load the User fixtures
  *
  * @param ObjectManager $manager
  * @return void
  */
 public function load(ObjectManager $manager)
 {
     $id = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $email = new Email('*****@*****.**');
     $username = new Username('username');
     $password = new HashedPassword('qwerty');
     $user = User::register($id, $email, $username, $password);
     $manager->persist($user);
     $manager->flush();
 }
Esempio n. 6
0
 /** @test */
 public function should_create_new_group()
 {
     $this->groups->shouldReceive('groupOfName')->once()->andReturn(null);
     $this->groups->shouldReceive('add')->once()->andReturn(null);
     $this->user->shouldReceive('id')->once()->andReturn(UserId::generate());
     $this->user->shouldReceive('email')->once()->andReturn(new Email('*****@*****.**'));
     $this->user->shouldReceive('username')->once()->andReturn(new Username('username'));
     $group = $this->service->create($this->user, 'Cribbb');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Groups\\Group', $group);
     $this->assertEquals('Cribbb', $group->name());
     $this->assertEquals(1, $group->admins()->count());
 }
 /** @test */
 public function should_add_new_post()
 {
     $user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('username'), new HashedPassword('qwerty'));
     $group = new Group(GroupId::generate(), 'Cribbb');
     $thread = new Thread(ThreadId::generate(), $group, 'Hello World');
     $id = PostId::generate();
     $post = new Post($id, $user, $thread, 'Hello world');
     $this->repository->add($post);
     $this->em->clear();
     $post = $this->repository->postOfId($id);
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\PostId', $post->id());
     $this->assertEquals('hello-world', $post->slug());
 }
 /** @test */
 public function should_add_new_user()
 {
     $id = UserId::generate();
     $email = new Email('*****@*****.**');
     $username = new Username('username');
     $password = new HashedPassword('qwerty');
     $this->repository->add(User::register($id, $email, $username, $password));
     $this->em->clear();
     $user = $this->repository->userOfUsername(new Username('username'));
     $this->assertEquals($id, $user->id());
     $this->assertEquals($email, $user->email());
     $this->assertEquals($username, $user->username());
 }
Esempio n. 9
0
 public function setUp()
 {
     $id = UserId::generate();
     $email = new Email('*****@*****.**');
     $username = new Username('username');
     $password = new HashedPassword('qwerty123');
     $this->user = User::register($id, $email, $username, $password);
     $this->fixture = ['id' => ReminderId::generate(), 'code' => ReminderCode::generate(), 'email' => new Email('*****@*****.**')];
     $this->users = m::mock('Cribbb\\Domain\\Model\\Identity\\UserRepository');
     $this->reminders = m::mock('Cribbb\\Domain\\Model\\Identity\\ReminderRepository');
     $this->hasher = m::mock('Cribbb\\Domain\\Services\\Identity\\HashingService');
     $this->service = new ReminderService($this->reminders, $this->users, $this->hasher);
 }
Esempio n. 10
0
 /** @test */
 public function should_return_user_id_as_string()
 {
     $id = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', $id->toString());
     $this->assertEquals('d16f9fe7-e947-460e-99f6-2d64d65f46bc', (string) $id);
 }
Esempio n. 11
0
 public function setUp()
 {
     $this->user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('username'), new HashedPassword('password'));
 }
Esempio n. 12
0
File: User.php Progetto: alle/cribbb
 /**
  * Set the User's id
  *
  * @param UserId $id
  * @return void
  */
 private function setId(UserId $id)
 {
     $this->id = $id->toString();
 }
Esempio n. 13
0
 public function setUp()
 {
     $this->user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('username'), new HashedPassword('password'));
     $this->thread = new Thread(ThreadId::generate(), new Group(GroupId::generate(), 'Cribbb'), 'Hello World');
 }
Esempio n. 14
0
 /** @test */
 public function should_become_an_admin_of_a_group()
 {
     $user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('zuck'), new HashedPassword('facemash'));
     $group = new Group(GroupId::generate(), 'Porcellian');
     $this->assertEquals(0, $group->admins()->count());
     $this->assertEquals(0, $user->adminOf()->count());
     $user->addAsAdminOf($group);
     $this->assertEquals(1, $group->admins()->count());
     $this->assertEquals(1, $user->adminOf()->count());
 }
Esempio n. 15
0
 /**
  * Find a user by their id
  *
  * @param UserId $id
  * @return User
  */
 public function userOfId(UserId $id)
 {
     return $this->em->getRepository($this->class)->findOneBy(['id' => $id->toString()]);
 }