Testing code moved out of t/Session/Http.t into t/Session/Request.t
This commit is contained in:
parent
1d19269f7e
commit
8cf5ce1950
1 changed files with 51 additions and 0 deletions
51
t/Session/Request.t
Normal file
51
t/Session/Request.t
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# Please read the legal notices (docs/legal.txt) and the license
|
||||||
|
# (docs/license.txt) that came with this distribution before using
|
||||||
|
# this software.
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# http://www.plainblack.com info@plainblack.com
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
use WebGUI::Test;
|
||||||
|
use WebGUI::Session;
|
||||||
|
|
||||||
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
||||||
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
|
my $response = $session->response;
|
||||||
|
|
||||||
|
####################################################
|
||||||
|
#
|
||||||
|
# ifModifiedSince
|
||||||
|
#
|
||||||
|
####################################################
|
||||||
|
##Clear request object to run a new set of requests
|
||||||
|
|
||||||
|
{
|
||||||
|
##A new, clean session
|
||||||
|
my $http_request = HTTP::Request::Common::GET('http://'.$session->config->get('sitename')->[0]);
|
||||||
|
$http_request->header('If-Modified-Since' => '');
|
||||||
|
my $session = WebGUI::Test->newSession('nocleanup', $http_request);
|
||||||
|
my $guard = WebGUI::Test->addToCleanup($session);
|
||||||
|
ok $session->request->ifModifiedSince(0), 'ifModifiedSince: empty header always returns true';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
my $http_request = HTTP::Request::Common::GET('http://'.$session->config->get('sitename')->[0]);
|
||||||
|
$http_request->header('If-Modified-Since' => $session->datetime->epochToHttp(WebGUI::Test->webguiBirthday));
|
||||||
|
my $session = WebGUI::Test->newSession('nocleanup', $http_request);
|
||||||
|
my $guard = WebGUI::Test->cleanupGuard($session);
|
||||||
|
ok $session->request->ifModifiedSince(WebGUI::Test->webguiBirthday + 5), '... epoch check, true';
|
||||||
|
ok !$session->request->ifModifiedSince(WebGUI::Test->webguiBirthday - 5), '... epoch check, false';
|
||||||
|
ok $session->request->ifModifiedSince(WebGUI::Test->webguiBirthday - 5, 3600), '... epoch check, made true by maxCacheTimeout';
|
||||||
|
}
|
||||||
|
|
||||||
|
done_testing;
|
||||||
|
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue