1 package FS::part_export::test;
4 use vars qw(%options %info);
6 use base qw(FS::part_export);
8 tie %options, 'Tie::IxHash',
9 'result' => { label => 'Result',
11 options => [ 'success', 'failure', 'exception' ],
14 'errormsg'=> { label => 'Error message',
15 default => 'Test export' },
16 'insert' => { label => 'Insert', type => 'checkbox', default => 1, },
17 'delete' => { label => 'Delete', type => 'checkbox', default => 1, },
18 'replace' => { label => 'Replace',type => 'checkbox', default => 1, },
19 'suspend' => { label => 'Suspend',type => 'checkbox', default => 1, },
20 'unsuspend'=>{ label => 'Unsuspend', type => 'checkbox', default => 1, },
24 'svc' => [ qw(svc_acct svc_broadband svc_phone svc_domain) ],
25 'desc' => 'Test export for development',
26 'options' => \%options,
28 <P>Test export. Do not use this in production systems.</P>
29 <P>This export either always succeeds, always fails (returning an error),
30 or always dies, according to the "Result" option. It does nothing else; the
31 purpose is purely to simulate success or failure within an export module.</P>
32 <P>The checkbox options can be used to turn the export off for certain
33 actions, if this is needed.</P>
39 $self->run(@_) if $self->option('insert');
44 $self->run(@_) if $self->option('delete');
49 $self->run(@_) if $self->option('replace');
54 $self->run(@_) if $self->option('suspend');
57 sub export_unsuspend {
59 $self->run(@_) if $self->option('unsuspend');
65 my $result = $self->option('result');
66 if ( $result eq 'failure' ) {
67 return $self->option('errormsg');
68 } elsif ( $result eq 'exception' ) {
69 die $self->option('errormsg');