Zonemaster/Engine/TestMethods.pm untested

filter: Statementstmt 0.0% 0 / 50 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 71 CC 2 SCAR 9.6
CC
2
Cov
0%
method3
6.0
method1
2.0
method2
2.0
CRAP 2.6
1 package Zonemaster::Engine::TestMethods;
2  
3 use v5.16.0;
4 use warnings;
5  
6 use version; our $VERSION = version->declare("v1.0.3");
7  
8 use List::MoreUtils qw[uniq];
9 use Zonemaster::Engine::Util;
10  
11 sub method1 {
12 my ( $class, $zone ) = @_;
13  
14 return $zone->parent;
15 }
16  
17 sub method2 {
18 my ( $class, $zone ) = @_;
19  
20 return $zone->glue_names;
21 }
22  
23 sub method3 {
24 my ( $class, $zone ) = @_;
25  
26 my @child_nsnames;
27 my @nsnames;
28 my $ns_aref = $zone->query_all( $zone->name, q{NS} );
29 foreach my $p ( @{$ns_aref} ) {
30 next if not $p;
31 push @nsnames, $p->get_records_for_name( q{NS}, $zone->name );
32 }
33 @child_nsnames = uniq map { name( lc( $_->nsdname ) ) } @nsnames;
34  
35 return [@child_nsnames];
36 }
37  
38 sub method4 {
39 my ( $class, $zone ) = @_;
40  
41 return $zone->glue;
42 }
43  
44 sub method5 {
45 my ( $class, $zone ) = @_;
46  
47 return $zone->ns;
48 }
49  
50 sub method2and3 {
51 my ( $class, $zone ) = @_;
52  
53 my %union = map { $_->string => $_ } @{ $class->method2( $zone ) }, @{ $class->method3( $zone ) };
54 return [ @union{ sort keys %union } ];
55 }
56  
57 sub method4and5 {
58 my ( $class, $zone ) = @_;
59  
60 my %union = map { $_->string => $_ } @{ $class->method4( $zone ) }, @{ $class->method5( $zone ) };
61 return [ @union{ sort keys %union } ];
62 }
63  
64 =head1 NAME
65  
66 Zonemaster::Engine::TestMethods - Methods common to Test Specification used in test modules
67  
68 =head1 SYNOPSIS
69  
70 my @results = Zonemaster::Engine::TestMethods->method1($zone);
71  
72 =head1 METHODS
73  
74 For details on what these methods implement, see the test
75 specification documents.
76  
77 =over
78  
79 =item method1($zone)
80  
81 Returns either a Zonemaster::Engine::Zone or undef.
82  
83 =item method2($zone)
84  
85 Returns an arrayref of Zonemaster::Engine::DNSName objects.
86  
87 =item method3($zone)
88  
89 Returns an arrayref of Zonemaster::Engine::DNSName objects.
90  
91 =item method4($zone)
92  
93 Returns something that behaves like an arrayref of Zonemaster::Engine::Nameserver objects.
94  
95 =item method5($zone)
96  
97 Returns something that behaves like an arrayref of Zonemaster::Engine::Nameserver objects.
98  
99 =item method2and3($zone)
100  
101 Returns the union of Zonemaster::Engine::DNSName objects returned by
102 method2($zone) and method3($zone) in a arrayref.
103 The elements are sorted according to their string representation.
104  
105 =item method4and5($zone)
106  
107 Returns the union of Zonemaster::Engine::Nameserver objects returned by
108 method4($zone) and method5($zone) in a arrayref.
109 The elements are sorted according to their string representation.
110  
111 =back
112  
113 =cut
114  
115 1;