diff --git a/lib/WebGUI/Shop/Vendor.pm b/lib/WebGUI/Shop/Vendor.pm index 9df6c2412..d5940e959 100644 --- a/lib/WebGUI/Shop/Vendor.pm +++ b/lib/WebGUI/Shop/Vendor.pm @@ -194,6 +194,26 @@ sub getVendors { #------------------------------------------------------------------- +=head2 isVendorInfoComplete ( ) + +Returns a boolean indicating whether the payoutinformation entered by the vendor is complete. + +=cut + +sub isVendorInfoComplete { + my $self = shift; + + my $complete = + defined $self->get( 'name' ) + && defined $self->get( 'userId' ) + && defined $self->get( 'preferredPaymentType' ) + && defined $self->get( 'paymentInformation' ); + + return $complete +} + +#------------------------------------------------------------------- + =head2 new ( session, vendorId ) Constructor. Returns a WebGUI::Shop::Vendor object. diff --git a/t/Shop/Vendor.t b/t/Shop/Vendor.t index bd778dfe3..f00533eab 100644 --- a/t/Shop/Vendor.t +++ b/t/Shop/Vendor.t @@ -31,7 +31,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 44; +my $tests = 49; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -283,6 +283,27 @@ cmp_deeply( 'delete removed the correct vendor' ); +####################################################################### +# +# isVendorInfoComplete +# +####################################################################### + +my %completeProps = ( + name => 'Esquerita', + userId => $fenceUser->userId, + preferredPaymentType => 'PayPal', + paymentInformation => 'esquerita@example.com', +); +$fence->update( { %completeProps } ); +is( $fence->isVendorInfoComplete, 1, 'Vendor information is complete' ); + +foreach (keys %completeProps ) { + $fence->update( { %completeProps, $_ => undef } ); + ok( !$fence->isVendorInfoComplete, "Vendor information is not complete without $_" ); +} + + undef $guard; }