|
Lines 36-41
subtest 'existing_statuses() tests' => sub {
Link Here
|
| 36 |
$schema->storage->txn_begin; |
36 |
$schema->storage->txn_begin; |
| 37 |
Koha::Illrequests->search->delete; |
37 |
Koha::Illrequests->search->delete; |
| 38 |
|
38 |
|
|
|
39 |
# Mock ILLBackend (as object) |
| 40 |
my $backend = Test::MockObject->new; |
| 41 |
$backend->set_isa('Koha::Illbackends::Mock'); |
| 42 |
$backend->set_always( 'name', 'Mock' ); |
| 43 |
|
| 44 |
$backend->mock( |
| 45 |
'status_graph', |
| 46 |
sub { |
| 47 |
return { |
| 48 |
READY => { |
| 49 |
prev_actions => [ 'NEW', 'REQREV', 'QUEUED', 'CANCREQ' ], |
| 50 |
id => 'READY', |
| 51 |
name => 'Ready', |
| 52 |
ui_method_name => 'Make request ready', |
| 53 |
method => 'confirm', |
| 54 |
next_actions => [ 'REQREV', 'COMP', 'CHK' ], |
| 55 |
ui_method_icon => 'fa-check', |
| 56 |
} |
| 57 |
}; |
| 58 |
}, |
| 59 |
); |
| 60 |
|
| 61 |
# Mock Koha::Illrequest::load_backend (to load Mocked Backend) |
| 62 |
my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); |
| 63 |
$illreqmodule->mock( |
| 64 |
'load_backend', |
| 65 |
sub { my $self = shift; $self->{_my_backend} = $backend; return $self } |
| 66 |
); |
| 67 |
|
| 39 |
my $alias = $builder->build_object( |
68 |
my $alias = $builder->build_object( |
| 40 |
{ |
69 |
{ |
| 41 |
class => 'Koha::AuthorisedValues', |
70 |
class => 'Koha::AuthorisedValues', |
|
Lines 47-52
subtest 'existing_statuses() tests' => sub {
Link Here
|
| 47 |
} |
76 |
} |
| 48 |
); |
77 |
); |
| 49 |
|
78 |
|
|
|
79 |
my $backend_req_status = $builder->build_object( |
| 80 |
{ |
| 81 |
class => 'Koha::Illrequests', |
| 82 |
value => { |
| 83 |
status => 'READY', |
| 84 |
status_alias => undef, |
| 85 |
biblio_id => undef, |
| 86 |
backend => 'Mock' |
| 87 |
} |
| 88 |
} |
| 89 |
); |
| 90 |
|
| 50 |
my $req = $builder->build_object( |
91 |
my $req = $builder->build_object( |
| 51 |
{ |
92 |
{ |
| 52 |
class => 'Koha::Illrequests', |
93 |
class => 'Koha::Illrequests', |
|
Lines 54-60
subtest 'existing_statuses() tests' => sub {
Link Here
|
| 54 |
status => 'REQ', |
95 |
status => 'REQ', |
| 55 |
status_alias => undef, |
96 |
status_alias => undef, |
| 56 |
biblio_id => undef, |
97 |
biblio_id => undef, |
| 57 |
backend => 'FreeForm' |
98 |
backend => 'Mock' |
| 58 |
} |
99 |
} |
| 59 |
} |
100 |
} |
| 60 |
); |
101 |
); |
|
Lines 65-71
subtest 'existing_statuses() tests' => sub {
Link Here
|
| 65 |
status => 'CHK', |
106 |
status => 'CHK', |
| 66 |
status_alias => undef, |
107 |
status_alias => undef, |
| 67 |
biblio_id => undef, |
108 |
biblio_id => undef, |
| 68 |
backend => 'FreeForm' |
109 |
backend => 'Mock' |
| 69 |
} |
110 |
} |
| 70 |
} |
111 |
} |
| 71 |
); |
112 |
); |
|
Lines 76-82
subtest 'existing_statuses() tests' => sub {
Link Here
|
| 76 |
status => 'REQ', |
117 |
status => 'REQ', |
| 77 |
status_alias => 'BOB', |
118 |
status_alias => 'BOB', |
| 78 |
biblio_id => undef, |
119 |
biblio_id => undef, |
| 79 |
backend => 'FreeForm' |
120 |
backend => 'Mock' |
| 80 |
} |
121 |
} |
| 81 |
} |
122 |
} |
| 82 |
); |
123 |
); |
|
Lines 87-106
subtest 'existing_statuses() tests' => sub {
Link Here
|
| 87 |
status => 'REQ', |
128 |
status => 'REQ', |
| 88 |
status_alias => undef, |
129 |
status_alias => undef, |
| 89 |
biblio_id => undef, |
130 |
biblio_id => undef, |
| 90 |
backend => 'FreeForm' |
131 |
backend => 'Mock' |
| 91 |
} |
132 |
} |
| 92 |
} |
133 |
} |
| 93 |
); |
134 |
); |
| 94 |
|
135 |
|
| 95 |
my $backend_module = Koha::Illbackend->new; |
136 |
my $backend_module = Koha::Illbackend->new; |
| 96 |
|
137 |
|
| 97 |
my $existing_statuses = $backend_module->existing_statuses('FreeForm'); |
138 |
my $existing_statuses = $backend_module->existing_statuses('Mock'); |
| 98 |
|
139 |
|
| 99 |
is( @{$existing_statuses}, 3, "Return 3 unique existing statuses" ); |
140 |
is( @{$existing_statuses}, 4, "Return 4 unique existing statuses" ); |
| 100 |
|
141 |
|
| 101 |
# FIXME: Add tests to check content and order of return |
142 |
# FIXME: Add tests to check content and order of return |
| 102 |
my $expected_statuses = [ |
143 |
my $expected_statuses = [ |
| 103 |
{ code => 'CHK', str => 'Checked out' }, |
144 |
{ code => 'CHK', str => 'Checked out' }, |
|
|
145 |
{ code => 'READY', str => 'Ready' }, |
| 104 |
{ code => 'REQ', str => 'Requested' }, |
146 |
{ code => 'REQ', str => 'Requested' }, |
| 105 |
{ code => 'BOB', str => 'Bob is the best status' } |
147 |
{ code => 'BOB', str => 'Bob is the best status' } |
| 106 |
]; |
148 |
]; |
| 107 |
- |
|
|