/** @test */ public function should_fail_to_create_post_when_user_is_not_a_member() { $this->setExpectedException('Exception'); $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); }
/** @test */ public function should_test_equality() { $one = ThreadId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $two = ThreadId::fromString('d16f9fe7-e947-460e-99f6-2d64d65f46bc'); $three = ThreadId::generate(); $this->assertTrue($one->equals($two)); $this->assertFalse($one->equals($three)); }
/** * 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_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()); }
/** @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()); }
/** * Start a new Thread * * @param User $user * @param string $subject * @return Thread */ public function startNewThread(User $user, $subject) { if ($this->members->contains($user)) { $thread = new Thread(ThreadId::generate(), $this, $subject); $this->threads[] = $thread; return $thread; } throw new Exception('This user is not a member of the Group!'); }
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'); }