Finance-Bank-IE
view release on metacpan or search on metacpan
SKIP:
{
skip "these tests don't work against the live site", 3 if $live;
# some failure scenarios
Finance::Bank::IE::PTSB->reset and
Test::MockBank->globalstate( 'loggedin', 0 );
# if we get a page failure, it should trip up the code but not
# cause it to crash
Test::MockBank->fail_on_iterations( 1 );
@accounts = Finance::Bank::IE::PTSB->check_balance( $config );
ok( !@accounts, "can handle page-load failure (check_balance)" );
Finance::Bank::IE::PTSB->reset and
Test::MockBank->globalstate( 'loggedin', 0 );
Test::MockBank->fail_on_iterations( 1 );
( @details ) = Finance::Bank::IE::PTSB->account_details( $testaccount, $config );
ok( !@details, "can handle page-load failure (account_detail)" );
# this checks the _third_party code as well
Finance::Bank::IE::PTSB->reset and
Test::MockBank->globalstate( 'loggedin', 0 );
Test::MockBank->fail_on_iterations( 5 );
$beneficiaries = Finance::Bank::IE::PTSB->list_beneficiaries( $testaccount,
$config );
ok( !$beneficiaries, "can handle page-load failure (list_beneficiaries 1)")
or diag Dumper($beneficiaries);
Finance::Bank::IE::PTSB->reset and
Test::MockBank->globalstate( 'loggedin', 0 );
Test::MockBank->fail_on_iterations( 6 );
$beneficiaries = Finance::Bank::IE::PTSB->list_beneficiaries( $testaccount,
$config );
ok( !$beneficiaries, "can handle page-load failure (list_beneficiaries 2)");
Finance::Bank::IE::PTSB->reset and
Test::MockBank->globalstate( 'loggedin', 0 );
Test::MockBank->fail_on_iterations( 5 );
$beneficiary_add = Finance::Bank::IE::PTSB->add_beneficiary( $testaccount, @new_beneficiary, $config );
ok( !$beneficiary_add, "can handle page-load failure (add_beneficiary)");
Finance::Bank::IE::PTSB->reset and
Test::MockBank->globalstate( 'loggedin', 0 );
Test::MockBank->fail_on_iterations( 7 );
$beneficiary_add = Finance::Bank::IE::PTSB->add_beneficiary( $testaccount, @new_beneficiary, $config );
ok( !$beneficiary_add, "can handle page-load failure (add_beneficiary 2)");
Finance::Bank::IE::PTSB->reset and
Test::MockBank->globalstate( 'loggedin', 0 );
Test::MockBank->fail_on_iterations( 8 );
$beneficiary_add = Finance::Bank::IE::PTSB->add_beneficiary( $testaccount, @new_beneficiary, $config );
ok( !$beneficiary_add, "can handle page-load failure (add_beneficiary 2)");
Finance::Bank::IE::PTSB->reset and
Test::MockBank->globalstate( 'loggedin', 0 );
Test::MockBank->fail_on_iterations( 9 );
$beneficiary_add = Finance::Bank::IE::PTSB->add_beneficiary( $testaccount, @new_beneficiary, $config );
ok( !$beneficiary_add, "can handle page-load failure (add_beneficiary 2)");
# looping login page
Test::MockBank->fail_on_iterations( 0 );
Test::MockBank->globalstate( 'loggedin', 0 );
Test::MockBank->globalstate( 'loop', 1 );
@accounts = Finance::Bank::IE::PTSB->check_balance( $config );
ok( !@accounts, "can handle looping login page" );
Test::MockBank->globalstate( 'loop', 0 );
}
# utterly bogus URL (mainly for coverage)
Test::MockBank->globalstate( 'loggedin', 0 );
t/lib/Test/MockBank.pm view on Meta::CPAN
if ( defined( $value )) {
$GLOBALSTATE{$key} = $value;
# what I should be doing, except I'm using this as a set/get function :(
# } else {
# delete $GLOBALSTATE{$key};
}
$GLOBALSTATE{$key};
}
sub fail_on_iterations {
my $self = shift;
my $iterations = [ @_ ];
$self->globalstate( 'fail', [ $iterations, 0 ] );
}
sub on_page {
my $self = shift;
my $uri = shift;
my $usepage = shift;
if ( !$uri ) {
# argh
delete $GLOBALSTATE{on_page};
t/lib/Test/MockBank.pm view on Meta::CPAN
my $response = new HTTP::Response();
$response->request( $request );
if ( $fail ) {
$iteration++;
Test::MockBank->globalstate( 'fail', [ $failures, $iteration ]);
if ( grep {m/^$iteration$/} @{$failures} ) {
diag( "failing per request on iteration $iteration when " . $request->method . "ing " . $request->uri) if $ENV{DEBUG};
my @iterations = grep {!m/^$iteration$/} @{$failures};
if ( !@iterations ) {
Test::MockBank->globalstate( 'fail', 0 );
} else {
Test::MockBank->globalstate( 'fail', [ \@iterations, $iteration ] );
}
$response->code( RC_INTERNAL_SERVER_ERROR );
$response->content( 'FAIL' );
diag( "returning " . $response->code) if $ENV{DEBUG};
return $response;
} else {
}
}
if ( my $substitute = Test::MockBank->globalstate( 'on_page' )) {
( run in 1.596 second using v1.01-cache-2.11-cpan-71847e10f99 )