/** * @test */ public function shouldSetContentType() { //given $_SERVER['CONTENT_TYPE'] = 'application/json'; //when ContentType::set('text/plain'); //then $this->assertEquals('text/plain', ContentType::value()); }
/** * @test */ public function shouldReturnHtmlForUnsupportedAcceptAndNoRequestContentType() { //given $_SERVER['HTTP_ACCEPT'] = 'application/unsupported'; ContentType::set(null); //when $resolved = ResponseTypeResolve::resolve(); //then $this->assertEquals('text/html', $resolved); }
/** * @test */ public function shouldAcceptEmptyJson() { //given StreamStub::register('json'); StreamStub::$body = ''; ContentType::set('application/json'); //when $parameters = $this->getRequestParameters('json://input'); //then ArrayAssert::that($parameters)->hasSize(0); StreamStub::unregister(); }