예제 #1
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);
 }
예제 #2
0
 /** @test */
 public function should_allow_user_to_join_the_group()
 {
     $user = m::mock('Cribbb\\Domain\\Model\\Identity\\User');
     $group = m::mock('Cribbb\\Domain\\Model\\Groups\\Group');
     $group->shouldReceive('addMember')->once();
     $this->users->shouldReceive('userById')->once()->andReturn($user);
     $this->groups->shouldReceive('groupById')->once()->andReturn($group);
     $group = $this->service->join('7c5e8127-3f77-496c-9bb4-5cb092969d89', 'a3d9e532-0ea8-4572-8e83-119fc49e4c6f');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Groups\\Group', $group);
 }
 /** @test */
 public function should_register_new_user()
 {
     $this->repository->shouldReceive('userOfEmail')->andReturn(null);
     $this->repository->shouldReceive('userOfUsername')->andReturn(null);
     $this->repository->shouldReceive('nextIdentity')->andReturn($this->uuid);
     $this->hashing->shouldReceive('hash')->andReturn($this->password);
     $this->repository->shouldReceive('add');
     $this->dispatcher->shouldReceive('dispatch');
     $user = $this->service->registerUser('*****@*****.**', 'username', 'password');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
 }
예제 #4
0
 /** @test */
 public function should_reset_password_and_return_user()
 {
     $reminder = new Reminder($this->fixture['id'], $this->fixture['email'], $this->fixture['code']);
     $this->reminders->shouldReceive('findReminderByEmailAndCode')->andReturn($reminder);
     $this->users->shouldReceive('userOfEmail')->andReturn($this->user);
     $this->hasher->shouldReceive('hash')->andReturn(new HashedPassword('qwerty123'));
     $this->users->shouldReceive('update');
     $this->reminders->shouldReceive('deleteReminderByCode');
     $user = $this->service->reset('*****@*****.**', 'qwerty123', 'abc123');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
 }
예제 #5
0
 /** @test */
 public function should_create_new_thread()
 {
     $user = m::mock('Cribbb\\Domain\\Model\\Identity\\User');
     $group = m::mock('Cribbb\\Domain\\Model\\Groups\\Group');
     $thread = m::mock('Cribbb\\Domain\\Model\\Discussion\\Thread');
     $this->users->shouldReceive('userById')->once()->andReturn($user);
     $this->groups->shouldReceive('groupById')->once()->andReturn($group);
     $group->shouldReceive('startNewThread')->once()->andReturn($thread);
     $this->threads->shouldReceive('add')->once();
     $thread = $this->service->create('7c5e8127-3f77-496c-9bb4-5cb092969d89', 'a3d9e532-0ea8-4572-8e83-119fc49e4c6f', 'Hello World');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\Thread', $thread);
 }
예제 #6
0
 /** @test */
 public function should_create_new_post()
 {
     $user = m::mock('Cribbb\\Domain\\Model\\Identity\\User');
     $thread = m::mock('Cribbb\\Domain\\Model\\Discussion\\Thread');
     $post = m::mock('Cribbb\\Domain\\Model\\Discussion\\Post');
     $this->users->shouldReceive('userById')->once()->andReturn($user);
     $this->threads->shouldReceive('threadById')->once()->andReturn($thread);
     $thread->shouldReceive('createNewPost')->once()->andReturn($post);
     $this->posts->shouldReceive('add')->once();
     $post = $this->service->create('7c5e8127-3f77-496c-9bb4-5cb092969d89', 'a3d9e532-0ea8-4572-8e83-119fc49e4c6f', 'Hello World');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\Post', $post);
 }
예제 #7
0
 /** @test */
 public function should_reset_password_and_return_user()
 {
     $reminder = m::mock('Cribbb\\Domain\\Model\\Identity\\Reminder');
     $reminder->shouldReceive('isValid')->andReturn(true);
     $this->reminders->shouldReceive('findReminderByEmailAndCode')->andReturn($reminder);
     $user = m::mock('Cribbb\\Domain\\Model\\Identity\\User');
     $this->users->shouldReceive('userOfEmail')->once()->andReturn($user);
     $user->shouldReceive('resetPassword')->once();
     $this->users->shouldReceive('update')->once();
     $this->reminders->shouldReceive('deleteReminderByCode')->once();
     $user = $this->service->reset('*****@*****.**', 'password', 'abc123');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
 }
예제 #8
0
 /** @test */
 public function should_return_false_when_not_unique()
 {
     $this->repository->shouldReceive('userOfUsername')->andReturn(['id' => 1]);
     $this->assertFalse($this->spec->isSatisfiedBy(new Username('philipbrown')));
 }
예제 #9
0
 /** @test */
 public function should_return_false_when_not_unique()
 {
     $this->repository->shouldReceive('userOfEmail')->andReturn(['id' => 1]);
     $this->assertFalse($this->spec->isSatisfiedBy(new Email('*****@*****.**')));
 }