Lines 33-50
my $builder = t::lib::TestBuilder->new;
Link Here
|
33 |
$schema->storage->txn_begin; |
33 |
$schema->storage->txn_begin; |
34 |
|
34 |
|
35 |
subtest 'get' => sub { |
35 |
subtest 'get' => sub { |
36 |
plan tests => 2; |
36 |
plan tests => 4; |
37 |
|
37 |
|
38 |
my $additional_contents = Koha::Template::Plugin::AdditionalContents->get({ category => 'news', location => ['opac_only', 'staff_and_opac'], lang => 'default', library => '%' }); |
38 |
my $additional_contents = Koha::Template::Plugin::AdditionalContents->get( |
39 |
my $before_count = $additional_contents ? $additional_contents->{content}->count() : 0; |
39 |
{ category => 'news', location => [ 'opac_only', 'staff_and_opac' ], lang => 'default', library => '%' } ); |
40 |
my $additional_content = $builder->build_object({ |
40 |
my $before_count = $additional_contents ? $additional_contents->{content}->count() : 0; |
41 |
class => 'Koha::AdditionalContents', |
41 |
my $additional_content = $builder->build_object( |
42 |
value => { |
42 |
{ |
43 |
category => 'news', |
43 |
class => 'Koha::AdditionalContents', |
44 |
location => 'opac_only', |
44 |
value => { |
45 |
branchcode => undef |
45 |
category => 'news', |
|
|
46 |
location => 'opac_only', |
47 |
branchcode => undef |
48 |
} |
46 |
} |
49 |
} |
47 |
}); |
50 |
); |
48 |
$builder->build_object( |
51 |
$builder->build_object( |
49 |
{ |
52 |
{ |
50 |
class => 'Koha::AdditionalContentsLocalizations', |
53 |
class => 'Koha::AdditionalContentsLocalizations', |
Lines 54-66
subtest 'get' => sub {
Link Here
|
54 |
} |
57 |
} |
55 |
} |
58 |
} |
56 |
); |
59 |
); |
57 |
$additional_contents = Koha::Template::Plugin::AdditionalContents->get({ category => 'news', location => ['opac_only', 'staff_and_opac'], lang => 'default' }); |
60 |
$additional_contents = Koha::Template::Plugin::AdditionalContents->get( |
58 |
is( $additional_contents->{content}->count, $before_count + 1, "We get the additional one we added"); |
61 |
{ category => 'news', location => [ 'opac_only', 'staff_and_opac' ], lang => 'default' } ); |
|
|
62 |
is( $additional_contents->{content}->count, $before_count + 1, "We get the additional one we added" ); |
63 |
|
64 |
$additional_contents = Koha::Template::Plugin::AdditionalContents->get( |
65 |
{ |
66 |
category => 'news', location => [ 'opac_only', 'staff_and_opac' ], lang => 'default', |
67 |
blocktitle => 'blockhead' |
68 |
} |
69 |
); |
59 |
|
70 |
|
60 |
$additional_contents = Koha::Template::Plugin::AdditionalContents->get({ category => 'news', location => ['opac_only', 'staff_and_opac'], lang => 'default', blocktitle => 'blockhead' }); |
71 |
is( $additional_contents->{blocktitle}, 'blockhead', "Block title is passed through" ); |
61 |
|
72 |
|
62 |
is( $additional_contents->{blocktitle}, 'blockhead', "Block title is passed through"); |
73 |
$additional_contents = Koha::Template::Plugin::AdditionalContents->get( |
|
|
74 |
{ |
75 |
id => $additional_content->id, category => 'news', location => [ 'opac_only', 'staff_and_opac' ], |
76 |
lang => 'default' |
77 |
} |
78 |
); |
79 |
is( $additional_contents->{content}->count, 1 ); |
63 |
|
80 |
|
|
|
81 |
$additional_contents = Koha::Template::Plugin::AdditionalContents->get( |
82 |
{ |
83 |
id => $additional_content->id, category => 'html_customizations', |
84 |
location => [ 'opac_only', 'staff_and_opac' ], lang => 'default' |
85 |
} |
86 |
); |
87 |
is( $additional_contents, undef ); |
64 |
|
88 |
|
65 |
}; |
89 |
}; |
66 |
|
90 |
|
67 |
- |
|
|