LDAP/Mixin.pm

filter: Statementstmt 98.3% 59 / 60 Branchbran 75.0% 6 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 2 totaltotal 93.9% 77 / 82 CC 5 SCAR 6.3
CC
5
Cov
96%
method_is
4.0
method_ok
2.0
BEGIN
1.0
CRAP 1.9
« LDAP/Mock/Node.pm ↑ Summary LDAP.pm »
1 14 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 14 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 14 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package Test::Net::LDAP::Mixin;
6  
7 14 ▶use Net::LDAP;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 14 ▶use Net::LDAP::Constant;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 14 ▶use Test::Builder;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 14 ▶use Test::Net::LDAP::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 14 for my $method (qw(search compare add modify delete moddn bind unbind abandon)) {
13 14 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
14
15 126 *{__PACKAGE__.'::'.$method.'_ok'} = sub {
16 102 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
17 102 local $Test::Builder::Level = $Test::Builder::Level + 1;
18 102 return $self->method_ok($method, @_);
19 126 };
20
21 126 *{__PACKAGE__.'::'.$method.'_is'} = sub {
22 44 ▶ my $self = shift;
Subroutine __ANON__: called CC=1 SCAR=0.0
23 44 local $Test::Builder::Level = $Test::Builder::Level + 1;
24 44 return $self->method_is($method, @_);
25 126 };
26 }
27  
28 sub method_ok {
29 105 ▶ my $ldap = shift;
Subroutine method_ok: called CC=2 SCAR=6.9
Pod undocumented
30 105 my $method = shift;
31 105 my ($params, $name);
32
33 105 ▶ if (ref $_[0] eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'ARRAY') { } 5 100 105
34 5 ($params, $name) = @_;
35 } else {
36 100 $params = \@_;
37 }
38
39 105 my $expected = Net::LDAP::Constant::LDAP_SUCCESS;
40 105 return $ldap->method_is($method, $params, $expected, $name);
41 }
42  
43 sub method_is {
44 150 ▶ my $ldap = shift;
Subroutine method_is: called CC=4 SCAR=14.0
Pod undocumented
45 150 my $method = shift;
46 150 my ($params, $expected, $name);
47
48 150 ▶ if (ref $_[0] eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq 'ARRAY') { } 150 0 150
49 150 ($params, $expected, $name) = @_;
50 } else {
51 0 $params = \@_;
52 }
53
54 150 my $mesg = $ldap->$method(@$params);
55
56 150 ▶ unless (defined $name) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 150 0 150
57 150 my $arg = Net::LDAP::_dn_options(@$params);
58
59 $name = $method.'('.join(', ', map {
60 205 my ($param, $value) = ($_, "$arg->{$_}");
61 205 ▶ $value = substr($value, 0, 32).'...' if length($value) > 32;
Branch: 1 branch
BranchTrueFalseTotal
if length $value > 32 10 195 205
62 205 qq($param => "$value");
63 } grep {
64 150 defined $arg->{$_}
65 } qw(base scope filter dn newrdn newsuperior)).')';
66 }
67
68 150 local $Test::Builder::Level = $Test::Builder::Level + 1;
69 150 Test::Net::LDAP::Util::ldap_result_is($mesg, $expected, $name);
70
71 150 return $mesg;
72 }
73  
74 14 1;
« LDAP/Mock/Node.pm ↑ Summary LDAP.pm »