Ejemplo n.º 1
0
$t->diag('->getRequestFormat() ->setRequestFormat()');
$t->ok(is_null($request->getRequestFormat()), '->getRequestFormat() returns null if the format is not defined in the request');
$request->setParameter('sf_format', 'js');
$t->is($request->getRequestFormat(), 'js', '->getRequestFormat() returns the request format');
$request->setRequestFormat('css');
$t->is($request->getRequestFormat(), 'css', '->setRequestFormat() sets the request format');
// ->getFormat() ->setFormat()
$t->diag('->getFormat() ->setFormat()');
$request->setFormat('js', 'application/x-javascript');
$t->is($request->getFormat('application/x-javascript'), 'js', '->getFormat() returns the format for the given mime type');
$request->setFormat('js', array('application/x-javascript', 'text/js'));
$t->is($request->getFormat('text/js'), 'js', '->setFormat() can take an array of mime types');
$t->is($request->getFormat('foo/bar'), null, '->getFormat() returns null if the mime type does not exist');
// ->getMimeType()
$t->diag('->getMimeType()');
$t->is($request->getMimeType('js'), 'application/x-javascript', '->getMimeType() returns the first mime type for the given format');
$t->is($request->getMimeType('foo'), null, '->getMimeType() returns null if the format does not exist');
// ->isSecure()
$t->diag('->isSecure()');
$t->is($request->isSecure(), false, '->isSecure() returns false if request is not secure');
$_SERVER['HTTPS'] = 'ON';
$t->is($request->isSecure(), true, '->isSecure() checks the "HTTPS" environment variable');
$_SERVER['HTTPS'] = 'on';
$t->is($request->isSecure(), true, '->isSecure() checks the "HTTPS" environment variable');
$_SERVER['HTTPS'] = '1';
$t->is($request->isSecure(), true, '->isSecure() checks the "HTTPS" environment variable');
$request->resetPathInfoArray();
$_SERVER['HTTP_SSL_HTTPS'] = 'ON';
$t->is($request->isSecure(), true, '->isSecure() checks the "HTTP_SSL_HTTPS" environment variable');
$_SERVER['HTTP_SSL_HTTPS'] = 'on';
$t->is($request->isSecure(), true, '->isSecure() checks the "HTTP_SSL_HTTPS" environment variable');