Bug 24487: Add 2 more tests

And make sure tests pass if there is no patron with borrowernumber=10 in
DB.

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Ammended test description
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Jonathan Druart 2020-01-23 10:47:17 +01:00 committed by Martin Renvoize
parent 1e5fca80e6
commit fd1ade2a67
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 17 additions and 2 deletions

View File

@ -189,13 +189,22 @@ subtest 'objects.search helper, embed' => sub {
};
subtest 'objects.search helper, with path parameters and _match' => sub {
plan tests => 4;
plan tests => 8;
$schema->storage->txn_begin;
Koha::Holds->search()->delete;
$builder->build_object({class=>"Koha::Holds", value => {borrowernumber => 10 }});
my $patron = Koha::Patrons->find(10);
$patron->delete if $patron;
$patron = $builder->build_object( { class => "Koha::Patrons" } );
$patron->borrowernumber(10)->store;
$builder->build_object(
{
class => "Koha::Holds",
value => { borrowernumber => $patron->borrowernumber }
}
);
$t->get_ok('/patrons/1/holds?_match=exact')
->json_is('/count' => 0, 'there should be no holds for borrower 1 with _match=exact');
@ -203,5 +212,11 @@ subtest 'objects.search helper, with path parameters and _match' => sub {
$t->get_ok('/patrons/1/holds?_match=contains')
->json_is('/count' => 0, 'there should be no holds for borrower 1 with _match=contains');
$t->get_ok('/patrons/10/holds?_match=exact')
->json_is('/count' => 1, 'there should be 1 hold for borrower 10 with _match=exact');
$t->get_ok('/patrons/10/holds?_match=contains')
->json_is('/count' => 1, 'there should be 1 hold for borrower 10 with _match=contains');
$schema->storage->txn_rollback;
};