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

(-)a/Koha/Illcomment.pm (-4 / +4 lines)
Lines 1-4 Link Here
1
package Koha::Illcomment;
1
package Koha::ILL::Comment;
2
2
3
# Copyright Magnus Enger Libriotech 2017
3
# Copyright Magnus Enger Libriotech 2017
4
#
4
#
Lines 23-35 use base qw(Koha::Object); Link Here
23
23
24
=head1 NAME
24
=head1 NAME
25
25
26
Koha::Illcomment - Koha Illcomment Object class
26
Koha::ILL::Comment - Koha Illcomment Object class
27
27
28
=head2 Class methods
28
=head2 Class methods
29
29
30
=head3 patron
30
=head3 patron
31
31
32
    my $patron = Koha::Illcomment->patron;
32
    my $patron = Koha::ILL::Comment->patron;
33
33
34
Return the patron object associated with this comment
34
Return the patron object associated with this comment
35
35
Lines 46-52 sub patron { Link Here
46
46
47
=head3 _type
47
=head3 _type
48
48
49
    my $type = Koha::IllComment->_type;
49
    my $type = Koha::ILL::Comment->_type;
50
50
51
Return this object's type
51
Return this object's type
52
52
(-)a/Koha/Illcomments.pm (-6 / +6 lines)
Lines 1-4 Link Here
1
package Koha::Illcomments;
1
package Koha::ILL::Comments;
2
2
3
# Copyright Magnus Enger Libriotech 2017
3
# Copyright Magnus Enger Libriotech 2017
4
#
4
#
Lines 19-36 package Koha::Illcomments; Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
use Koha::Database;
21
use Koha::Database;
22
use Koha::Illcomment;
22
use Koha::ILL::Comment;
23
use base qw(Koha::Objects);
23
use base qw(Koha::Objects);
24
24
25
=head1 NAME
25
=head1 NAME
26
26
27
Koha::Illcomments - Koha Illcomments Object class
27
Koha::ILL::Comments - Koha Illcomments Object class
28
28
29
=head2 Internal methods
29
=head2 Internal methods
30
30
31
=head3 _type
31
=head3 _type
32
32
33
    my $type = Koha::IllComments->_type;
33
    my $type = Koha::ILL::Comments->_type;
34
34
35
Return this object's type
35
Return this object's type
36
36
Lines 42-55 sub _type { Link Here
42
42
43
=head3 object_class
43
=head3 object_class
44
44
45
    my $class = Koha::IllComments->object_class;
45
    my $class = Koha::ILL::Comments->object_class;
46
46
47
Return this object's class name
47
Return this object's class name
48
48
49
=cut
49
=cut
50
50
51
sub object_class {
51
sub object_class {
52
    return 'Koha::Illcomment';
52
    return 'Koha::ILL::Comment';
53
}
53
}
54
54
55
=head1 AUTHOR
55
=head1 AUTHOR
(-)a/Koha/Illrequest.pm (-4 / +4 lines)
Lines 30-36 use Koha::Cache::Memory::Lite; Link Here
30
use Koha::Database;
30
use Koha::Database;
31
use Koha::DateUtils qw( dt_from_string );
31
use Koha::DateUtils qw( dt_from_string );
32
use Koha::Exceptions::Ill;
32
use Koha::Exceptions::Ill;
33
use Koha::Illcomments;
33
use Koha::ILL::Comments;
34
use Koha::Illrequestattributes;
34
use Koha::Illrequestattributes;
35
use Koha::AuthorisedValue;
35
use Koha::AuthorisedValue;
36
use Koha::Illrequest::Logger;
36
use Koha::Illrequest::Logger;
Lines 208-214 sub illrequestattributes { Link Here
208
208
209
sub illcomments {
209
sub illcomments {
210
    my ( $self ) = @_;
210
    my ( $self ) = @_;
211
    return Koha::Illcomments->_new_from_dbic(
211
    return Koha::ILL::Comments->_new_from_dbic(
212
        scalar $self->_result->illcomments
212
        scalar $self->_result->illcomments
213
    );
213
    );
214
}
214
}
Lines 217-229 sub illcomments { Link Here
217
217
218
    my $ill_comments = $req->comments;
218
    my $ill_comments = $req->comments;
219
219
220
Returns a I<Koha::Illcomments> resultset for the linked comments.
220
Returns a I<Koha::ILL::Comments> resultset for the linked comments.
221
221
222
=cut
222
=cut
223
223
224
sub comments {
224
sub comments {
225
    my ( $self ) = @_;
225
    my ( $self ) = @_;
226
    return Koha::Illcomments->_new_from_dbic(
226
    return Koha::ILL::Comments->_new_from_dbic(
227
        scalar $self->_result->comments
227
        scalar $self->_result->comments
228
    );
228
    );
229
}
229
}
(-)a/ill/ill-requests.pl (-1 / +1 lines)
Lines 25-31 use C4::Auth qw( get_template_and_user ); Link Here
25
use C4::Output qw( output_and_exit output_html_with_http_headers );
25
use C4::Output qw( output_and_exit output_html_with_http_headers );
26
use Koha::Notice::Templates;
26
use Koha::Notice::Templates;
27
use Koha::AuthorisedValues;
27
use Koha::AuthorisedValues;
28
use Koha::Illcomment;
28
use Koha::ILL::Comment;
29
use Koha::Illrequests;
29
use Koha::Illrequests;
30
use Koha::Illrequest;
30
use Koha::Illrequest;
31
use Koha::ILL::Batches;
31
use Koha::ILL::Batches;
(-)a/t/db_dependent/Illcomments.t (-21 / +25 lines)
Lines 30-83 use Test::MockModule; Link Here
30
30
31
use Test::More tests => 9;
31
use Test::More tests => 9;
32
32
33
my $schema = Koha::Database->new->schema;
33
my $schema  = Koha::Database->new->schema;
34
my $builder = t::lib::TestBuilder->new;
34
my $builder = t::lib::TestBuilder->new;
35
use_ok('Koha::Illcomment');
35
use_ok('Koha::ILL::Comment');
36
use_ok('Koha::Illcomments');
36
use_ok('Koha::ILL::Comments');
37
37
38
$schema->storage->txn_begin;
38
$schema->storage->txn_begin;
39
39
40
Koha::Illrequests->search->delete;
40
Koha::Illrequests->search->delete;
41
41
42
# Create a patron
42
# Create a patron
43
my $patron = $builder->build({ source => 'Borrower' });
43
my $patron = $builder->build( { source => 'Borrower' } );
44
44
45
# Create an ILL request
45
# Create an ILL request
46
my $illrq = $builder->build({
46
my $illrq = $builder->build(
47
    source => 'Illrequest',
47
    {
48
    value => { borrowernumber => $patron->{borrowernumber} }
48
        source => 'Illrequest',
49
});
49
        value  => { borrowernumber => $patron->{borrowernumber} }
50
my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id});
50
    }
51
);
52
my $illrq_obj = Koha::Illrequests->find( $illrq->{illrequest_id} );
51
isa_ok( $illrq_obj, 'Koha::Illrequest' );
53
isa_ok( $illrq_obj, 'Koha::Illrequest' );
52
54
53
# Create a librarian
55
# Create a librarian
54
my $librarian = $builder->build({ source => 'Borrower' });
56
my $librarian = $builder->build( { source => 'Borrower' } );
55
57
56
# Create a comment and tie it to the request and the librarian
58
# Create a comment and tie it to the request and the librarian
57
my $comment_text = 'xyz';
59
my $comment_text = 'xyz';
58
my $illcomment = $builder->build({
60
my $illcomment   = $builder->build(
59
    source => 'Illcomment',
61
    {
60
    value => {
62
        source => 'Illcomment',
61
        illrequest_id  => $illrq_obj->illrequest_id,
63
        value  => {
62
        borrowernumber => $librarian->{borrowernumber},
64
            illrequest_id  => $illrq_obj->illrequest_id,
63
        comment        => $comment_text,
65
            borrowernumber => $librarian->{borrowernumber},
66
            comment        => $comment_text,
67
        }
64
    }
68
    }
65
});
69
);
66
70
67
# Get all the comments
71
# Get all the comments
68
my $comments = $illrq_obj->illcomments;
72
my $comments = $illrq_obj->illcomments;
69
isa_ok( $comments, 'Koha::Illcomments', "Illcomments" );
73
isa_ok( $comments, 'Koha::ILL::Comments', "Illcomments" );
70
my @comments_list = $comments->as_list();
74
my @comments_list = $comments->as_list();
71
is( scalar @comments_list, 1, "We have 1 comment" );
75
is( scalar @comments_list, 1, "We have 1 comment" );
72
76
73
# Get the first (and only) comment
77
# Get the first (and only) comment
74
my $comment = $comments->next();
78
my $comment = $comments->next();
75
isa_ok( $comment, 'Koha::Illcomment', "Illcomment" );
79
isa_ok( $comment, 'Koha::ILL::Comment', "Illcomment" );
76
80
77
# Check the different data in the comment
81
# Check the different data in the comment
78
is( $comment->illrequest_id,  $illrq_obj->illrequest_id,    'illrequest_id getter works' );
82
is( $comment->illrequest_id,  $illrq_obj->illrequest_id,    'illrequest_id getter works' );
79
is( $comment->borrowernumber, $librarian->{borrowernumber}, 'borrowernumber getter works');
83
is( $comment->borrowernumber, $librarian->{borrowernumber}, 'borrowernumber getter works' );
80
is( $comment->comment,        $comment_text,                'comment getter works');
84
is( $comment->comment,        $comment_text,                'comment getter works' );
81
85
82
$illrq_obj->delete;
86
$illrq_obj->delete;
83
87
(-)a/t/db_dependent/api/v1/ill_requests.t (-2 / +1 lines)
Lines 209-215 subtest 'list() tests' => sub { Link Here
209
    # x-koha-embed: comments
209
    # x-koha-embed: comments
210
    # Create comment
210
    # Create comment
211
    my $comment_text = "This is the comment";
211
    my $comment_text = "This is the comment";
212
    my $comment = $builder->build_object({ class => 'Koha::Illcomments', value => { illrequest_id => $req_1->illrequest_id, comment => $comment_text , borrowernumber => $patron->borrowernumber } } );
212
    my $comment = $builder->build_object({ class => 'Koha::ILL::Comments', value => { illrequest_id => $req_1->illrequest_id, comment => $comment_text , borrowernumber => $patron->borrowernumber } } );
213
213
214
    # Make sure comments come back
214
    # Make sure comments come back
215
    $t->get_ok("//$userid:$password@/api/v1/ill/requests" => {"x-koha-embed" => "comments"} )
215
    $t->get_ok("//$userid:$password@/api/v1/ill/requests" => {"x-koha-embed" => "comments"} )
216
- 

Return to bug 35581