Пример #1
0
 /** @test */
 public function should_test_equality()
 {
     $one = PostId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $two = PostId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc');
     $three = PostId::generate();
     $this->assertTrue($one->equals($two));
     $this->assertFalse($one->equals($three));
 }
Пример #2
0
 /** @test */
 public function should_create_post()
 {
     $post = new Post(PostId::generate(), $this->user, $this->thread, 'Once upon a time...');
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\Post', $post);
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\PostId', $post->id());
     $this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $post->user());
     $this->assertInstanceOf('Carbon\\Carbon', $post->createdAt());
     $this->assertEquals('Once upon a time...', $post->body());
 }
Пример #3
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());
 }
Пример #4
0
 /**
  * Create new Post
  *
  * @param User $user
  * @param string $body
  * @return Post
  */
 public function createNewPost(User $user, $body)
 {
     if ($this->group->isMember($user)) {
         $post = new Post(PostId::generate(), $user, $this, $body);
         $this->posts[] = $post;
         return $post;
     }
     throw new Exception('This user is not a member of the Group!');
 }