Lines 34-42
subtest 'transfer_ownership() tests' => sub {
Link Here
|
34 |
|
34 |
|
35 |
$schema->storage->txn_begin; |
35 |
$schema->storage->txn_begin; |
36 |
|
36 |
|
37 |
my $patron_1 = $builder->build_object({ class => 'Koha::Patrons' }); |
37 |
my $patron_1 = $builder->build_object( { class => 'Koha::Patrons' } ); |
38 |
my $patron_2 = $builder->build_object({ class => 'Koha::Patrons' }); |
38 |
my $patron_2 = $builder->build_object( { class => 'Koha::Patrons' } ); |
39 |
my $patron_3 = $builder->build_object({ class => 'Koha::Patrons' }); |
39 |
my $patron_3 = $builder->build_object( { class => 'Koha::Patrons' } ); |
40 |
|
40 |
|
41 |
my $public_list = $builder->build_object( |
41 |
my $public_list = $builder->build_object( |
42 |
{ |
42 |
{ |
Lines 52-60
subtest 'transfer_ownership() tests' => sub {
Link Here
|
52 |
} |
52 |
} |
53 |
); |
53 |
); |
54 |
|
54 |
|
55 |
throws_ok |
55 |
throws_ok { $public_list->transfer_ownership } |
56 |
{ $public_list->transfer_ownership } |
56 |
'Koha::Exceptions::MissingParameter', |
57 |
'Koha::Exceptions::MissingParameter', |
|
|
58 |
'Exception thrown if missing parameter'; |
57 |
'Exception thrown if missing parameter'; |
59 |
|
58 |
|
60 |
like( "$@", qr/Mandatory parameter 'patron' missing/, 'Exception string as expected' ); |
59 |
like( "$@", qr/Mandatory parameter 'patron' missing/, 'Exception string as expected' ); |
Lines 63-69
subtest 'transfer_ownership() tests' => sub {
Link Here
|
63 |
$builder->build_object( |
62 |
$builder->build_object( |
64 |
{ |
63 |
{ |
65 |
class => 'Koha::Virtualshelfshares', |
64 |
class => 'Koha::Virtualshelfshares', |
66 |
value => { shelfnumber => $public_list->id, invitekey => undef, borrowernumber => $patron_2->id } |
65 |
value => { shelfnumber => $public_list->id, invitekey => undef, borrowernumber => $patron_2->id } |
67 |
} |
66 |
} |
68 |
); |
67 |
); |
69 |
$builder->build_object( |
68 |
$builder->build_object( |
Lines 84-90
subtest 'transfer_ownership() tests' => sub {
Link Here
|
84 |
|
83 |
|
85 |
is( $public_list->owner, $patron_2->id, 'Owner changed correctly' ); |
84 |
is( $public_list->owner, $patron_2->id, 'Owner changed correctly' ); |
86 |
my $public_list_shares = $public_list->get_shares; |
85 |
my $public_list_shares = $public_list->get_shares; |
87 |
is( $public_list_shares->count, 1, 'Count is correct' ); |
86 |
is( $public_list_shares->count, 1, 'Count is correct' ); |
88 |
is( $public_list_shares->next->borrowernumber, $patron_2->id, "Public lists don't get the share removed" ); |
87 |
is( $public_list_shares->next->borrowernumber, $patron_2->id, "Public lists don't get the share removed" ); |
89 |
|
88 |
|
90 |
$private_list->transfer_ownership( $patron_2->id ); |
89 |
$private_list->transfer_ownership( $patron_2->id ); |
Lines 93-99
subtest 'transfer_ownership() tests' => sub {
Link Here
|
93 |
is( $private_list->owner, $patron_2->id ); |
92 |
is( $private_list->owner, $patron_2->id ); |
94 |
my $private_list_shares = $private_list->get_shares; |
93 |
my $private_list_shares = $private_list->get_shares; |
95 |
is( $private_list_shares->count, 1, 'Count is correct' ); |
94 |
is( $private_list_shares->count, 1, 'Count is correct' ); |
96 |
is( $private_list_shares->next->borrowernumber, $patron_3->id, "Private lists get the share for the new owner removed" ); |
95 |
is( |
|
|
96 |
$private_list_shares->next->borrowernumber, $patron_3->id, |
97 |
"Private lists get the share for the new owner removed" |
98 |
); |
97 |
|
99 |
|
98 |
my %params; |
100 |
my %params; |
99 |
my $mocked_letters = Test::MockModule->new('C4::Letters'); |
101 |
my $mocked_letters = Test::MockModule->new('C4::Letters'); |
Lines 114-123
subtest 'transfer_ownership() tests' => sub {
Link Here
|
114 |
$public_list->transfer_ownership( $patron_1->id ); |
116 |
$public_list->transfer_ownership( $patron_1->id ); |
115 |
$public_list->discard_changes; |
117 |
$public_list->discard_changes; |
116 |
|
118 |
|
117 |
is( $params{module}, "lists", "Enqueued letter with module lists correctly" ); |
119 |
is( $params{module}, "lists", "Enqueued letter with module lists correctly" ); |
118 |
is( $params{letter_code}, "TRANSFER_OWNERSHIP", "Enqueued letter with code TRANSFER_OWNERSHIP correctly" ); |
120 |
is( $params{letter_code}, "TRANSFER_OWNERSHIP", "Enqueued letter with code TRANSFER_OWNERSHIP correctly" ); |
119 |
is( $params{objects}->{old_owner}->borrowernumber, $patron_2->borrowernumber, "old_owner passed to enqueue letter correctly" ); |
121 |
is( |
120 |
is( $params{objects}->{new_owner}->borrowernumber, $patron_1->borrowernumber, "new_owner passed to enqueue letter correctly" ); |
122 |
$params{objects}->{old_owner}->borrowernumber, $patron_2->borrowernumber, |
|
|
123 |
"old_owner passed to enqueue letter correctly" |
124 |
); |
125 |
is( |
126 |
$params{objects}->{owner}->borrowernumber, $patron_1->borrowernumber, |
127 |
"owner passed to enqueue letter correctly" |
128 |
); |
121 |
is( $params{objects}->{shelf}->shelfnumber, $public_list->shelfnumber, "shelf passed to enqueue letter correctly" ); |
129 |
is( $params{objects}->{shelf}->shelfnumber, $public_list->shelfnumber, "shelf passed to enqueue letter correctly" ); |
122 |
|
130 |
|
123 |
$schema->storage->txn_rollback; |
131 |
$schema->storage->txn_rollback; |
124 |
- |
|
|