Bugzilla – Attachment 137700 Details for
Bug 27683
Bind results of GetAnalyticsCount to the EasyAnalyticalRecords pref
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27683: Unit test for GetAnalyticsCount
Bug-27683-Unit-test-for-GetAnalyticsCount.patch (text/plain), 1.98 KB, created by
Martin Renvoize (ashimema)
on 2022-07-14 09:36:42 UTC
(
hide
)
Description:
Bug 27683: Unit test for GetAnalyticsCount
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2022-07-14 09:36:42 UTC
Size:
1.98 KB
patch
obsolete
>From e49ac084b9be68b2e7d64fe680184c44b1b46aa9 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Thu, 11 Feb 2021 16:28:18 +0100 >Subject: [PATCH] Bug 27683: Unit test for GetAnalyticsCount > >Run prove t/db_dependent/Items/GetAnalyticsCount.t > >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Items/GetAnalyticsCount.t | 42 ++++++++++++++++++++++++ > 1 file changed, 42 insertions(+) > create mode 100755 t/db_dependent/Items/GetAnalyticsCount.t > >diff --git a/t/db_dependent/Items/GetAnalyticsCount.t b/t/db_dependent/Items/GetAnalyticsCount.t >new file mode 100755 >index 0000000000..7430102b26 >--- /dev/null >+++ b/t/db_dependent/Items/GetAnalyticsCount.t >@@ -0,0 +1,42 @@ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+use Test::MockModule; >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+use C4::Items; >+use Koha::Database; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+subtest 'GetAnalyticsCount' => sub { >+ plan tests => 2; >+ >+ my $itemnumber = '123456789'; >+ >+ my $engine = C4::Context->preference("SearchEngine") // 'Zebra'; >+ my $search = Test::MockModule->new("Koha::SearchEngine::${engine}::Search"); >+ $search->mock( >+ 'simple_search_compat', >+ sub { >+ my ( $self, $query ) = @_; >+ if ( $query and $query eq "hi=$itemnumber" ) { >+ return ( undef, undef, 7 ); >+ } >+ return ( undef, undef, 0 ); >+ } >+ ); >+ >+ t::lib::Mocks::mock_preference( 'EasyAnalyticalRecords', 0 ); >+ my $c = C4::Items::GetAnalyticsCount($itemnumber); >+ is( $c, 0, 'GetAnalyticsCount returns 0 when pref is disabled' ); >+ >+ t::lib::Mocks::mock_preference( 'EasyAnalyticalRecords', 1 ); >+ $c = C4::Items::GetAnalyticsCount($itemnumber); >+ is( $c, 7, 'GetAnalyticsCount uses simple_search_compat("hi=<itemnumber>") when pref is enabled' ); >+ >+}; >+ >+$schema->storage->txn_rollback; >-- >2.20.1
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 27683
:
116767
|
116768
|
116769
|
127839
|
127840
|
127841
|
137447
|
137448
|
137449
| 137700 |
137701
|
137702