Lines 19-31
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 8; |
22 |
use Test::More tests => 14; |
|
|
23 |
use Test::Warn; |
23 |
|
24 |
|
24 |
use Koha::Patrons; |
25 |
use Koha::Patrons; |
25 |
use Koha::Reviews; |
26 |
use Koha::Reviews; |
|
|
27 |
use Koha::Notice::Messages; |
28 |
use Koha::Notice::Templates; |
26 |
use Koha::Database; |
29 |
use Koha::Database; |
27 |
|
30 |
|
28 |
use t::lib::TestBuilder; |
31 |
use t::lib::TestBuilder; |
|
|
32 |
use t::lib::Mocks; |
29 |
|
33 |
|
30 |
my $schema = Koha::Database->new->schema; |
34 |
my $schema = Koha::Database->new->schema; |
31 |
$schema->storage->txn_begin; |
35 |
$schema->storage->txn_begin; |
Lines 37-42
$patron_1 = Koha::Patrons->find( $patron_1->{borrowernumber} );
Link Here
|
37 |
$patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} ); |
41 |
$patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} ); |
38 |
my $biblio_1 = $builder->build({ source => 'Biblio' }); |
42 |
my $biblio_1 = $builder->build({ source => 'Biblio' }); |
39 |
my $biblio_2 = $builder->build({ source => 'Biblio' }); |
43 |
my $biblio_2 = $builder->build({ source => 'Biblio' }); |
|
|
44 |
my $nb_of_messages = Koha::Notice::Messages->search->count; |
40 |
my $nb_of_reviews = Koha::Reviews->search->count; |
45 |
my $nb_of_reviews = Koha::Reviews->search->count; |
41 |
my $nb_of_approved_reviews = Koha::Reviews->search({ approved => 1 })->count; |
46 |
my $nb_of_approved_reviews = Koha::Reviews->search({ approved => 1 })->count; |
42 |
my $new_review_1_1 = Koha::Review->new({ |
47 |
my $new_review_1_1 = Koha::Review->new({ |
Lines 82-87
subtest 'search_limited' => sub {
Link Here
|
82 |
$retrieved_review_1_1->delete; |
87 |
$retrieved_review_1_1->delete; |
83 |
is( Koha::Reviews->search->count, $nb_of_reviews + 2, 'Delete should have deleted the review' ); |
88 |
is( Koha::Reviews->search->count, $nb_of_reviews + 2, 'Delete should have deleted the review' ); |
84 |
|
89 |
|
|
|
90 |
# Test SendReview Alert |
91 |
|
92 |
# empty CommentModeratorsEmail |
93 |
t::lib::Mocks::mock_preference('CommentModeratorsEmail',undef); |
94 |
warning_like { |
95 |
$new_review_1_2->SendReviewAlert({ |
96 |
borrowernumber => $patron_1->{borrowernumber}, |
97 |
biblionumber => $biblio_2->{biblionumber}, |
98 |
reviewid => $new_review_1_2->reviewid |
99 |
}) } qr/CommentModeratorsEmail is not set!/, 'SendReviewAlert triggered expected CommentModeratorsEmail warning.'; |
100 |
is( Koha::Notice::Messages->search->count, $nb_of_messages, 'SendReviewAlert lacking CommentModeratorsEmail triggered nothing.' ); |
101 |
|
102 |
# set CommentModeratorsEmail |
103 |
t::lib::Mocks::mock_preference('CommentModeratorsEmail','test@test.test'); |
104 |
warning_is { |
105 |
$new_review_1_2->SendReviewAlert({ |
106 |
borrowernumber => $patron_1->{borrowernumber}, |
107 |
biblionumber => $biblio_2->{biblionumber}, |
108 |
reviewid => $new_review_1_2->reviewid |
109 |
}) } '', 'SendReviewAlert triggered no warnings as expected.'; |
110 |
is( Koha::Notice::Messages->search->count, $nb_of_messages+1, 'SendReviewAlert triggered notice.' ); |
111 |
|
112 |
# letter missing |
113 |
Koha::Notice::Templates->search({ |
114 |
module => 'members', |
115 |
code => 'COMMENT_CREATED' |
116 |
})->delete; |
117 |
warnings_like { |
118 |
$new_review_1_2->SendReviewAlert({ |
119 |
borrowernumber => $patron_1->{borrowernumber}, |
120 |
biblionumber => $biblio_2->{biblionumber}, |
121 |
reviewid => $new_review_1_2->reviewid |
122 |
}) } |
123 |
[ qr/No members COMMENT_CREATED letter transported by email/, |
124 |
qr/COMMENT_CREATED member letter not found!/ ] , 'SendReviewAlert triggered expected COMMENT_CREATED warnings.'; |
125 |
is( Koha::Notice::Messages->search->count, $nb_of_messages+1, 'SendReviewAlert lacking letter triggered nothing new.' ); |
126 |
|
85 |
$schema->storage->txn_rollback; |
127 |
$schema->storage->txn_rollback; |
86 |
|
128 |
|
87 |
sub set_logged_in_user { |
129 |
sub set_logged_in_user { |
88 |
- |
|
|