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

(-)a/Koha/Objects.pm (-2 / +2 lines)
Lines 233-246 The autoload method is used call DBIx::Class method on a resultset. Link Here
233
233
234
Important: If you plan to use one of the DBIx::Class methods you must provide
234
Important: If you plan to use one of the DBIx::Class methods you must provide
235
relevant tests in t/db_dependent/Koha/Objects.t
235
relevant tests in t/db_dependent/Koha/Objects.t
236
Currently count, pager, reset and update are covered.
236
Currently count, pager, reset, update and delete are covered.
237
237
238
=cut
238
=cut
239
239
240
sub AUTOLOAD {
240
sub AUTOLOAD {
241
    my ( $self, @params ) = @_;
241
    my ( $self, @params ) = @_;
242
242
243
    my @known_methods = qw( count pager reset update );
243
    my @known_methods = qw( count pager reset update delete );
244
    my $method = our $AUTOLOAD;
244
    my $method = our $AUTOLOAD;
245
    $method =~ s/.*:://;
245
    $method =~ s/.*:://;
246
246
(-)a/t/db_dependent/Koha/Objects.t (-2 / +10 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 6;
22
use Test::More tests => 7;
23
use Test::Warn;
23
use Test::Warn;
24
24
25
use Koha::Authority::Types;
25
use Koha::Authority::Types;
Lines 67-72 subtest 'reset' => sub { Link Here
67
    is( $patrons->reset->next->borrowernumber, $first_borrowernumber, 'Koha::Objects->reset should work as expected');
67
    is( $patrons->reset->next->borrowernumber, $first_borrowernumber, 'Koha::Objects->reset should work as expected');
68
};
68
};
69
69
70
subtest 'delete' => sub {
71
    plan tests => 2;
72
    my $builder   = t::lib::TestBuilder->new;
73
    my $patron_1 = $builder->build({source => 'Borrower'});
74
    my $patron_2 = $builder->build({source => 'Borrower'});
75
    is( Koha::Patrons->search({ -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber}]}})->delete, 2, '');
76
    is( Koha::Patrons->search({ -or => { borrowernumber => [ $patron_1->{borrowernumber}, $patron_2->{borrowernumber}]}})->count, 0, '');
77
};
78
70
subtest 'not_covered_yet' => sub {
79
subtest 'not_covered_yet' => sub {
71
    plan tests => 1;
80
    plan tests => 1;
72
    warning_is { Koha::Patrons->search->not_covered_yet } { carped => 'The method not_covered_yet is not covered by tests' }, "If a method is not covered by tests, the AUTOLOAD method won't execute the method";
81
    warning_is { Koha::Patrons->search->not_covered_yet } { carped => 'The method not_covered_yet is not covered by tests' }, "If a method is not covered by tests, the AUTOLOAD method won't execute the method";
73
- 

Return to bug 17091