Exemplo n.º 1
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;
 }
Exemplo n.º 2
0
 /** @test */
 public function should_test_equality()
 {
     $one = GroupId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $two = GroupId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $three = GroupId::generate();
     $this->assertTrue($one->equals($two));
     $this->assertFalse($one->equals($three));
 }
Exemplo n.º 3
0
 /**
  * Load the fixtures
  *
  * @param ObjectManager $manager
  * @return void
  */
 public function load(ObjectManager $manager)
 {
     $group = new Group(GroupId::generate(), 'Cribbb');
     $id = ThreadId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $thread = new Thread($id, $group, 'Hello World');
     $manager->persist($thread);
     $manager->flush();
 }
Exemplo n.º 4
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();
 }
 /** @test */
 public function should_add_new_group()
 {
     $this->repository->add(new Group(GroupId::generate(), 'Cribbb'));
     $this->em->clear();
     $group = $this->repository->groupOfName('Cribbb');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Groups\\GroupId', $group->id());
     $this->assertEquals('Cribbb', $group->name());
     $this->assertEquals('cribbb', $group->slug());
 }
 /** @test */
 public function should_add_new_thread()
 {
     $group = new Group(GroupId::generate(), 'Cribbb');
     $id = ThreadId::generate();
     $thread = new Thread($id, $group, 'Hello World');
     $this->repository->add($thread);
     $this->em->clear();
     $thread = $this->repository->threadOfId($id);
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\ThreadId', $thread->id());
     $this->assertEquals('hello-world', $thread->slug());
 }
Exemplo n.º 7
0
 /** @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());
 }
Exemplo n.º 8
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');
 }
Exemplo n.º 9
0
 public function setUp()
 {
     $this->group = new Group(GroupId::generate(), 'Cribbb');
     $this->user = User::register(UserId::generate(), new Email('*****@*****.**'), new Username('username'), new HashedPassword('password'));
 }
Exemplo n.º 10
0
 /**
  * Return the next identity
  *
  * @return GroupId
  */
 public function nextIdentity()
 {
     return GroupId::generate();
 }
Exemplo n.º 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());
 }