Author: Kris.Wallsmith
Date: 2010-09-13 14:42:39 +0200 (Mon, 13 Sep 2010)
New Revision: 30894

Modified:
   branches/1.3/test/unit/request/sfWebRequestTest.php
   branches/1.4/test/unit/request/sfWebRequestTest.php
Log:
[1.3, 1.4] improved test coverage of sfWebRequest::isSecure()

Modified: branches/1.3/test/unit/request/sfWebRequestTest.php
===================================================================
--- branches/1.3/test/unit/request/sfWebRequestTest.php 2010-09-13 09:00:20 UTC 
(rev 30893)
+++ branches/1.3/test/unit/request/sfWebRequestTest.php 2010-09-13 12:42:39 UTC 
(rev 30894)
@@ -10,7 +10,7 @@
 
 require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
 
-$t = new lime_test(57);
+$t = new lime_test(65);
 
 class myRequest extends sfWebRequest
 {
@@ -108,6 +108,31 @@
 $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');
+unset($_SERVER['HTTPS']);
+
+$_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');
+$_SERVER['HTTP_SSL_HTTPS'] = '1';
+$t->is($request->isSecure(), true, '->isSecure() checks the "HTTP_SSL_HTTPS" 
environment variable');
+unset($_SERVER['HTTP_SSL_HTTPS']);
+
+$_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
+$t->is($request->isSecure(), true, '->isSecure() checks the 
"HTTP_X_FORWARDED_PROTO" environment variable');
+unset($_SERVER['HTTP_X_FORWARDED_PROTO']);
+
 // ->getUriPrefix()
 $t->diag('->getUriPrefix()');
 $_SERVER['SERVER_PORT'] = '80';

Modified: branches/1.4/test/unit/request/sfWebRequestTest.php
===================================================================
--- branches/1.4/test/unit/request/sfWebRequestTest.php 2010-09-13 09:00:20 UTC 
(rev 30893)
+++ branches/1.4/test/unit/request/sfWebRequestTest.php 2010-09-13 12:42:39 UTC 
(rev 30894)
@@ -10,7 +10,7 @@
 
 require_once(dirname(__FILE__).'/../../bootstrap/unit.php');
 
-$t = new lime_test(57);
+$t = new lime_test(65);
 
 class myRequest extends sfWebRequest
 {
@@ -108,6 +108,31 @@
 $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');
+unset($_SERVER['HTTPS']);
+
+$_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');
+$_SERVER['HTTP_SSL_HTTPS'] = '1';
+$t->is($request->isSecure(), true, '->isSecure() checks the "HTTP_SSL_HTTPS" 
environment variable');
+unset($_SERVER['HTTP_SSL_HTTPS']);
+
+$_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
+$t->is($request->isSecure(), true, '->isSecure() checks the 
"HTTP_X_FORWARDED_PROTO" environment variable');
+unset($_SERVER['HTTP_X_FORWARDED_PROTO']);
+
 // ->getUriPrefix()
 $t->diag('->getUriPrefix()');
 $_SERVER['SERVER_PORT'] = '80';

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to