Lines 1627-1633
subtest 'BorrowersLog tests' => sub {
Link Here
|
1627 |
$schema->storage->txn_rollback; |
1627 |
$schema->storage->txn_rollback; |
1628 |
|
1628 |
|
1629 |
subtest 'Test Koha::Patrons::merge' => sub { |
1629 |
subtest 'Test Koha::Patrons::merge' => sub { |
1630 |
plan tests => 110; |
1630 |
plan tests => 113; |
1631 |
|
1631 |
|
1632 |
my $schema = Koha::Database->new()->schema(); |
1632 |
my $schema = Koha::Database->new()->schema(); |
1633 |
|
1633 |
|
Lines 1639-1644
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1639 |
my $loser_1 = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1639 |
my $loser_1 = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1640 |
my $loser_2 = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1640 |
my $loser_2 = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1641 |
|
1641 |
|
|
|
1642 |
my $keeper_protected = $builder->build_object({ class => 'Koha::Patrons' }); |
1643 |
$keeper_protected->protected( 1 )->store; |
1644 |
|
1645 |
my $loser_protected_obj = $builder->build_object({ class => 'Koha::Patrons' }); |
1646 |
$loser_protected_obj->protected( 1 )->store; |
1647 |
my $loser_protected = $loser_protected_obj->borrowernumber; |
1648 |
|
1642 |
my $anonymous_patron_orig = C4::Context->preference('AnonymousPatron'); |
1649 |
my $anonymous_patron_orig = C4::Context->preference('AnonymousPatron'); |
1643 |
my $anonymous_patron = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1650 |
my $anonymous_patron = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1644 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron ); |
1651 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron ); |
Lines 1661-1667
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1661 |
is( $loser_2_rs->count(), 1, "Found 1 $r rows for loser_2" ); |
1668 |
is( $loser_2_rs->count(), 1, "Found 1 $r rows for loser_2" ); |
1662 |
} |
1669 |
} |
1663 |
|
1670 |
|
1664 |
my $results = $keeper->merge_with([ $loser_1, $loser_2 ]); |
1671 |
my $results_protected = $keeper_protected->merge_with( [ $loser_1 ] ); |
|
|
1672 |
is( $results_protected, undef, "Protected patrons cannot have other patrons merged into them" ); |
1673 |
is( Koha::Patrons->search( { borrowernumber => $loser_1 } )->count, 1, "Patron from attempted merge with protected patron still exists" ); |
1674 |
|
1675 |
my $results = $keeper->merge_with([ $loser_1, $loser_2, $loser_protected ]); |
1665 |
|
1676 |
|
1666 |
while (my ($r, $field) = each(%$resultsets)) { |
1677 |
while (my ($r, $field) = each(%$resultsets)) { |
1667 |
my $keeper_rs = |
1678 |
my $keeper_rs = |
Lines 1672-1677
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1672 |
is( Koha::Patrons->find($loser_1), undef, 'Loser 1 has been deleted' ); |
1683 |
is( Koha::Patrons->find($loser_1), undef, 'Loser 1 has been deleted' ); |
1673 |
is( Koha::Patrons->find($loser_2), undef, 'Loser 2 has been deleted' ); |
1684 |
is( Koha::Patrons->find($loser_2), undef, 'Loser 2 has been deleted' ); |
1674 |
is( ref Koha::Patrons->find($anonymous_patron), 'Koha::Patron', 'Anonymous Patron was not deleted' ); |
1685 |
is( ref Koha::Patrons->find($anonymous_patron), 'Koha::Patron', 'Anonymous Patron was not deleted' ); |
|
|
1686 |
is( ref Koha::Patrons->find($loser_protected), 'Koha::Patron', 'Protected patron was not deleted' ); |
1675 |
|
1687 |
|
1676 |
$anonymous_patron = Koha::Patrons->find($anonymous_patron); |
1688 |
$anonymous_patron = Koha::Patrons->find($anonymous_patron); |
1677 |
$results = $anonymous_patron->merge_with( [ $keeper->id ] ); |
1689 |
$results = $anonymous_patron->merge_with( [ $keeper->id ] ); |