Lines 49-79
subtest 'enqueue' => sub {
Link Here
|
49 |
}; |
49 |
}; |
50 |
|
50 |
|
51 |
subtest 'process' => sub { |
51 |
subtest 'process' => sub { |
52 |
plan tests => 1; |
52 |
plan tests => 2; |
53 |
|
|
|
54 |
$schema->storage->txn_begin; |
55 |
|
53 |
|
56 |
my $biblio = $builder->build_sample_biblio; |
54 |
subtest 'package_do_not_exist' => sub { |
57 |
|
55 |
plan tests => 2; |
58 |
my $package = |
56 |
|
59 |
Koha::ERM::EHoldings::Package->new( { name => 'a package' } )->store; |
57 |
$schema->storage->txn_begin; |
60 |
|
58 |
|
61 |
my $job = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new( |
59 |
my $biblio = $builder->build_sample_biblio; |
62 |
{ |
60 |
my $package = |
63 |
status => 'new', |
61 |
Koha::ERM::EHoldings::Package->new( { name => 'a package' } )->store; |
64 |
type => 'create_eholdings_from_biblios', |
62 |
|
65 |
size => 1, |
63 |
my $job = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new( |
66 |
} |
64 |
{ |
67 |
)->store; |
65 |
status => 'new', |
68 |
$job = Koha::BackgroundJobs->find( $job->id ); |
66 |
type => 'create_eholdings_from_biblios', |
69 |
my $data = { |
67 |
size => 1, |
70 |
record_ids => [ $biblio->biblionumber ], |
68 |
} |
71 |
package_id => $package->package_id, |
69 |
)->store; |
|
|
70 |
$job = Koha::BackgroundJobs->find( $job->id ); |
71 |
my $data = { |
72 |
record_ids => [ $biblio->biblionumber ], |
73 |
package_id => $package->package_id, |
74 |
}; |
75 |
my $json = $job->json->encode($data); |
76 |
$job->data($json)->store; |
77 |
$package->delete; # Delete the package |
78 |
$job->process($data); |
79 |
is( $job->report->{total_success}, 0 ); |
80 |
is_deeply( |
81 |
$job->messages, |
82 |
[ |
83 |
{ |
84 |
code => "package_do_not_exist", |
85 |
package_id => $package->package_id, |
86 |
type => "error" |
87 |
} |
88 |
] |
89 |
); |
72 |
}; |
90 |
}; |
73 |
my $json = $job->json->encode($data); |
|
|
74 |
$job->data($json)->store; |
75 |
$job->process($data); |
76 |
is( $job->report->{total_success}, 1 ); |
77 |
|
91 |
|
78 |
$schema->storage->txn_rollback; |
92 |
subtest 'all good' => sub { |
|
|
93 |
plan tests => 1; |
94 |
|
95 |
$schema->storage->txn_begin; |
96 |
|
97 |
my $biblio = $builder->build_sample_biblio; |
98 |
my $package = |
99 |
Koha::ERM::EHoldings::Package->new( { name => 'a package' } )->store; |
100 |
|
101 |
my $job = Koha::BackgroundJob::CreateEHoldingsFromBiblios->new( |
102 |
{ |
103 |
status => 'new', |
104 |
type => 'create_eholdings_from_biblios', |
105 |
size => 1, |
106 |
} |
107 |
)->store; |
108 |
$job = Koha::BackgroundJobs->find( $job->id ); |
109 |
my $data = { |
110 |
record_ids => [ $biblio->biblionumber ], |
111 |
package_id => $package->package_id, |
112 |
}; |
113 |
my $json = $job->json->encode($data); |
114 |
$job->data($json)->store; |
115 |
$job->process($data); |
116 |
is( $job->report->{total_success}, 1 ); |
117 |
|
118 |
$schema->storage->txn_rollback; |
119 |
}; |
79 |
}; |
120 |
}; |
80 |
- |
|
|