|
Lines 23-28
use Test::Mojo;
Link Here
|
| 23 |
use t::lib::TestBuilder; |
23 |
use t::lib::TestBuilder; |
| 24 |
use t::lib::Mocks; |
24 |
use t::lib::Mocks; |
| 25 |
|
25 |
|
|
|
26 |
use C4::Biblio qw( GetMarcFromKohaField ); |
| 27 |
|
| 26 |
use Koha::ERM::EHoldings::Titles; |
28 |
use Koha::ERM::EHoldings::Titles; |
| 27 |
use Koha::ERM::EHoldings::Packages; |
29 |
use Koha::ERM::EHoldings::Packages; |
| 28 |
use Koha::Virtualshelves; |
30 |
use Koha::Virtualshelves; |
|
Lines 337-343
subtest 'add() tests' => sub {
Link Here
|
| 337 |
|
339 |
|
| 338 |
subtest 'update() tests' => sub { |
340 |
subtest 'update() tests' => sub { |
| 339 |
|
341 |
|
| 340 |
plan tests => 15; |
342 |
plan tests => 16; |
| 341 |
|
343 |
|
| 342 |
$schema->storage->txn_begin; |
344 |
$schema->storage->txn_begin; |
| 343 |
|
345 |
|
|
Lines 362-369
subtest 'update() tests' => sub {
Link Here
|
| 362 |
my $unauth_userid = $patron->userid; |
364 |
my $unauth_userid = $patron->userid; |
| 363 |
|
365 |
|
| 364 |
my $ehtitle_id = |
366 |
my $ehtitle_id = |
| 365 |
$builder->build_object( { class => 'Koha::ERM::EHoldings::Titles' } ) |
367 |
$builder->build_object( { class => 'Koha::ERM::EHoldings::Titles', value => { biblio_id => undef } } ) |
| 366 |
->title_id; |
368 |
->title_id; |
| 367 |
|
369 |
|
| 368 |
# Unauthorized attempt to update |
370 |
# Unauthorized attempt to update |
| 369 |
$t->put_ok( |
371 |
$t->put_ok( |
|
Lines 460-465
subtest 'update() tests' => sub {
Link Here
|
| 460 |
"//$userid:$password@/api/v1/erm/eholdings/local/titles/$ehtitle_id" => |
462 |
"//$userid:$password@/api/v1/erm/eholdings/local/titles/$ehtitle_id" => |
| 461 |
json => $ehtitle_with_updated_field )->status_is(404); |
463 |
json => $ehtitle_with_updated_field )->status_is(404); |
| 462 |
|
464 |
|
|
|
465 |
subtest 'update eholdings title linked to biblio tests' => sub { |
| 466 |
|
| 467 |
plan tests => 6; |
| 468 |
|
| 469 |
my $biblio = $builder->build_sample_biblio(); |
| 470 |
my $record = $biblio->metadata->record(); |
| 471 |
|
| 472 |
my $ehtitle_id = |
| 473 |
$builder->build_object( { class => 'Koha::ERM::EHoldings::Titles', value => { biblio_id => $biblio->id } } ) |
| 474 |
->title_id; |
| 475 |
my $ehtitle_updated_title = { publication_title => "The journal of writing unit tests :" }; |
| 476 |
|
| 477 |
$t->put_ok( |
| 478 |
"//$userid:$password@/api/v1/erm/eholdings/local/titles/$ehtitle_id" => json => $ehtitle_updated_title ) |
| 479 |
->status_is(200)->json_is( '/publication_title' => 'The journal of writing unit tests :' ); |
| 480 |
|
| 481 |
$biblio->discard_changes; |
| 482 |
warn $biblio->title; |
| 483 |
my $record_after = $biblio->metadata->record; |
| 484 |
|
| 485 |
my ( $title_tag, $title_subfield ) = GetMarcFromKohaField('biblio.title'); |
| 486 |
is( |
| 487 |
$record_after->subfield( $title_tag, $title_subfield ), "The journal of writing unit tests :", |
| 488 |
"Biblio title is correctly update by eholding title update" |
| 489 |
); |
| 490 |
|
| 491 |
is( $record->fields(), $record_after->fields(), "We have the same number of fields after edit" ); |
| 492 |
my ($author_tag) = GetMarcFromKohaField('biblio.author'); |
| 493 |
my $old_author = $record->field($author_tag); |
| 494 |
my $new_author = $record_after->field($author_tag); |
| 495 |
is( $old_author->as_string, $new_author->as_string, "The record is otherwise untouched" ); |
| 496 |
|
| 497 |
}; |
| 498 |
|
| 463 |
$schema->storage->txn_rollback; |
499 |
$schema->storage->txn_rollback; |
| 464 |
}; |
500 |
}; |
| 465 |
|
501 |
|
| 466 |
- |
|
|