Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 4; |
22 |
use Test::More tests => 7; |
23 |
|
23 |
|
24 |
use Koha::Review; |
24 |
use Koha::Review; |
25 |
use Koha::Reviews; |
25 |
use Koha::Reviews; |
Lines 36-41
my $patron_2 = $builder->build({ source => 'Borrower' });
Link Here
|
36 |
my $biblio_1 = $builder->build({ source => 'Biblio' }); |
36 |
my $biblio_1 = $builder->build({ source => 'Biblio' }); |
37 |
my $biblio_2 = $builder->build({ source => 'Biblio' }); |
37 |
my $biblio_2 = $builder->build({ source => 'Biblio' }); |
38 |
my $nb_of_reviews = Koha::Reviews->search->count; |
38 |
my $nb_of_reviews = Koha::Reviews->search->count; |
|
|
39 |
my $nb_of_approved_reviews = Koha::Reviews->search({ approved => 1 })->count; |
39 |
my $new_review_1_1 = Koha::Review->new({ |
40 |
my $new_review_1_1 = Koha::Review->new({ |
40 |
borrowernumber => $patron_1->{borrowernumber}, |
41 |
borrowernumber => $patron_1->{borrowernumber}, |
41 |
biblionumber => $biblio_1->{biblionumber}, |
42 |
biblionumber => $biblio_1->{biblionumber}, |
Lines 55-60
my $new_review_2_1 = Koha::Review->new({
Link Here
|
55 |
like( $new_review_1_1->reviewid, qr|^\d+$|, 'Adding a new review should have set the reviewid'); |
56 |
like( $new_review_1_1->reviewid, qr|^\d+$|, 'Adding a new review should have set the reviewid'); |
56 |
is( Koha::Reviews->search->count, $nb_of_reviews + 3, 'The 3 reviews should have been added' ); |
57 |
is( Koha::Reviews->search->count, $nb_of_reviews + 3, 'The 3 reviews should have been added' ); |
57 |
|
58 |
|
|
|
59 |
is( Koha::Reviews->search({approved => 1})->count, $nb_of_approved_reviews, 'There should not be new approved reviews' ); |
60 |
$new_review_1_1->approve; |
61 |
is( Koha::Reviews->search({approved => 1})->count, $nb_of_approved_reviews + 1, 'There should be 1 new approved review' ); |
62 |
$new_review_1_1->unapprove; |
63 |
is( Koha::Reviews->search({approved => 1})->count, $nb_of_approved_reviews, 'There should not be any new approved review anymore' ); |
64 |
|
58 |
my $retrieved_review_1_1 = Koha::Reviews->find( $new_review_1_1->reviewid ); |
65 |
my $retrieved_review_1_1 = Koha::Reviews->find( $new_review_1_1->reviewid ); |
59 |
is( $retrieved_review_1_1->review, $new_review_1_1->review, 'Find a review by id should return the correct review' ); |
66 |
is( $retrieved_review_1_1->review, $new_review_1_1->review, 'Find a review by id should return the correct review' ); |
60 |
|
67 |
|
61 |
- |
|
|