Beispiel #1
0
 /** @test */
 public function should_create_post()
 {
     $this->group->addMember($this->user);
     $thread = new Thread(ThreadId::generate(), $this->group, 'Hello World');
     $post = $thread->createNewPost($this->user, 'Once upon a time...');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\Post', $post);
 }
Beispiel #2
0
 /**
  * Create a new Group
  *
  * @param User $user
  * @param string $name
  * @return Group
  */
 public function create(User $user, $name)
 {
     $this->checkNameIsUnique($name);
     $group = new Group(GroupId::generate(), $name);
     $group->addAdmin($user);
     $this->groups->add($group);
     return $group;
 }
Beispiel #3
0
 /** @test */
 public function should_throw_exception_when_non_member_attempts_to_create_thread()
 {
     $this->setExpectedException('Exception');
     $group = new Group(GroupId::generate(), 'Cribbb');
     $thread = $group->startNewThread($this->user, 'Hello World');
 }
Beispiel #4
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());
 }
Beispiel #5
0
 /**
  * Add the User as an Admin of a Group
  *
  * @param Group $group
  * @return void
  */
 public function addAsAdminOf(Group $group)
 {
     $this->adminOf[] = $group;
     $group->addAdmin($this);
 }