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

(-)a/Koha/Patrons.pm (-1 / +1 lines)
Lines 167-173 sub search_patrons_to_anonymise { Link Here
167
      : undef;
167
      : undef;
168
168
169
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
169
    my $dtf = Koha::Database->new->schema->storage->datetime_parser;
170
    my $rs = $class->search(
170
    my $rs = $class->_resultset->search(
171
        {   returndate                  => { '<'   =>  $dtf->format_datetime($older_than_date), },
171
        {   returndate                  => { '<'   =>  $dtf->format_datetime($older_than_date), },
172
            'old_issues.borrowernumber' => { 'not' => undef },
172
            'old_issues.borrowernumber' => { 'not' => undef },
173
            privacy                     => { '<>'  => 0 },                  # Keep forever
173
            privacy                     => { '<>'  => 0 },                  # Keep forever
(-)a/t/db_dependent/Koha/Patrons.t (-2 / +5 lines)
Lines 618-624 subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { Link Here
618
    t::lib::Mocks::mock_preference( 'AnonymousPatron', '' );
618
    t::lib::Mocks::mock_preference( 'AnonymousPatron', '' );
619
619
620
    subtest 'AnonymousPatron is not defined' => sub {
620
    subtest 'AnonymousPatron is not defined' => sub {
621
        plan tests => 3;
621
        plan tests => 4;
622
622
623
        t::lib::Mocks::mock_preference('IndependentBranches', 0);
623
        t::lib::Mocks::mock_preference('IndependentBranches', 0);
624
        my $patron = $builder->build(
624
        my $patron = $builder->build(
Lines 645-650 subtest 'search_patrons_to_anonymise & anonymise_issue_history' => sub { Link Here
645
645
646
        my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
646
        my ( $returned, undef, undef ) = C4::Circulation::AddReturn( $item->{barcode}, undef, undef, undef, '2010-10-10' );
647
        is( $returned, 1, 'The item should have been returned' );
647
        is( $returned, 1, 'The item should have been returned' );
648
649
        my $patron_to_anonymise = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11' )->search( { 'me.borrowernumber' => $patron->{borrowernumber} } )->next;
650
        is( ref($patron_to_anonymise), 'Koha::Patron', 'search_patrons_to_anonymise should return Koha::Patrons' );
651
648
        my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11');
652
        my $rows_affected = Koha::Patrons->search_patrons_to_anonymise( '2010-10-11')->anonymise_issue_history('2010-10-11');
649
        ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' );
653
        ok( $rows_affected > 0, 'AnonymiseIssueHistory should affect at least 1 row' );
650
654
651
- 

Return to bug 16966