Lines 17-24
Link Here
|
17 |
# You should have received a copy of the GNU General Public License |
17 |
# You should have received a copy of the GNU General Public License |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
19 |
|
19 |
|
20 |
use strict; |
20 |
use Modern::Perl; |
21 |
use warnings; |
21 |
|
22 |
use File::Spec; |
22 |
use File::Spec; |
23 |
use MARC::Record; |
23 |
use MARC::Record; |
24 |
|
24 |
|
Lines 77-80
eval {
Link Here
|
77 |
|
77 |
|
78 |
ok(!$@, 'Destroyed processor successfully'); |
78 |
ok(!$@, 'Destroyed processor successfully'); |
79 |
|
79 |
|
|
|
80 |
subtest "new() tests" => sub { |
81 |
|
82 |
plan tests => 13; |
83 |
|
84 |
my $processor; |
85 |
|
86 |
# Create a processor with a valid filter |
87 |
$processor = new Koha::RecordProcessor({ filters => 'Null' }); |
88 |
is( ref($processor), 'Koha::RecordProcessor', 'Processor created' ); |
89 |
is( scalar @{ $processor->filters }, 1, 'One filter initialized' ); |
90 |
is( ref($processor->filters->[0]), 'Koha::Filter::MARC::Null', 'Correct filter initialized' ); |
91 |
|
92 |
# Create a processor with an invalid filter |
93 |
$processor = new Koha::RecordProcessor({ filters => 'Dummy' }); |
94 |
is( ref($processor), 'Koha::RecordProcessor', 'Processor created' ); |
95 |
is( scalar @{ $processor->filters }, 0, 'No filter initialized' ); |
96 |
is( ref($processor->filters->[0]), '', 'Make sure no filter initialized' ); |
97 |
|
98 |
# Create a processor with two valid filters |
99 |
$processor = new Koha::RecordProcessor({ filters => [ 'Null', 'EmbedSeeFromHeadings' ] }); |
100 |
is( ref($processor), 'Koha::RecordProcessor', 'Processor created' ); |
101 |
is( scalar @{ $processor->filters }, 2, 'Two filters initialized' ); |
102 |
is( ref($processor->filters->[0]), 'Koha::Filter::MARC::Null', 'Correct first filter initialized' ); |
103 |
is( ref($processor->filters->[1]), 'Koha::Filter::MARC::EmbedSeeFromHeadings', 'Correct second filter initialized' ); |
104 |
|
105 |
# Create a processor with both valid and invalid filters. |
106 |
$processor = new Koha::RecordProcessor({ filters => [ 'Null', 'Dummy' ] }); |
107 |
is( ref($processor), 'Koha::RecordProcessor', 'Processor created' ); |
108 |
is( scalar @{ $processor->filters }, 1, 'Invalid filter skipped' ); |
109 |
is( ref($processor->filters->[0]), 'Koha::Filter::MARC::Null', 'Correct filter initialized' ); |
110 |
|
111 |
}; |
112 |
|
80 |
done_testing(); |
113 |
done_testing(); |
81 |
- |
|
|