| 1 | package Test::DBIx::Class; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 17 | ▶ | use 5.008; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 17 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 17 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 17 | ▶ | use base 'Test::Builder::Module'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 17 | our $VERSION = '0.52'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 17 | our $AUTHORITY = 'cpan:JJNAPIORK'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 17 | ▶ | use Config::Any; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 17 | ▶ | use Data::Visitor::Callback; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 17 | ▶ | use Digest::MD5; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 17 | ▶ | use Hash::Merge; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 17 | ▶ | use Path::Class; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 17 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 17 | ▶ | use Sub::Exporter; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 17 | ▶ | use Test::DBIx::Class::SchemaManager; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 17 | ▶ | use Test::Deep (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 17 | ▶ | use Test::More (); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 32 | ▶ | sub eq_or_diff2 { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
eq_or_diff2: called CC=2 SCAR=7.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 32 | my ($given, $expected, $message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 32 | my ($ok, $stack) = Test::Deep::cmp_details($given, $expected); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 32 | ▶ | if($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 32 | Test::More::pass($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | my $diag = Test::Deep::deep_diag($stack); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | Test::More::fail("$message: $diag"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 10 | ▶ | sub import { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 10 | my ($class, @opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 10 | my ($schema_manager, $merged_config, @exports) = $class->_initialize(@opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | my $exporter = Sub::Exporter::build_exporter({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | exports => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 10 | ▶ | dump_settings => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | return $merged_config, @exports; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 10 | ▶ | Schema => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | return $schema_manager->schema; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 10 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 10 | ▶ | ResultSet => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 10 | my ($local_class, $name, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 5 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 5 | my $source = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 5 | my $search = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 5 | my $resultset = $schema_manager->schema->resultset($source); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 5 | ▶ | if(my $global_search = $arg->{search}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my @global_search = ref $global_search eq 'ARRAY' ? @$global_search : ($global_search); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | $resultset = $resultset->search(@global_search); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 5 | ▶ | if(my $global_cb = $arg->{exec}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | $resultset = $global_cb->($resultset); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 5 | ▶ | if($search) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 4 | ▶ | my @search = ref $search eq 'ARRAY' ? @$search : ($search, @_); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 4 | $resultset = $resultset->search(@search); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 5 | return $resultset; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 10 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 10 | ▶ | is_result => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=12.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 10 | my ($local_class, $name, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 10 | ▶ | my $global_class = defined $arg->{isa_class} ? $arg->{isa_class} : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $rs = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | my $compare = shift @_ || $global_class || "DBIx::Class"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
shift @_ || $global_class || 'DBIx::Class'
shift @_ or $global_class
MC/DC0%0/2
shift @_ || $global_class || 'DBIx::Class'
shift @_
$global_class
Truth table0%0/3
A or B
A= shift @_B= $global_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | my $message = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | Test::More::isa_ok($rs, $compare, $message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 10 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 10 | ▶ | is_resultset => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 10 | my ($local_class, $name, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 10 | ▶ | my $global_class = defined $arg->{isa_class} ? $arg->{isa_class} : ''; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 11 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 11 | my $rs = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 11 | ▶ | my $compare = shift @_ || $global_class || "DBIx::Class::ResultSet"; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition80%4/5
shift @_ || $global_class || 'DBIx::Class::ResultSet'
shift @_ or $global_class
MC/DC50%1/2
shift @_ || $global_class || 'DBIx::Class::ResultSet'
shift @_
$global_class
Truth table66%2/3
A or B
A= shift @_B= $global_class
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 11 | my $message = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 11 | Test::More::isa_ok($rs, $compare, $message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 10 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 10 | ▶ | eq_result => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 1 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | my ($result1, $result2, $message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | $message = defined $message ? $message : ref($result1) . " equals " . ref($result2); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | ▶ | if( ref($result1) eq ref($result2) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | eq_or_diff2( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | {$result2->get_columns}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | {$result1->get_columns}, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | $message, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | Test::More::fail($message ." :Result arguments not of same class"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 10 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 10 | ▶ | eq_resultset => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 3 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 3 | my ($rs1, $rs2, $message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | $message = defined $message ? $message : ref($rs1) . " equals " . ref($rs2); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 3 | ▶ | if( ref($rs1) eq ref($rs2) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | ($rs1, $rs2) = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 3 | my $me = $_->current_source_alias; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 6 | my @pks = map { "$me.$_"} $_->result_source->primary_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 6 | my @result = $_->search({}, { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | result_class => 'DBIx::Class::ResultClass::HashRefInflator', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | order_by => [@pks], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | })->all; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 6 | [@result]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | } ($rs1, $rs2); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 3 | eq_or_diff2([$rs2],[$rs1],$message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | Test::More::fail($message ." :ResultSet arguments not of same class"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 10 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 10 | ▶ | hri_dump => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 11 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 11 | (shift)->search ({}, { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | result_class => 'DBIx::Class::ResultClass::HashRefInflator' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 10 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 10 | ▶ | fixtures_ok => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 13 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=15 SCAR=29.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 13 | my ($arg, $message) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 13 | ▶ | $message = defined $message ? $message : 'Fixtures Installed'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 13 | ▶ | if ($arg && ref $arg && (ref $arg eq 'CODE')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition83%5/6
$arg and ref $arg and ref $arg eq "CODE"
$arg and ref $arg
MC/DC66%2/3
$arg and ref $arg and ref $arg eq "CODE"
$arg
ref $arg
ref $arg eq "CODE"
Truth table75%3/4
A and B and C
A= $argB= ref $argC= ref $arg eq "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | $arg->($schema_manager->schema); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | ▶ | }; if($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | Test::More::fail($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $schema_manager->builder->diag($@); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | Test::More::pass($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ▶ | } elsif( $arg && ref $arg && (ref $arg eq 'HASH' || ref $arg eq 'ARRAY') ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%6/9
$arg and ref $arg and ref $arg eq "HASH" || ref $arg eq "ARRAY"
$arg and ref $arg
ref $arg eq "HASH" or ref $arg eq "ARRAY"
MC/DC25%1/4
$arg and ref $arg and ref $arg eq "HASH" || ref $arg eq "ARRAY"
$arg
ref $arg
ref $arg eq "HASH"
ref $arg eq "ARRAY"
Truth table60%3/5
A and B and C or D
A= $argB= ref $argC= ref $arg eq "HASH"D= ref $arg eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 7 | my @return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 7 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 7 | @return = $schema_manager->install_fixtures($arg); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 7 | ▶ | }; if($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | Test::More::fail($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $schema_manager->builder->diag($@); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 7 | Test::More::pass($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 7 | return @return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } elsif( $arg ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 5 | ▶ | my @sets = ref $arg ? @$arg : ($arg); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | my @fixtures = $schema_manager->get_fixture_sets(@sets); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | my @return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 5 | foreach my $fixture (@fixtures) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 5 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 5 | push @return, $schema_manager->install_fixtures($fixture); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | ▶ | }; if($@) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | Test::More::fail($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $schema_manager->builder->diag($@); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 5 | Test::More::pass($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 5 | return @return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | Test::More::fail("Can't figure out what fixtures you want"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 10 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 10 | ▶ | is_fields => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=16.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 10 | my ($local_class, $name, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 10 | my @default_fields = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 10 | ▶ | if(defined $arg && ref $arg eq 'HASH' && defined $arg->{fields}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $arg and ref $arg eq "HASH" and defined $arg->{"fields"}
defined $arg and ref $arg eq "HASH"
MC/DC0%0/3
defined $arg and ref $arg eq "HASH" and defined $arg->{"fields"}
defined $arg
ref $arg eq "HASH"
defined $arg->{"fields"}
Truth table25%1/4
A and B and C
A= defined $argB= ref $arg eq "HASH"C= defined $arg->{"fields"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | @default_fields = ref $arg->{fields} ? @{$arg->{fields}} : ($arg->{fields}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 28 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=28 SCAR=34.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 28 | my @args = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 28 | my @fields = @default_fields; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 28 | ▶ | if(!ref($args[0]) || (ref($args[0]) eq 'ARRAY')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not ref $args[0] or ref $args[0] eq "ARRAY"
MC/DC100%2/2
not ref $args[0] or ref $args[0] eq "ARRAY"
not ref $args[0]
ref $args[0] eq "ARRAY"
Truth table100%3/3
not(A) or B
A= not ref $args[0]B= ref $args[0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 27 | my $fields = shift(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 27 | ▶ | @fields = ref $fields ? @$fields : ($fields); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 28 | ▶ | if(Scalar::Util::blessed($args[0]) && | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%3/6
builtin::blessed($args[0]) and $args[0]->isa("DBIx::Class") and not $args[0]->isa("DBIx::Class::ResultSet")
builtin::blessed($args[0]) and $args[0]->isa("DBIx::Class")
MC/DC33%1/3
builtin::blessed($args[0]) and $args[0]->isa("DBIx::Class") and not $args[0]->isa("DBIx::Class::ResultSet")
builtin::blessed($args[0])
$args[0]->isa("DBIx::Class")
not $args[0]->isa("DBIx::Class::ResultSet")
Truth table50%2/4
A and B and not(C)
A= builtin::blessed($args[0])B= $args[0]->isa("DBIx::Class")C= not $args[0]->isa("DBIx::Class::ResultSet")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | $args[0]->isa('DBIx::Class') && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | !$args[0]->isa('DBIx::Class::ResultSet') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 7 | my $result = shift(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 7 | ▶ | unless(@fields) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | my @pks = $result->result_source->primary_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | push @fields, grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 1 | my $field = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 5 | ▶ | $field ne ((grep { $field eq $_ } @pks)[0] || '') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
(grep {$field eq $_;} @pks)[0] || ''
MC/DC100%1/1
(grep {$field eq $_;} @pks)[0] || ''
(grep {$field eq $_;} @pks)[0]
Truth table100%2/2
A
A= (grep {$field eq $_;} @pks)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } ($result->result_source->columns); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 7 | my $compare = shift(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 7 | ▶ | if(ref $compare eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } elsif(ref $compare eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 3 | my @localfields = @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | $compare = {map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 3 | my $value = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 4 | my $key = shift(@localfields); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 4 | $key => $value } @$compare}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 3 | ▶ | Test::More::fail('Too many fields!') if @localfields; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } elsif(!ref $compare) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 2 | my @localfields = @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | $compare = {map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | my $value = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 2 | my $key = shift(@localfields); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 2 | $key => $value } ($compare)}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 2 | ▶ | Test::More::fail('Too many fields!') if @localfields; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 7 | ▶ | my $message = shift(@args) || 'Fields match'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift @args || 'Fields match'
MC/DC100%1/1
shift @args || 'Fields match'
shift @args
Truth table100%2/2
A
A= shift @args
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | my $compare_rs = {map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 7 | ▶ | die "$_ is not an available field" | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | unless $result->can($_); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 12 | $_ => $result->$_ } @fields}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 7 | eq_or_diff2($compare,$compare_rs,$message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 7 | return $compare; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | ▶ | } elsif (Scalar::Util::blessed($args[0]) && $args[0]->isa('DBIx::Class::ResultSet')) { | |||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
builtin::blessed($args[0]) and $args[0]->isa("DBIx::Class::ResultSet")
MC/DC0%0/2
builtin::blessed($args[0]) and $args[0]->isa("DBIx::Class::ResultSet")
builtin::blessed($args[0])
$args[0]->isa("DBIx::Class::ResultSet")
Truth table33%1/3
A and B
A= builtin::blessed($args[0])B= $args[0]->isa("DBIx::Class::ResultSet")
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 21 | my $resultset = shift(@args); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 21 | ▶ | unless(@fields) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | my @pks = $resultset->result_source->primary_columns; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | push @fields, grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $field = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | $field ne ((grep { $field eq $_ } @pks)[0] || '') | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
(grep {$field eq $_;} @pks)[0] || ''
MC/DC0%0/1
(grep {$field eq $_;} @pks)[0] || ''
(grep {$field eq $_;} @pks)[0]
Truth table0%0/2
A
A= (grep {$field eq $_;} @pks)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } ($resultset->result_source->columns); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 21 | my @compare = @{shift(@args)}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 21 | foreach (@compare) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 58 | ▶ | if(!ref $_) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 7 | my @localfields = @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | $_ = {map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 7 | my $value = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 7 | my $key = shift(@localfields); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 7 | $key => $value } ($_)}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 7 | ▶ | Test::More::fail('Too many fields!') if @localfields; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } elsif(ref $_ eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 48 | my @localfields = @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | $_ = {map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 48 | my $value = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 98 | my $key = shift(@localfields); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 98 | $key => $value } (@$_)}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 48 | ▶ | Test::More::fail('Too many fields!') if @localfields; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 21 | ▶ | my $message = shift(@args) || 'Fields match'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @args || 'Fields match'
MC/DC0%0/1
shift @args || 'Fields match'
shift @args
Truth table50%1/2
A
A= shift @args
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 21 | my @resultset = $resultset->search({}, { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | result_class => 'DBIx::Class::ResultClass::HashRefInflator', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | columns => [@fields], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | })->all; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 21 | my %compare_rs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 21 | foreach my $row(@resultset) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 17 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 58 | my $id = Digest::MD5::md5_hex(join('.', map {$row->{$_}} sort keys %$row)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 58 | $compare_rs{$id} = { map { $_,"$row->{$_}"} keys %$row}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 21 | my %compare; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 21 | foreach my $row(@compare) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 17 | ▶ | no warnings 'uninitialized'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 58 | my $id = Digest::MD5::md5_hex(join('.', map {$row->{$_}} sort keys %$row)); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | ## Force comparison stuff in stringy form :( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 58 | $compare{$id} = { map { $_,"$row->{$_}"} keys %$row}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 21 | eq_or_diff2(\%compare,\%compare_rs,$message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 21 | return \@compare; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | die "I'm not sure what to do with your arguments"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 10 | ▶ | reset_schema => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 4 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 4 | ▶ | my $message = shift @_ || 'Schema reset complete'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || 'Schema reset complete'
MC/DC0%0/1
shift @_ || 'Schema reset complete'
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 4 | $schema_manager->reset; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 4 | Test::More::pass($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 10 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 10 | ▶ | cleanup_schema => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 1 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | ▶ | my $message = shift @_ || 'Schema cleanup complete'; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
shift @_ || 'Schema cleanup complete'
MC/DC0%0/1
shift @_ || 'Schema cleanup complete'
shift @_
Truth table50%1/2
A
A= shift @_
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 1 | $schema_manager->cleanup; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 1 | Test::More::pass($message); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 10 | }, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 10 | my $source = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 18 | ▶ | $source => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 18 | my ($local_class, $name, $arg) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 18 | my $resultset = $schema_manager->schema->resultset($source); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 18 | ▶ | if(my $search = $arg->{search}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 2 | ▶ | my @search = ref $search eq 'ARRAY' ? @$search : ($search); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 2 | $resultset = $resultset->search(@search); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 54 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 54 | my $search = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 54 | ▶ | if($search) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 4 | my @search = (); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 4 | ▶ | if(ref $search && ref $search eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $search and ref $search eq "HASH"
MC/DC50%1/2
ref $search and ref $search eq "HASH"
ref $search
ref $search eq "HASH"
Truth table66%2/3
A and B
A= ref $searchB= ref $search eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 2 | @search = ($search, @_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 2 | @search = ({$search, @_}); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 4 | return $resultset->search(@search); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 50 | return $resultset->search_rs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 120 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | } $schema_manager->schema->sources, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | groups => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | resultsets => [$schema_manager->schema->sources], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | into_level => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 10 | $class->$exporter( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | qw/Schema ResultSet is_result is_resultset hri_dump fixtures_ok reset_schema | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | eq_result eq_resultset is_fields dump_settings cleanup_schema /, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | @exports | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 10 | ▶ | sub _initialize { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 10 | my ($class, @opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 10 | my ($config, @exports) = $class->_normalize_opts(@opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 10 | my $merged_config = $class->_prepare_config($config); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 10 | ▶ | if(my $resultsets = delete $merged_config->{resultsets}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 1 | ▶ | if(ref $resultsets eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 1 | push @exports, @$resultsets; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | die '"resultsets" options must be a Array Reference.'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 10 | my $merged_with_fixtures_config = $class->_prepare_fixtures($merged_config); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 10 | my $visitor = Data::Visitor::Callback->new(plain_value=>\&_visit_config_values); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 10 | $visitor->visit($merged_with_fixtures_config); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 10 | my $schema_manager = $class->_initialize_schema($merged_with_fixtures_config); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 10 | $schema_manager, | |||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | $merged_config, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | @exports, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 272 | ▶ | sub _visit_config_values { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_visit_config_values: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 272 | ▶ | return unless $_; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 266 | &_config_substitutions($_); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 266 | ▶ | sub _config_substitutions { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_config_substitutions: called CC=4 SCAR=15.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 266 | my $subs = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | $subs->{ ENV } = | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 1 | ▶ | sub { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=8.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 1 | my ( $v ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 1 | ▶ | if (! defined($ENV{$v})) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | Test::More::fail("Missing environment variable: $v"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | return ''; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 1 | return $ENV{ $v }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 266 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | $subs->{ literal } ||= sub { return $_[ 1 ]; }; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.0
Condition33%1/3
$subs->{"literal"} ||= sub {
return $_[1];
}
MC/DC0%0/2
$subs->{"literal"} ||= sub {
return $_[1];
}
$subs->{"literal"}
sub {
return $_[1];
}
Truth table33%1/3
A ||= B
A= $subs->{"literal"}B= sub {
return $_[1];
}
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 266 | my $subsre = join( '|', keys %$subs ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 266 | for ( @_ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 266 | ▶ | s{__($subsre)(?:\((.+?)\))?__}{ $subs->{ $1 }->( $2 ? split( /,/, $2 ) : () ) }eg; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 13 | ▶ | sub _normalize_opts { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_normalize_opts: called CC=10 SCAR=23.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 13 | my ($class, @opts) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 13 | my ($config, @exports) = ({},()); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 13 | ▶ | if(ref $opts[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 7 | ▶ | if(ref $opts[0] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 7 | $config = shift(@opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | die 'First argument to "use Test::DBIx::Class @args" not properly formed.'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 13 | ▶ | while( my $opt = shift(@opts)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 14 | ▶ | if($opt =~m/^-(.+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | ▶ | if($config->{$1}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | die "$1 already is defined as $config->{$1}"; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 3 | $config->{$1} = shift(@opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 11 | @exports = ($opt, @opts); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 11 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 13 | ▶ | if(my $resultsets = delete $config->{resultsets}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 1 | ▶ | if(ref $resultsets eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 1 | push @exports, @$resultsets; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | die '"resultsets" options must be a Array Reference.'; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 13 | ▶ | @exports = map { ref $_ && ref $_ eq 'ARRAY' ? @$_:$_ } @exports; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $_ and ref $_ eq "ARRAY"
MC/DC0%0/2
ref $_ and ref $_ eq "ARRAY"
ref $_
ref $_ eq "ARRAY"
Truth table66%2/3
A and B
A= ref $_B= ref $_ eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 13 | return ($config, @exports); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 11 | ▶ | sub _prepare_fixtures { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_fixtures: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 11 | my ($class, $config) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 11 | my @dirs; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 11 | ▶ | if(my $fixture_path = delete $config->{fixture_path}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 2 | @dirs = $class->_normalize_config_path( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | $class->_default_fixture_paths, $fixture_path, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 9 | @dirs = $class->_normalize_config_path($class->_default_fixture_paths); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 11 | my @extensions = $class->_allowed_extensions; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | my @files = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 16 | grep { $class->_is_allowed_extension($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 13 | map {Path::Class::dir($_)->children} | |||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 11 | grep { -e $_ } | |||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | @dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 11 | my $fixture_definitions = Config::Any->load_files({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | files => \@files, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | use_ext => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 11 | my %merged_fixtures; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 11 | foreach my $fixture_definition(@$fixture_definitions) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 16 | my ($path, $fixture) = %$fixture_definition; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | ## hack to normalize arrayref fixtures. needs work!!! | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 16 | ▶ | $fixture = ref $fixture eq 'HASH' ? [$fixture] : $fixture; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 16 | my $file = Path::Class::file($path)->basename; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 16 | $file =~s/\..{1,4}$//; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 16 | ▶ | if($merged_fixtures{$file}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 2 | my $old_fixture = $merged_fixtures{$file}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 2 | my $merged_fixture = Hash::Merge::merge($fixture, $old_fixture); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 2 | $merged_fixtures{$file} = $merged_fixture; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 14 | $merged_fixtures{$file} = $fixture; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 11 | ▶ | if(my $old_fixture_sets = delete $config->{fixture_sets}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | ## hack to normalize arrayref fixtures. needs work!!! | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | my %normalized_old_fixture_sets = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 2 | ▶ | ref($old_fixture_sets->{$_}) eq 'HASH' ? ($_, [$old_fixture_sets->{$_}]): ($_, $old_fixture_sets->{$_}); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } keys %$old_fixture_sets; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 2 | my $new_fixture_sets = Hash::Merge::merge(\%normalized_old_fixture_sets, \%merged_fixtures ); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 2 | $config->{fixture_sets} = $new_fixture_sets; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 9 | $config->{fixture_sets} = \%merged_fixtures; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 11 | return $config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 16 | ▶ | sub _is_allowed_extension { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_is_allowed_extension: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 16 | my ($class, $file) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 16 | my @extensions = $class->_allowed_extensions; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 16 | foreach my $extension(@extensions) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 96 | ▶ | if($file =~ m/\.$extension$/) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 16 | return $file; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 12 | ▶ | sub _prepare_config { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_config: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 12 | my ($class, $config) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 12 | ▶ | if(my $extra_config = delete $config->{config_path}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 3 | my @config_data = $class->_load_via_config_any($extra_config); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 3 | foreach my $config_datum(reverse @config_data) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 8 | $config = Hash::Merge::merge($config, $config_datum); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 9 | my @config_data = $class->_load_via_config_any(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 9 | foreach my $config_datum(reverse @config_data) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 9 | $config = Hash::Merge::merge($config, $config_datum); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 12 | ▶ | if(my $post_config = delete $config->{config_path}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 2 | my @post_config_paths = $class->_normalize_external_paths($post_config); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 2 | my @extensions = $class->_allowed_extensions; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 30 | my @post_config_files = grep { -e $_} map { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 2 | my $path = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 2 | $ENV{TEST_DBIC_CONFIG_SUFFIX} ? | |||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 20 | ▶ | ("$path.$_", "$path$ENV{TEST_DBIC_CONFIG_SUFFIX}.$_") : | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | ("$path.$_"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | } @extensions; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 2 | ▶ | my @local_path = ref $_ ? @$_ : ($_); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 2 | Path::Class::file(@local_path); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } @post_config_paths; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 2 | my $post_config = $class->_config_any_load_files(@post_config_files); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 2 | foreach my $config_datum(reverse map { values %$_ } @$post_config) { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 2 | $config = Hash::Merge::merge($config, $config_datum); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 12 | return $config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 13 | ▶ | sub _load_via_config_any { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_load_via_config_any: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 13 | my ($class, $extra_paths) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 13 | my @files = $class->_valid_config_files($class->_default_paths, $extra_paths); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 13 | my $config = $class->_config_any_load_files(@files); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 13 | my @config_data = map { values %$_ } @$config; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 13 | return @config_data; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 15 | ▶ | sub _config_any_load_files { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_config_any_load_files: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 15 | my ($class, @files) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 15 | return Config::Any->load_files({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | files => \@files, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | use_ext => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 15 | ▶ | sub _valid_config_files { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_valid_config_files: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 15 | my ($class, $default_paths, $extra_paths) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 15 | my @extensions = $class->_allowed_extensions; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 15 | my @paths = $class->_normalize_config_path($default_paths, $extra_paths); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 410 | my @config_files = grep { -e $_} map { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 15 | my $path = $_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | map { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 35 | $ENV{TEST_DBIC_CONFIG_SUFFIX} ? | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 350 | ▶ | ("$path.$_", "$path$ENV{TEST_DBIC_CONFIG_SUFFIX}.$_") : | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | ("$path.$_"); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | } @extensions; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } @paths; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 15 | return @config_files; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 44 | ▶ | sub _allowed_extensions { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_allowed_extensions: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 44 | return @{ Config::Any->extensions }; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 11 | ▶ | sub _normalize_external_paths { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_normalize_external_paths: called CC=5 SCAR=16.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 11 | my ($class, $extra_paths) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 11 | my @extra_paths; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 11 | ▶ | if(!ref $extra_paths) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | @extra_paths = ([$extra_paths]); ## "t/etc" => (["t/etc"]) | |||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } elsif(ref $extra_paths eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 11 | ▶ | if(!ref $extra_paths->[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 4 | @extra_paths = ($extra_paths); ## [qw( t etc )] | |||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } elsif( ref $extra_paths->[0] eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 7 | @extra_paths = @$extra_paths; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 11 | return @extra_paths; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 27 | ▶ | sub _normalize_config_path { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_normalize_config_path: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 27 | my ($class, $default_paths, $extra_paths) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 27 | ▶ | if(defined $extra_paths) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 23 | ▶ | my @extra_paths = map { "$_" eq "+" ? @$default_paths : $_ } map { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 9 | ▶ | my @local_path = ref $_ ? @$_ : ($_); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 23 | Path::Class::file(@local_path); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } $class->_normalize_external_paths($extra_paths); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 9 | return @extra_paths; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 18 | return @$default_paths; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 25 | ▶ | sub _script_path { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_script_path: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 25 | return ($0 =~m/^(.+)\.t$/)[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 11 | ▶ | sub _default_fixture_paths { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_fixture_paths: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 11 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 11 | my $script_path = Path::Class::file($class->_script_path); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 11 | my $script_dir = $script_path->dir; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 11 | my @dir_parts = $script_dir->dir_list(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 11 | Path::Class::file(qw/t etc fixtures/), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | Path::Class::file(qw/t etc fixtures/, @dir_parts, $script_path->basename), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 14 | ▶ | sub _default_paths { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_paths: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 14 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 14 | my $script_path = Path::Class::file($class->_script_path); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 14 | my $script_dir = $script_path->dir; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 14 | my @dir_parts = $script_dir->dir_list(1); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 14 | ▶ | if( | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$script_path->basename eq "schema" and scalar @dir_parts == 0
MC/DC0%0/2
$script_path->basename eq "schema" and scalar @dir_parts == 0
$script_path->basename eq "schema"
scalar @dir_parts == 0
Truth table33%1/3
A and B
A= $script_path->basename eq "schema"B= scalar @dir_parts == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | $script_path->basename eq 'schema' && | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | (scalar(@dir_parts) == 0 ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 0 | Path::Class::file(qw/t etc schema/), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 14 | Path::Class::file(qw/t etc schema/), | |||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | Path::Class::file(qw/t etc /, @dir_parts, $script_path->basename), | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 20 | ▶ | sub _initialize_schema { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize_schema: called CC=5 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 20 | my $class = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 20 | my $config = shift @_; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 20 | my $builder = __PACKAGE__->builder; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 20 | my $fail_on_schema_break = delete $config->{fail_on_schema_break}; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 20 | my $schema_manager; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 20 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 20 | $schema_manager = Test::DBIx::Class::SchemaManager->initialize_schema({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | %$config, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | builder => $builder, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 20 | ▶ | }; if ($@ or !$schema_manager) { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ or not $schema_manager
MC/DC0%0/2
$@ or not $schema_manager
$@
not $schema_manager
Truth table33%1/3
A or not(B)
A= $@B= not $schema_manager
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | Test::More::diag("Can't initialize a schema with the given configuration"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | Test::More::diag("Returned Error: ".$@) if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | Test::More::diag( | |||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | Test::More::explain("configuration: " => $config) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | # FIXME: make this optional. | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | ▶ | if($fail_on_schema_break) | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 0 | Test::More::fail("Failed remaining tests since we don't have a schema"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 0 | Test::More::done_testing(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | $builder->finalize(); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | exit(0); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | else | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | $builder->skip_all("Skipping remaining tests since we don't have a schema"); | |||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 20 | return $schema_manager | |||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||