Beispiel #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));
 }
Beispiel #2
0
 /** @test */
 public function should_test_equality()
 {
     $one = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $two = UserId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $three = UserId::generate();
     $this->assertTrue($one->equals($two));
     $this->assertFalse($one->equals($three));
 }
Beispiel #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();
 }
Beispiel #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);
 }
Beispiel #5
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());
 }
Beispiel #8
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);
 }
Beispiel #9
0
 public function setUp()
 {
     $this->user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('username'), new HashedPassword('password'));
 }
Beispiel #10
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');
 }
Beispiel #11
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());
 }
 /**
  * Return the next identity
  *
  * @return UserId
  */
 public function nextIdentity()
 {
     return UserId::generate();
 }