Bugzilla – Attachment 79579 Details for
Bug 20797
If an Ill request has an associated bib record, the detail view should contain a link to the record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20996: Fix unit tests
Bug-20996-Fix-unit-tests.patch (text/plain), 8.04 KB, created by
Magnus Enger
on 2018-09-28 13:17:21 UTC
(
hide
)
Description:
Bug 20996: Fix unit tests
Filename:
MIME Type:
Creator:
Magnus Enger
Created:
2018-09-28 13:17:21 UTC
Size:
8.04 KB
patch
obsolete
>From 3f51e777b5d0277fdf2e195054f8bbee9b8d603f Mon Sep 17 00:00:00 2001 >From: Andrew Isherwood <andrew.isherwood@ptfs-europe.com> >Date: Wed, 4 Jul 2018 13:13:33 +0100 >Subject: [PATCH] Bug 20996: Fix unit tests > >- Remove unit tests relating to TO_JSON >- Add tests for new explicit embedding >- Modify tests relating to now deprecated brw_cat > >Signed-off-by: Magnus Enger <magnus@enger.priv.no> > >https://bugs.koha-community.org/show_bug.cgi?id=20797 >--- > t/db_dependent/Illrequests.t | 75 +++---------------------------------- > t/db_dependent/api/v1/illrequests.t | 19 +++++----- > 2 files changed, 14 insertions(+), 80 deletions(-) > >diff --git a/t/db_dependent/Illrequests.t b/t/db_dependent/Illrequests.t >index 761de9f12b..83bdbe0829 100644 >--- a/t/db_dependent/Illrequests.t >+++ b/t/db_dependent/Illrequests.t >@@ -28,7 +28,7 @@ use Test::MockObject; > use Test::MockModule; > use Test::Exception; > >-use Test::More tests => 11; >+use Test::More tests => 10; > > my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new; >@@ -536,7 +536,7 @@ subtest 'Backend core methods' => sub { > > subtest 'Helpers' => sub { > >- plan tests => 9; >+ plan tests => 7; > > $schema->storage->txn_begin; > >@@ -564,35 +564,26 @@ subtest 'Helpers' => sub { > $config->set_series('getPrefixes', > { CPL => "TEST", TSL => "BAR", default => "DEFAULT" }, > { A => "ATEST", C => "CBAR", default => "DEFAULT" }); >- is($illrq_obj->getPrefix({ brw_cat => "C", branch => "CPL" }), "CBAR", >- "getPrefix: brw_cat"); >- $config->set_series('getPrefixes', >- { CPL => "TEST", TSL => "BAR", default => "DEFAULT" }, >- { A => "ATEST", C => "CBAR", default => "DEFAULT" }); > is($illrq_obj->getPrefix({ brw_cat => "UNKNOWN", branch => "CPL" }), "TEST", > "getPrefix: branch"); > $config->set_series('getPrefixes', > { CPL => "TEST", TSL => "BAR", default => "DEFAULT" }, > { A => "ATEST", C => "CBAR", default => "DEFAULT" }); >- is($illrq_obj->getPrefix({ brw_cat => "UNKNOWN", branch => "UNKNOWN" }), "DEFAULT", >+ is($illrq_obj->getPrefix({ branch => "UNKNOWN" }), "", > "getPrefix: default"); > $config->set_always('getPrefixes', {}); >- is($illrq_obj->getPrefix({ brw_cat => "UNKNOWN", branch => "UNKNOWN" }), "", >+ is($illrq_obj->getPrefix({ branch => "UNKNOWN" }), "", > "getPrefix: the empty prefix"); > > # id_prefix > $config->set_series('getPrefixes', > { CPL => "TEST", TSL => "BAR", default => "DEFAULT" }, >- { A => "ATEST", C => "CBAR", default => "DEFAULT" }); >- is($illrq_obj->id_prefix, "ATEST-", "id_prefix: brw_cat"); >- $config->set_series('getPrefixes', >- { CPL => "TEST", TSL => "BAR", default => "DEFAULT" }, > { AB => "ATEST", CD => "CBAR", default => "DEFAULT" }); > is($illrq_obj->id_prefix, "TEST-", "id_prefix: branch"); > $config->set_series('getPrefixes', > { CPLT => "TEST", TSLT => "BAR", default => "DEFAULT" }, > { AB => "ATEST", CD => "CBAR", default => "DEFAULT" }); >- is($illrq_obj->id_prefix, "DEFAULT-", "id_prefix: default"); >+ is($illrq_obj->id_prefix, "", "id_prefix: default"); > > # requires_moderation > $illrq_obj->status('NEW')->store; >@@ -804,59 +795,3 @@ subtest 'Checking Limits' => sub { > > $schema->storage->txn_rollback; > }; >- >-subtest 'TO_JSON() tests' => sub { >- >- plan tests => 10; >- >- my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); >- >- # Mock ->capabilities >- $illreqmodule->mock( 'capabilities', sub { return 'capable'; } ); >- >- # Mock ->metadata >- $illreqmodule->mock( 'metadata', sub { return 'metawhat?'; } ); >- >- $schema->storage->txn_begin; >- >- my $library = $builder->build_object( { class => 'Koha::Libraries' } ); >- my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >- my $illreq = $builder->build_object( >- { >- class => 'Koha::Illrequests', >- value => { >- branchcode => $library->branchcode, >- borrowernumber => $patron->borrowernumber >- } >- } >- ); >- my $illreq_json = $illreq->TO_JSON; >- is( $illreq_json->{patron}, >- undef, '%embed not passed, no \'patron\' attribute' ); >- is( $illreq_json->{metadata}, >- undef, '%embed not passed, no \'metadata\' attribute' ); >- is( $illreq_json->{capabilities}, >- undef, '%embed not passed, no \'capabilities\' attribute' ); >- is( $illreq_json->{library}, >- undef, '%embed not passed, no \'library\' attribute' ); >- >- $illreq_json = $illreq->TO_JSON( >- { patron => 1, metadata => 1, capabilities => 1, library => 1 } ); >- is( $illreq_json->{patron}->{firstname}, >- $patron->firstname, >- '%embed passed, \'patron\' attribute correct (firstname)' ); >- is( $illreq_json->{patron}->{surname}, >- $patron->surname, >- '%embed passed, \'patron\' attribute correct (surname)' ); >- is( $illreq_json->{patron}->{cardnumber}, >- $patron->cardnumber, >- '%embed passed, \'patron\' attribute correct (cardnumber)' ); >- is( $illreq_json->{metadata}, >- 'metawhat?', '%embed passed, \'metadata\' attribute correct' ); >- is( $illreq_json->{capabilities}, >- 'capable', '%embed passed, \'capabilities\' attribute correct' ); >- is( $illreq_json->{library}->{branchcode}, >- $library->branchcode, '%embed not passed, no \'library\' attribute' ); >- >- $schema->storage->txn_rollback; >-}; >diff --git a/t/db_dependent/api/v1/illrequests.t b/t/db_dependent/api/v1/illrequests.t >index b0850e9192..b58d529c08 100644 >--- a/t/db_dependent/api/v1/illrequests.t >+++ b/t/db_dependent/api/v1/illrequests.t >@@ -38,7 +38,7 @@ my $t = Test::Mojo->new('Koha::REST::V1'); > > subtest 'list() tests' => sub { > >- plan tests => 15; >+ plan tests => 18; > > my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); > # Mock ->capabilities >@@ -67,6 +67,7 @@ subtest 'list() tests' => sub { > { > class => 'Koha::Illrequests', > value => { >+ backend => 'FreeForm', > branchcode => $library->branchcode, > borrowernumber => $patron->borrowernumber > } >@@ -77,20 +78,18 @@ subtest 'list() tests' => sub { > $tx = $t->ua->build_tx( GET => '/api/v1/illrequests' ); > $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); > $tx->req->env( { REMOTE_ADDR => $remote_address } ); >- $t->request_ok($tx)->status_is(200)->json_is( [ $illrequest->TO_JSON ] ); >+ $t->request_ok($tx)->status_is(200)->json_is( [ $illrequest->unblessed ] ); > > # One illrequest created, returned with augmented data > $tx = $t->ua->build_tx( GET => > '/api/v1/illrequests?embed=patron,library,capabilities,metadata' ); > $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); > $tx->req->env( { REMOTE_ADDR => $remote_address } ); >- $t->request_ok($tx)->status_is(200)->json_is( >- [ >- $illrequest->TO_JSON( >- { patron => 1, library => 1, capabilities => 1, metadata => 1 } >- ) >- ] >- ); >+ $t->request_ok($tx)->status_is(200) >+ ->json_has( '/0/patron', $patron->unblessed ) >+ ->json_has( '/0/capabilities', 'capable' ) >+ ->json_has( '/0/library', $library->unblessed ) >+ ->json_has( '/0/metadata', 'metawhat?' ); > > # Create another ILL request > my $illrequest2 = $builder->build_object( >@@ -108,7 +107,7 @@ subtest 'list() tests' => sub { > $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); > $tx->req->env( { REMOTE_ADDR => $remote_address } ); > $t->request_ok($tx)->status_is(200) >- ->json_is( [ $illrequest->TO_JSON, $illrequest2->TO_JSON ] ); >+ ->json_is( [ $illrequest->unblessed, $illrequest2->unblessed ] ); > > # Warn on unsupported query parameter > $tx = $t->ua->build_tx( GET => '/api/v1/illrequests?request_blah=blah' ); >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20797
:
75454
|
75485
|
75486
|
75656
|
75870
|
79495
|
79496
|
79497
|
79578
|
79579
|
79580
|
79581
|
79582
|
79946
|
79947
|
80018
|
80019
|
80021
|
80022
|
80038
|
80040
|
80047
|
80048
|
80049
|
80055
|
80071
|
80072
|
80073
|
80120
|
80121
|
80122