Lines 1614-1620
subtest 'BorrowersLog tests' => sub {
Link Here
|
1614 |
$schema->storage->txn_rollback; |
1614 |
$schema->storage->txn_rollback; |
1615 |
|
1615 |
|
1616 |
subtest 'Test Koha::Patrons::merge' => sub { |
1616 |
subtest 'Test Koha::Patrons::merge' => sub { |
1617 |
plan tests => 110; |
1617 |
plan tests => 113; |
1618 |
|
1618 |
|
1619 |
my $schema = Koha::Database->new()->schema(); |
1619 |
my $schema = Koha::Database->new()->schema(); |
1620 |
|
1620 |
|
Lines 1626-1631
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1626 |
my $loser_1 = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1626 |
my $loser_1 = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1627 |
my $loser_2 = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1627 |
my $loser_2 = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1628 |
|
1628 |
|
|
|
1629 |
my $keeper_protected = $builder->build_object({ class => 'Koha::Patrons' }); |
1630 |
$keeper_protected->protected( 1 )->store; |
1631 |
|
1632 |
my $loser_protected_obj = $builder->build_object({ class => 'Koha::Patrons' }); |
1633 |
$loser_protected_obj->protected( 1 )->store; |
1634 |
my $loser_protected = $loser_protected_obj->borrowernumber; |
1635 |
|
1629 |
my $anonymous_patron_orig = C4::Context->preference('AnonymousPatron'); |
1636 |
my $anonymous_patron_orig = C4::Context->preference('AnonymousPatron'); |
1630 |
my $anonymous_patron = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1637 |
my $anonymous_patron = $builder->build({ source => 'Borrower' })->{borrowernumber}; |
1631 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron ); |
1638 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', $anonymous_patron ); |
Lines 1648-1654
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1648 |
is( $loser_2_rs->count(), 1, "Found 1 $r rows for loser_2" ); |
1655 |
is( $loser_2_rs->count(), 1, "Found 1 $r rows for loser_2" ); |
1649 |
} |
1656 |
} |
1650 |
|
1657 |
|
1651 |
my $results = $keeper->merge_with([ $loser_1, $loser_2 ]); |
1658 |
my $results_protected = $keeper_protected->merge_with( [ $loser_1 ] ); |
|
|
1659 |
is( $results_protected, undef, "Protected patrons cannot have other patrons merged into them" ); |
1660 |
is( Koha::Patrons->search( { borrowernumber => $loser_1 } )->count, 1, "Patron from attempted merge with protected patron still exists" ); |
1661 |
|
1662 |
my $results = $keeper->merge_with([ $loser_1, $loser_2, $loser_protected ]); |
1652 |
|
1663 |
|
1653 |
while (my ($r, $field) = each(%$resultsets)) { |
1664 |
while (my ($r, $field) = each(%$resultsets)) { |
1654 |
my $keeper_rs = |
1665 |
my $keeper_rs = |
Lines 1659-1664
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1659 |
is( Koha::Patrons->find($loser_1), undef, 'Loser 1 has been deleted' ); |
1670 |
is( Koha::Patrons->find($loser_1), undef, 'Loser 1 has been deleted' ); |
1660 |
is( Koha::Patrons->find($loser_2), undef, 'Loser 2 has been deleted' ); |
1671 |
is( Koha::Patrons->find($loser_2), undef, 'Loser 2 has been deleted' ); |
1661 |
is( ref Koha::Patrons->find($anonymous_patron), 'Koha::Patron', 'Anonymous Patron was not deleted' ); |
1672 |
is( ref Koha::Patrons->find($anonymous_patron), 'Koha::Patron', 'Anonymous Patron was not deleted' ); |
|
|
1673 |
is( ref Koha::Patrons->find($loser_protected), 'Koha::Patron', 'Protected patron was not deleted' ); |
1662 |
|
1674 |
|
1663 |
$anonymous_patron = Koha::Patrons->find($anonymous_patron); |
1675 |
$anonymous_patron = Koha::Patrons->find($anonymous_patron); |
1664 |
$results = $anonymous_patron->merge_with( [ $keeper->id ] ); |
1676 |
$results = $anonymous_patron->merge_with( [ $keeper->id ] ); |