Bugzilla – Attachment 154029 Details for
Bug 34223
ILL status filter does not load immediately after selecting a backend filter
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34223: (follow-up) Mock backend in tests
Bug-34223-follow-up-Mock-backend-in-tests.patch (text/plain), 4.45 KB, created by
Pedro Amorim
on 2023-07-28 09:36:39 UTC
(
hide
)
Description:
Bug 34223: (follow-up) Mock backend in tests
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2023-07-28 09:36:39 UTC
Size:
4.45 KB
patch
obsolete
>From 902dc4c825f38e91664521ae49ff9079a8ff8142 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Thu, 27 Jul 2023 14:20:11 +0000 >Subject: [PATCH] Bug 34223: (follow-up) Mock backend in tests > >Add a new request with a backend specific status > >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >--- > t/db_dependent/Koha/Illbackend.t | 60 +++++++++++++++++++++++++++----- > 1 file changed, 51 insertions(+), 9 deletions(-) > >diff --git a/t/db_dependent/Koha/Illbackend.t b/t/db_dependent/Koha/Illbackend.t >index d0ae26a4ea..79d9477b3a 100644 >--- a/t/db_dependent/Koha/Illbackend.t >+++ b/t/db_dependent/Koha/Illbackend.t >@@ -36,6 +36,35 @@ subtest 'existing_statuses() tests' => sub { > $schema->storage->txn_begin; > Koha::Illrequests->search->delete; > >+ # Mock ILLBackend (as object) >+ my $backend = Test::MockObject->new; >+ $backend->set_isa('Koha::Illbackends::Mock'); >+ $backend->set_always( 'name', 'Mock' ); >+ >+ $backend->mock( >+ 'status_graph', >+ sub { >+ return { >+ READY => { >+ prev_actions => [ 'NEW', 'REQREV', 'QUEUED', 'CANCREQ' ], >+ id => 'READY', >+ name => 'Ready', >+ ui_method_name => 'Make request ready', >+ method => 'confirm', >+ next_actions => [ 'REQREV', 'COMP', 'CHK' ], >+ ui_method_icon => 'fa-check', >+ } >+ }; >+ }, >+ ); >+ >+ # Mock Koha::Illrequest::load_backend (to load Mocked Backend) >+ my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); >+ $illreqmodule->mock( >+ 'load_backend', >+ sub { my $self = shift; $self->{_my_backend} = $backend; return $self } >+ ); >+ > my $alias = $builder->build_object( > { > class => 'Koha::AuthorisedValues', >@@ -47,6 +76,18 @@ subtest 'existing_statuses() tests' => sub { > } > ); > >+ my $backend_req_status = $builder->build_object( >+ { >+ class => 'Koha::Illrequests', >+ value => { >+ status => 'READY', >+ status_alias => undef, >+ biblio_id => undef, >+ backend => 'Mock' >+ } >+ } >+ ); >+ > my $req = $builder->build_object( > { > class => 'Koha::Illrequests', >@@ -54,7 +95,7 @@ subtest 'existing_statuses() tests' => sub { > status => 'REQ', > status_alias => undef, > biblio_id => undef, >- backend => 'FreeForm' >+ backend => 'Mock' > } > } > ); >@@ -65,7 +106,7 @@ subtest 'existing_statuses() tests' => sub { > status => 'CHK', > status_alias => undef, > biblio_id => undef, >- backend => 'FreeForm' >+ backend => 'Mock' > } > } > ); >@@ -76,7 +117,7 @@ subtest 'existing_statuses() tests' => sub { > status => 'REQ', > status_alias => 'BOB', > biblio_id => undef, >- backend => 'FreeForm' >+ backend => 'Mock' > } > } > ); >@@ -87,22 +128,23 @@ subtest 'existing_statuses() tests' => sub { > status => 'REQ', > status_alias => undef, > biblio_id => undef, >- backend => 'FreeForm' >+ backend => 'Mock' > } > } > ); > > my $backend_module = Koha::Illbackend->new; > >- my $existing_statuses = $backend_module->existing_statuses('FreeForm'); >+ my $existing_statuses = $backend_module->existing_statuses('Mock'); > >- is( @{$existing_statuses}, 3, "Return 3 unique existing statuses" ); >+ is( @{$existing_statuses}, 4, "Return 4 unique existing statuses" ); > > # FIXME: Add tests to check content and order of return > my $expected_statuses = [ >- { code => 'CHK', str => 'Checked out' }, >- { code => 'REQ', str => 'Requested' }, >- { code => 'BOB', str => 'Bob is the best status' } >+ { code => 'CHK', str => 'Checked out' }, >+ { code => 'READY', str => 'Ready' }, >+ { code => 'REQ', str => 'Requested' }, >+ { code => 'BOB', str => 'Bob is the best status' } > ]; > > is_deeply( $existing_statuses, $expected_statuses, 'Deep match on return' ); >-- >2.30.2
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 34223
:
153289
|
153953
|
153956
|
153957
|
153961
|
153962
|
153963
|
153968
|
153973
|
153978
|
153979
|
153980
|
153981
|
153989
|
153990
|
154026
|
154027
|
154028
|
154029
|
154030
|
154031
|
154032
|
154033
|
154068
|
154069
|
154070
|
154071
|
155280
|
155493