Lines 31-41
my $schema = Koha::Database->new->schema;
Link Here
|
31 |
|
31 |
|
32 |
subtest 'existing_statuses() tests' => sub { |
32 |
subtest 'existing_statuses() tests' => sub { |
33 |
|
33 |
|
34 |
plan tests => 4; |
34 |
plan tests => 1; |
35 |
|
35 |
|
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 |
# Mock Koha::Illrequest::load_backend (to load Mocked Backend) |
45 |
my $illreqmodule = Test::MockModule->new('Koha::Illrequest'); |
46 |
$illreqmodule->mock( |
47 |
'load_backend', |
48 |
sub { my $self = shift; $self->{_my_backend} = $backend; return $self } |
49 |
); |
50 |
|
51 |
$illreqmodule->mock( |
52 |
'capabilities', |
53 |
sub { |
54 |
return { |
55 |
READY => { |
56 |
prev_actions => [ 'NEW', 'REQREV', 'QUEUED', 'CANCREQ' ], |
57 |
id => 'REQ', |
58 |
name => 'Requested', |
59 |
ui_method_name => 'Confirm request', |
60 |
method => 'confirm', |
61 |
next_actions => [ 'REQREV', 'COMP', 'CHK' ], |
62 |
ui_method_icon => 'fa-check', |
63 |
} |
64 |
}; |
65 |
}, |
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-82
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 => { status => 'READY', status_alias => undef, biblio_id => undef, backend => 'Mock' } |
83 |
} |
84 |
); |
85 |
|
50 |
my $req = $builder->build_object( |
86 |
my $req = $builder->build_object( |
51 |
{ |
87 |
{ |
52 |
class => 'Koha::Illrequests', |
88 |
class => 'Koha::Illrequests', |
53 |
value => { status => 'REQ', status_alias => undef, biblio_id => undef, backend => 'FreeForm' } |
89 |
value => { status => 'REQ', status_alias => undef, biblio_id => undef, backend => 'Mock' } |
54 |
} |
90 |
} |
55 |
); |
91 |
); |
56 |
my $chk = $builder->build_object( |
92 |
my $chk = $builder->build_object( |
57 |
{ |
93 |
{ |
58 |
class => 'Koha::Illrequests', |
94 |
class => 'Koha::Illrequests', |
59 |
value => { status => 'CHK', status_alias => undef, biblio_id => undef, backend => 'FreeForm' } |
95 |
value => { status => 'CHK', status_alias => undef, biblio_id => undef, backend => 'Mock' } |
60 |
} |
96 |
} |
61 |
); |
97 |
); |
62 |
my $bob = $builder->build_object( |
98 |
my $bob = $builder->build_object( |
63 |
{ |
99 |
{ |
64 |
class => 'Koha::Illrequests', |
100 |
class => 'Koha::Illrequests', |
65 |
value => { status => 'REQ', status_alias => 'BOB', biblio_id => undef, backend => 'FreeForm' } |
101 |
value => { status => 'REQ', status_alias => 'BOB', biblio_id => undef, backend => 'Mock' } |
66 |
} |
102 |
} |
67 |
); |
103 |
); |
68 |
my $req2 = $builder->build_object( |
104 |
my $req2 = $builder->build_object( |
69 |
{ |
105 |
{ |
70 |
class => 'Koha::Illrequests', |
106 |
class => 'Koha::Illrequests', |
71 |
value => { status => 'REQ', status_alias => undef, biblio_id => undef, backend => 'FreeForm' } |
107 |
value => { status => 'REQ', status_alias => undef, biblio_id => undef, backend => 'Mock' } |
72 |
} |
108 |
} |
73 |
); |
109 |
); |
74 |
|
110 |
|
75 |
my $backend_module = Koha::Illbackend->new; |
111 |
my $backend_module = Koha::Illbackend->new; |
76 |
|
112 |
|
77 |
my $existing_statuses = $backend_module->existing_statuses('FreeForm'); |
113 |
my $existing_statuses = $backend_module->existing_statuses('Mock'); |
78 |
|
114 |
|
79 |
is( @{$existing_statuses}, 3, "Return 3 unique existing statuses" ); |
115 |
is( @{$existing_statuses}, 4, "Return 4 unique existing statuses" ); |
80 |
|
116 |
|
81 |
# FIXME: Add tests to check content and order of return |
117 |
# FIXME: Add tests to check content and order of return |
82 |
|
118 |
|
83 |
- |
|
|