Added Test::MockObject tests to Session/Url to bypass request requirements.
Added stub for Paginator.t
This commit is contained in:
parent
18060d8e4e
commit
e1b42d2970
2 changed files with 56 additions and 7 deletions
23
t/Paginator.t
Normal file
23
t/Paginator.t
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2006 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Utility;
|
||||
|
||||
use WebGUI::Paginator;
|
||||
use Test::More tests => 1; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -15,7 +15,8 @@ use lib "$FindBin::Bin/../lib";
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
|
||||
use Test::More tests => 15; # increment this value for each test you create
|
||||
use Test::More tests => 19; # increment this value for each test you create
|
||||
use Test::MockObject;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -37,9 +38,9 @@ is( $url2, $url.'?a=b;c=d', 'append second pair');
|
|||
|
||||
diag("gateway tests");
|
||||
|
||||
$session->config->{_config}->set(gateway => 'home.com');
|
||||
$session->config->{_config}->set(gateway => '/');
|
||||
|
||||
is ( $session->config->get('gateway'), 'home.com', 'Set gateway for downstream tests');
|
||||
is ( $session->config->get('gateway'), '/', 'Set gateway for downstream tests');
|
||||
|
||||
$url = $session->config->get('gateway') . '/';
|
||||
$url2 = $session->url->gateway;
|
||||
|
|
@ -92,8 +93,33 @@ $url2 = 'level1-/level2/level3';
|
|||
|
||||
is ( $session->url->makeCompliant($url), $url2, 'language specific URL compliance');
|
||||
|
||||
SKIP: {
|
||||
skip("getRequestedUrl requires a valid Apache request object",1);
|
||||
ok(undef,"getRequestedUrl");
|
||||
}
|
||||
diag("getRequestedUrl tests");
|
||||
|
||||
my $originalRequest = $session->request; ##Save the original request
|
||||
|
||||
my $newRequest = Test::MockObject->new;
|
||||
my $requestedUrl = 'empty';
|
||||
$newRequest->set_bound('uri', \$requestedUrl);
|
||||
$session->{_request} = $newRequest;
|
||||
|
||||
##Validate new MockObject
|
||||
|
||||
is ($session->request->uri, 'empty', 'Validate Mock Object operation');
|
||||
|
||||
$requestedUrl = 'full';
|
||||
is ($session->request->uri, 'full', 'Validate Mock Object operation #2');
|
||||
|
||||
$requestedUrl = 'home.com/path1/file1';
|
||||
is ($session->url->getRequestedUrl, '/path1/file1', 'getRequestedUrl, fetch');
|
||||
|
||||
$requestedUrl = 'home.com/path2/file2';
|
||||
is ($session->url->getRequestedUrl, '/path1/file1', 'getRequestedUrl, check cache of previous result');
|
||||
|
||||
diag("page tests");
|
||||
|
||||
is ($session->url->page, 'home.com/path1/file1', 'page with no args returns getRequestedUrl via gateway');
|
||||
|
||||
diag("config sitename: ".$session->config->get('sitename')->[0]);
|
||||
diag("gateway: ".$session->url->gateway);
|
||||
|
||||
is ($session->url->page('',1), 'http://home.com/path1/file1', 'page, withFullUrl');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue