/** @test */ public function it_responds_internal_error_when_something_bad_happens() { $this->speakers->shouldReceive('findProfile')->andThrow(new Exception('Zomgz it blew up somehow.')); $response = $this->sut->handleShowSpeakerProfile($this->getRequest()); $this->assertEquals(500, $response->getStatusCode()); $this->assertContains('Zomgz it blew up somehow', $response->getContent()); }
/** @test */ public function it_should_respond_unauthorized_when_no_authentication_provided() { $this->speakers->shouldReceive('getTalks')->andThrow(\OpenCFP\Domain\Services\NotAuthenticatedException::class); $response = $this->sut->handleViewAllTalks($this->getValidRequest()); $this->assertEquals(401, $response->getStatusCode()); $this->assertContains('Unauthorized', $response->getContent()); }
public function handleViewTalk(Request $request, $id) { try { $talk = $this->speakers->getTalk($id); return $this->setStatusCode(Response::HTTP_OK)->respond($talk->toArrayForApi()); } catch (NotAuthenticatedException $e) { return $this->respondUnauthorized(); } }
/** * @param Request $request * * @return JsonResponse */ public function handleShowSpeakerProfile(Request $request) { try { $profile = $this->speakers->findProfile(); return $this->respond($profile->toArrayForApi()); } catch (NotAuthenticatedException $e) { return $this->respondUnauthorized(); } catch (Exception $e) { return $this->respondInternalError($e->getMessage()); } }
/** @test */ public function it_doesnt_allow_talk_submissions_after_cfp_has_ended() { $this->callForProposal->shouldReceive('isOpen')->once()->andReturn(false); $this->setExpectedException('Exception', 'has ended'); $submission = TalkSubmission::fromNative(['title' => 'Sample Talk', 'description' => 'Some example talk for our submission', 'type' => 'regular', 'category' => 'api', 'level' => 'mid']); $this->sut->submitTalk($submission); }
/** @test */ public function it_guards_if_spot_relation_ever_returns_talks_that_arent_owned_by_speaker() { $this->trainStudentRepositoryToReturnSampleSpeaker($this->getSpeakerFromMisbehavingSpot()); $this->setExpectedException('OpenCFP\\Application\\NotAuthorizedException'); $this->sut->getTalk(self::SPEAKER_ID, 1); }