[LON-CAPA-cvs] cvs: modules /jerf/tests ApacheRequestTest.pm

bowersj2 lon-capa-cvs@mail.lon-capa.org
Thu, 29 May 2003 20:21:56 -0000


bowersj2		Thu May 29 16:21:56 2003 EDT

  Modified files:              
    /modules/jerf/tests	ApacheRequestTest.pm 
  Log:
  Update test to reflect ApacheRequest.pm.
  
  
  
Index: modules/jerf/tests/ApacheRequestTest.pm
diff -u modules/jerf/tests/ApacheRequestTest.pm:1.2 modules/jerf/tests/ApacheRequestTest.pm:1.3
--- modules/jerf/tests/ApacheRequestTest.pm:1.2	Fri May 23 14:10:45 2003
+++ modules/jerf/tests/ApacheRequestTest.pm	Thu May 29 16:21:56 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
-# Navigate Maps Handler
+# Apache Request Simulator Tester
 #
-# $Id: ApacheRequestTest.pm,v 1.2 2003/05/23 18:10:45 bowersj2 Exp $
+# $Id: ApacheRequestTest.pm,v 1.3 2003/05/29 20:21:56 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -126,6 +126,7 @@
     my $params = { querystring => $querystring }; 
     my $r = ApacheRequest->new($params);
     $self->assert($r->args() eq 'a=b&c=d');
+    $self->assert($ENV{QUERY_STRING} eq 'a=b&c=d');
 }
 
 sub test_argument_hash_handling {
@@ -134,6 +135,8 @@
     my $params = { querystring => $querystring };
     my $r = ApacheRequest->new($params);
     $self->assert($r->args() eq 'a=b&c=d' || $r->args() eq 'c=d&a=b');
+    $self->assert($ENV{QUERY_STRING} eq 'a=b&c=d' || 
+                  $ENV{QUERY_STRING} eq 'c=d&a=b');
 
     # Check that arguments are escaped correctly
     $r = ApacheRequest->new({querystring => { 'a&.' => ":,,"}});
@@ -192,6 +195,44 @@
     $self->assert($printed->[1] eq 'This is a simple test print.');
     $self->assert(scalar(@$printed) == 2);
 }
+
+# lonhelp.pm, the first handler getting tested, needs dir_config so
+# I wrote it and will test it here
+sub test_dir_config {
+    my $self = shift;
+    my $r = ApacheRequest->new();
+
+    my $result = $r->dir_config('lonDocRoot');
+
+    # Technically, while we're pretty sure this will be /home/httpd/html,
+    # we don't *know* that so we shouldn't test for it. However, we *do*
+    # know it must be set to *something*, or the system itself will stop
+    # working, so we can test for that, which will also test that dir_config
+    # is at least doing *something*.
+
+    $self->assert(defined($result));
+    $self->assert($result ne '');
+}
+
+sub test_environment_is_correct {
+    my $self = shift;
+    my $r = ApacheRequest->new();
+
+    $self->assert(defined($ENV{'QUERY_STRING'}));
+    # A popular ENV variable from the shell, but not in the server
+    $self->assert(!defined($ENV{'USER'}));
+}
+
+sub test_document_root_correct {
+    # this may seem silly, but if somebody ever changes how the DOCUMENT_ROOT
+    # is set, the failing of this test will emphasize that there was stuff
+    # that depended on it. The existance of this test validates the deliberateness
+    # of the setting.
+    my $self = shift;
+    my $r = ApacheRequest->new();
+    $self->assert($ENV{'DOCUMENT_ROOT'} eq $Apache::lonnet::perlvar{'lonDocRoot'});
+}
+
 1;
 
 package SimpleTestHandler;