| 1 | package App::ZofCMS::Test::Plugin; | ||||||||||||
| 2 | |||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 2 | our $VERSION = '1.001010'; # VERSION | |||||||||||
| 7 | |||||||||||||
| 8 | 2 | ▶ | use base 'Test::Builder::Module'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | 2 | my $Test = Test::Builder->new; | |||||||||||
| 11 | |||||||||||||
| 12 | 1 | ▶ | sub import { | ||||||||||
|
Subroutine
import: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | 1 | my $self = shift; | |||||||||||
| 14 | 1 | my $caller = caller; | |||||||||||
| 15 | 2 | ▶ | no strict 'refs'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | 1 | *{$caller.'::plugin_ok'} = \&plugin_ok; | |||||||||||
| 17 | |||||||||||||
| 18 | 1 | $Test->exported_to($caller); | |||||||||||
| 19 | 1 | $Test->plan( tests => 3); | |||||||||||
| 20 | } | ||||||||||||
| 21 | |||||||||||||
| 22 | 1 | ▶ | sub plugin_ok { | ||||||||||
|
Subroutine
plugin_ok: called CC=6 SCAR=19.7
Pod
documented
| |||||||||||||
| 23 | 1 | my ( $plugin_name, $template_with_input, $query, $config_hash ) = @_; | |||||||||||
| 24 | |||||||||||||
| 25 | 1 | ▶ | $template_with_input ||= {}; | ||||||||||
|
Condition50%1/2
$template_with_input ||= {}
MC/DC0%0/1
$template_with_input ||= {}
$template_with_input
Truth table50%1/2
A
A= $template_with_input
| |||||||||||||
| 26 | 1 | ▶ | $query ||= {}; | ||||||||||
|
Condition50%1/2
$query ||= {}
MC/DC0%0/1
$query ||= {}
$query
Truth table50%1/2
A
A= $query
| |||||||||||||
| 27 | |||||||||||||
| 28 | 1 | ▶ | eval "use App::ZofCMS::Plugin::$plugin_name"; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 29 | 1 | ▶ | if ( $@ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 30 | 0 | $Test->ok(1); | |||||||||||
| 31 | 0 | $Test->ok(1); | |||||||||||
| 32 | 0 | $Test->ok(1); | |||||||||||
| 33 | 0 | $Test->diag("Failed to use App::ZofCMS::Plugin::$plugin_name"); | |||||||||||
| 34 | 0 | exit 0; | |||||||||||
| 35 | } | ||||||||||||
| 36 | 1 | my $o = "App::ZofCMS::Plugin::$plugin_name"->new; | |||||||||||
| 37 | 1 | $Test->ok( $o->can('new'), "new() method is available"); | |||||||||||
| 38 | 1 | $Test->ok( $o->can('process'), "process() method is available"); | |||||||||||
| 39 | |||||||||||||
| 40 | SKIP: { | ||||||||||||
| 41 | 1 | ▶ | eval "use App::ZofCMS::Config"; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 42 | 1 | ▶ | if ( $@ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 0 | $Test->ok (1); | |||||||||||
| 44 | 0 | $Test->diag ("App::ZofCMS::Config is required for process() testing"); | |||||||||||
| 45 | 0 | last; | |||||||||||
| 46 | } | ||||||||||||
| 47 | |||||||||||||
| 48 | 1 | my $config = App::ZofCMS::Config->new; | |||||||||||
| 49 | 1 | ▶ | $config->conf( $config_hash || {} ); | ||||||||||
|
Condition50%1/2
$config_hash || {}
MC/DC0%0/1
$config_hash || {}
$config_hash
Truth table50%1/2
A
A= $config_hash
| |||||||||||||
| 50 | |||||||||||||
| 51 | 1 | $o->process( $template_with_input, $query, $config ); | |||||||||||
| 52 | |||||||||||||
| 53 | 1 | delete @$template_with_input{ qw/t d conf plugins/ }; | |||||||||||
| 54 | 1 | $Test->ok( 0 == keys %$template_with_input, | |||||||||||
| 55 | "Template must be empty after deleting {t}, {d}, {conf}" | ||||||||||||
| 56 | . " and {plugins} keys" | ||||||||||||
| 57 | ); | ||||||||||||
| 58 | |||||||||||||
| 59 | 1 | $Test->diag( | |||||||||||
| 60 | "Query ended up as: \n" . join "\n", map | ||||||||||||
| 61 | "[$_] => [$query->{$_}]", keys %$query | ||||||||||||
| 62 | ); | ||||||||||||
| 63 | } | ||||||||||||
| 64 | } | ||||||||||||
| 65 | |||||||||||||
| 66 | 2 | 1; | |||||||||||
| 67 | __END__ | ||||||||||||