Line 0
Link Here
|
|
|
1 |
From 4ed0166e2d0cbb63055a769ed038a063e4443e3f Mon Sep 17 00:00:00 2001 |
2 |
From: Martin Renvoize <martin.renvoize@ptfs-europe.com> |
3 |
Date: Thu, 27 Jul 2023 13:20:13 +0100 |
4 |
Subject: [PATCH 3/3] Bug 34223: Add unit test for existing_statuses |
5 |
|
6 |
This patch adds a unit test for the 'existing_statuses' method. |
7 |
|
8 |
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> |
9 |
Signed-off-by: Laura Escamilla <laura.escamilla@bywatersolutions.com> |
10 |
--- |
11 |
t/db_dependent/Koha/Illbackend.t | 111 +++++++++++++++++++++++++++++++ |
12 |
1 file changed, 111 insertions(+) |
13 |
create mode 100644 t/db_dependent/Koha/Illbackend.t |
14 |
|
15 |
diff --git a/t/db_dependent/Koha/Illbackend.t b/t/db_dependent/Koha/Illbackend.t |
16 |
new file mode 100644 |
17 |
index 0000000000..d0ae26a4ea |
18 |
--- /dev/null |
19 |
+++ b/t/db_dependent/Koha/Illbackend.t |
20 |
@@ -0,0 +1,111 @@ |
21 |
+#!/usr/bin/perl |
22 |
+ |
23 |
+# Copyright 2023 Koha Development team |
24 |
+# |
25 |
+# This file is part of Koha |
26 |
+# |
27 |
+# Koha is free software; you can redistribute it and/or modify it |
28 |
+# under the terms of the GNU General Public License as published by |
29 |
+# the Free Software Foundation; either version 3 of the License, or |
30 |
+# (at your option) any later version. |
31 |
+# |
32 |
+# Koha is distributed in the hope that it will be useful, but |
33 |
+# WITHOUT ANY WARRANTY; without even the implied warranty of |
34 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
35 |
+# GNU General Public License for more details. |
36 |
+# |
37 |
+# You should have received a copy of the GNU General Public License |
38 |
+# along with Koha; if not, see <http://www.gnu.org/licenses>. |
39 |
+ |
40 |
+use Modern::Perl; |
41 |
+ |
42 |
+use Test::More tests => 1; |
43 |
+ |
44 |
+use Koha::Illbackend; |
45 |
+ |
46 |
+use t::lib::TestBuilder; |
47 |
+use t::lib::Mocks; |
48 |
+ |
49 |
+my $builder = t::lib::TestBuilder->new; |
50 |
+my $schema = Koha::Database->new->schema; |
51 |
+ |
52 |
+subtest 'existing_statuses() tests' => sub { |
53 |
+ |
54 |
+ plan tests => 2; |
55 |
+ |
56 |
+ $schema->storage->txn_begin; |
57 |
+ Koha::Illrequests->search->delete; |
58 |
+ |
59 |
+ my $alias = $builder->build_object( |
60 |
+ { |
61 |
+ class => 'Koha::AuthorisedValues', |
62 |
+ value => { |
63 |
+ category => 'ILL_STATUS_ALIAS', |
64 |
+ authorised_value => 'BOB', |
65 |
+ lib => "Bob is the best status" |
66 |
+ } |
67 |
+ } |
68 |
+ ); |
69 |
+ |
70 |
+ my $req = $builder->build_object( |
71 |
+ { |
72 |
+ class => 'Koha::Illrequests', |
73 |
+ value => { |
74 |
+ status => 'REQ', |
75 |
+ status_alias => undef, |
76 |
+ biblio_id => undef, |
77 |
+ backend => 'FreeForm' |
78 |
+ } |
79 |
+ } |
80 |
+ ); |
81 |
+ my $chk = $builder->build_object( |
82 |
+ { |
83 |
+ class => 'Koha::Illrequests', |
84 |
+ value => { |
85 |
+ status => 'CHK', |
86 |
+ status_alias => undef, |
87 |
+ biblio_id => undef, |
88 |
+ backend => 'FreeForm' |
89 |
+ } |
90 |
+ } |
91 |
+ ); |
92 |
+ my $bob = $builder->build_object( |
93 |
+ { |
94 |
+ class => 'Koha::Illrequests', |
95 |
+ value => { |
96 |
+ status => 'REQ', |
97 |
+ status_alias => 'BOB', |
98 |
+ biblio_id => undef, |
99 |
+ backend => 'FreeForm' |
100 |
+ } |
101 |
+ } |
102 |
+ ); |
103 |
+ my $req2 = $builder->build_object( |
104 |
+ { |
105 |
+ class => 'Koha::Illrequests', |
106 |
+ value => { |
107 |
+ status => 'REQ', |
108 |
+ status_alias => undef, |
109 |
+ biblio_id => undef, |
110 |
+ backend => 'FreeForm' |
111 |
+ } |
112 |
+ } |
113 |
+ ); |
114 |
+ |
115 |
+ my $backend_module = Koha::Illbackend->new; |
116 |
+ |
117 |
+ my $existing_statuses = $backend_module->existing_statuses('FreeForm'); |
118 |
+ |
119 |
+ is( @{$existing_statuses}, 3, "Return 3 unique existing statuses" ); |
120 |
+ |
121 |
+ # FIXME: Add tests to check content and order of return |
122 |
+ my $expected_statuses = [ |
123 |
+ { code => 'CHK', str => 'Checked out' }, |
124 |
+ { code => 'REQ', str => 'Requested' }, |
125 |
+ { code => 'BOB', str => 'Bob is the best status' } |
126 |
+ ]; |
127 |
+ |
128 |
+ is_deeply( $existing_statuses, $expected_statuses, 'Deep match on return' ); |
129 |
+ |
130 |
+ $schema->storage->txn_rollback; |
131 |
+}; |
132 |
-- |
133 |
2.30.2 |
134 |
|