/** @test */ public function should_find_group() { $group = m::mock('Cribbb\\Domain\\Model\\Groups\\Group'); $this->groups->shouldReceive('groupBySlug')->once()->andReturn($group); $group = $this->service->find('cribbb'); $this->assertInstanceOf('Cribbb\\Domain\\Model\\Groups\\Group', $group); }
/** @test */ public function should_create_new_group() { $user = m::mock('Cribbb\\Domain\\Model\\Identity\\User'); $this->users->shouldReceive('userById')->once()->andReturn($user); $this->groups->shouldReceive('groupOfName')->once()->andReturn(null); $this->groups->shouldReceive('add')->once(); $group = $this->service->create('7c5e8127-3f77-496c-9bb4-5cb092969d89', 'Cribbb'); $this->assertInstanceOf('Cribbb\\Domain\\Model\\Groups\\Group', $group); }
/** @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_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); }
/** @test */ public function should_return_false_when_not_unique() { $this->repository->shouldReceive('groupOfName')->andReturn(['id' => 1]); $this->assertFalse($this->spec->isSatisfiedBy('Cribbb')); }