Business-CyberSource
view release on metacpan or search on metacpan
t/shipto-exceptions.t view on Meta::CPAN
# for the most part it is copy-paste from billto-exceptions.t
# but not totally, as some tests are specific to shipping
use strict;
use warnings;
use Test::More;
use Test::Fatal qw(exception dies_ok);
use Module::Runtime 'use_module';
my $shipto_c = use_module('Business::CyberSource::RequestPart::ShipTo');
dies_ok {
$shipto_c->new(
{
first_name => 'Caleb',
last_name => 'Cushing',
street1 => 'somewhere',
city => 'Houston',
state => 'TX',
postal_code => '77064',
}
);
}
'no country in request';
my $exception0 = exception {
$shipto_c->new(
{
first_name => 'Caleb',
last_name => 'Cushing',
street1 => 'somewhere',
city => 'Houston',
state => 'TX',
postal_code => '77064',
country => 'blerg',
}
)
};
like $exception0, qr/Attribute \(country\)/, 'country invalid';
my $exception1 = exception {
$shipto_c->new(
{
first_name => 'Caleb',
last_name => 'Cushing',
street1 => 'somewhere',
city => 'Houston',
state => 'TX',
country => 'US',
}
);
};
isa_ok $exception1, 'Moose::Exception::AttributeIsRequired';
like $exception1, qr/postal_code/, 'us/ca require a postal_code';
like $exception1, qr/US or Canada/, 'us/ca require a postal_code';
my $exception2 = exception {
$shipto_c->new(
{
first_name => 'Caleb',
last_name => 'Cushing',
street1 => 'somewhere',
city => 'Houston',
country => 'US',
postal_code => '77064',
}
( run in 0.729 second using v1.01-cache-2.11-cpan-54e63673c56 )