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

(-)a/Koha/NewsItem.pm (-2 / +4 lines)
Lines 47-54 Return the Koha::Patron object for the patron who authored this news item Link Here
47
=cut
47
=cut
48
48
49
sub author {
49
sub author {
50
    my ( $self ) = @_;
50
    my ($self) = @_;
51
    return Koha::Patron->_new_from_dbic($self->_result->borrowernumber);
51
    my $author_rs = $self->_result->borrowernumber;
52
    return unless $author_rs;
53
    return Koha::Patron->_new_from_dbic($author_rs);
52
}
54
}
53
55
54
=head3 _type
56
=head3 _type
(-)a/t/db_dependent/Koha/News.t (-3 / +9 lines)
Lines 55-64 $retrieved_news_item_1->delete; Link Here
55
is( Koha::News->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' );
55
is( Koha::News->search->count, $nb_of_news + 1, 'Delete should have deleted the news_item' );
56
56
57
subtest '->author' => sub {
57
subtest '->author' => sub {
58
    plan tests => 1;
58
    plan tests => 3;
59
59
60
    my $news_item = $builder->build_object({ class => 'Koha::News' });
60
    my $news_item = $builder->build_object({ class => 'Koha::News' });
61
    is( ref($news_item->author), 'Koha::Patron', 'Koha::NewsItem->author returns a Koha::Patron object' );
61
    my $author = $news_item->author;
62
    is( ref($author), 'Koha::Patron', 'Koha::NewsItem->author returns a Koha::Patron object' );
63
64
    $author->delete;
65
66
    $news_item = Koha::News->find($news_item->idnew);
67
    is( ref($news_item), 'Koha::NewsItem', 'News are not deleted alongwith the author' );
68
    is( $news_item->author, undef, '->author returns undef is the author has been deleted' );
62
};
69
};
63
70
64
$schema->storage->txn_rollback;
71
$schema->storage->txn_rollback;
65
- 

Return to bug 27714