Bug 22321: Add unit tests
To test: 1. prove t/db_dependent/Illrequests.t 2. Observe test failure 1..3 ok 1 - before change, original borrowernumber found not ok 2 - after change, changed borrowernumber found in holds # Failed test 'after change, changed borrowernumber found in holds' # at t/db_dependent/Illrequests.t line 167. # got: '3786' # expected: '3787' ok 3 - after change, changed borrowernumber found in illrequests # Looks like you failed 1 test of 3. not ok 4 - store borrowernumber change also updates holds Signed-off-by: Magnus Enger <magnus@libriotech.no> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
246658a04a
commit
794b2dd81c
1 changed files with 49 additions and 0 deletions
|
@ -125,6 +125,55 @@ subtest 'Basic object tests' => sub {
|
|||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
subtest 'store borrowernumber change also updates holds' => sub {
|
||||
plan tests => 3;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
Koha::Illrequests->search->delete;
|
||||
|
||||
my $patron = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
my $other_patron = $builder->build_object({ class => 'Koha::Patrons' });
|
||||
my $biblio = $builder->build_object({ class => 'Koha::Biblios' });
|
||||
|
||||
my $request = $builder->build_object({
|
||||
class => 'Koha::Illrequests',
|
||||
value => {
|
||||
borrowernumber => $patron->borrowernumber,
|
||||
biblio_id => $biblio->biblionumber,
|
||||
}
|
||||
});
|
||||
$builder->build({
|
||||
source => 'Reserve',
|
||||
value => {
|
||||
borrowernumber => $patron->borrowernumber,
|
||||
biblionumber => $request->biblio_id
|
||||
}
|
||||
});
|
||||
|
||||
my $hold = Koha::Holds->find({
|
||||
biblionumber => $request->biblio_id,
|
||||
borrowernumber => $request->borrowernumber,
|
||||
});
|
||||
|
||||
is( $hold->borrowernumber, $request->borrowernumber,
|
||||
'before change, original borrowernumber found' );
|
||||
|
||||
$request->borrowernumber( $other_patron->borrowernumber )->store;
|
||||
|
||||
# reload changes
|
||||
$hold->discard_changes;
|
||||
|
||||
is( $hold->borrowernumber, $other_patron->borrowernumber,
|
||||
'after change, changed borrowernumber found in holds' );
|
||||
|
||||
is( $request->borrowernumber, $other_patron->borrowernumber,
|
||||
'after change, changed borrowernumber found in illrequests' );
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
|
||||
};
|
||||
|
||||
subtest 'Working with related objects' => sub {
|
||||
|
||||
plan tests => 7;
|
||||
|
|
Loading…
Reference in a new issue