View | Details | Raw Unified | Return to bug 13518
Collapse All | Expand All

(-)a/Koha/Patron.pm (+5 lines)
Lines 42-47 use Koha::Patron::Categories; Link Here
42
use Koha::Patron::HouseboundProfile;
42
use Koha::Patron::HouseboundProfile;
43
use Koha::Patron::HouseboundRole;
43
use Koha::Patron::HouseboundRole;
44
use Koha::Patron::Images;
44
use Koha::Patron::Images;
45
use Koha::Patron::Modifications;
45
use Koha::Patron::Relationships;
46
use Koha::Patron::Relationships;
46
use Koha::Patrons;
47
use Koha::Patrons;
47
use Koha::Plugins;
48
use Koha::Plugins;
Lines 383-388 sub delete { Link Here
383
            # FIXME Could be $patron->get_lists
384
            # FIXME Could be $patron->get_lists
384
            $_->delete for Koha::Virtualshelves->search( { owner => $self->borrowernumber } );
385
            $_->delete for Koha::Virtualshelves->search( { owner => $self->borrowernumber } );
385
386
387
            # We cannot have a FK on borrower_modifications.borrowernumber, the table is also used
388
            # for patron selfreg
389
            $_->delete for Koha::Patron::Modifications->search( { borrowernumber => $self->borrowernumber } );
390
386
            $self->SUPER::delete;
391
            $self->SUPER::delete;
387
392
388
            logaction( "MEMBERS", "DELETE", $self->borrowernumber, "" ) if C4::Context->preference("BorrowersLog");
393
            logaction( "MEMBERS", "DELETE", $self->borrowernumber, "" ) if C4::Context->preference("BorrowersLog");
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +4 lines)
Lines 466-472 subtest "move_to_deleted" => sub { Link Here
466
};
466
};
467
467
468
subtest "delete" => sub {
468
subtest "delete" => sub {
469
    plan tests => 6;
469
    plan tests => 7;
470
    t::lib::Mocks::mock_preference( 'BorrowersLog', 1 );
470
    t::lib::Mocks::mock_preference( 'BorrowersLog', 1 );
471
    my $patron           = $builder->build( { source => 'Borrower' } );
471
    my $patron           = $builder->build( { source => 'Borrower' } );
472
    my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} );
472
    my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} );
Lines 480-485 subtest "delete" => sub { Link Here
480
            value  => { owner => $patron->{borrowernumber} }
480
            value  => { owner => $patron->{borrowernumber} }
481
        }
481
        }
482
    );
482
    );
483
    my $modification = $builder->build_object({ class => 'Koha::Patron::Modifications', value => { borrowernumber => $patron->{borrowernumber} } });
483
484
484
    my $deleted = $retrieved_patron->delete;
485
    my $deleted = $retrieved_patron->delete;
485
    is( ref($deleted), 'Koha::Patron', 'Koha::Patron->delete should return the deleted patron object if the patron has been correctly deleted' );
486
    is( ref($deleted), 'Koha::Patron', 'Koha::Patron->delete should return the deleted patron object if the patron has been correctly deleted' );
Lines 492-497 subtest "delete" => sub { Link Here
492
493
493
    is( Koha::Virtualshelves->search( { owner => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's lists| );
494
    is( Koha::Virtualshelves->search( { owner => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's lists| );
494
495
496
    is( Koha::Patron::Modifications->search( { borrowernumber => $patron->{borrowernumber} } )->count, 0, q|Koha::Patron->delete should have deleted patron's modifications| );
497
495
    my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $retrieved_patron->borrowernumber } )->count;
498
    my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'DELETE', object => $retrieved_patron->borrowernumber } )->count;
496
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' );
499
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->delete should have logged' );
497
};
500
};
498
- 

Return to bug 13518