set() public static method

public static set ( $contentType )
Example #1
0
 /**
  * @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);
 }
Example #3
0
 /**
  * @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();
 }