test_lib/DB/Introspector/RelInspectTest.pm

filter: Statementstmt 25.0% 10 / 40 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 0.0% 0 / 2 totaltotal 27.6% 13 / 47 CC 2 SCAR 10.4
CC
2
Cov
25%
test_find_mapped_paths_between_tables
6.0
test_find_path_between_two_tables
2.0
BEGIN
1.0
CRAP 2.8
« blib/lib/DB/Introspector/Base/Index.pm ↑ Summary test_lib/DB/IntrospectorTest.pm »
1 package DB::Introspector::RelInspectTest;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base qw( DB::IntrospectorBaseTest );
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use DB::Introspector::Util::RelInspect;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 0 ▶sub test_find_mapped_paths_between_tables {
Subroutine test_find_mapped_paths_between_tables: not called CC=2 SCAR=17.9
Pod undocumented
10 0 my $self = shift;
11  
12 0 my $users = $self->_introspector->find_table("users");
13 0 my $grouped_user_images =
14 $self->_introspector->find_table("grouped_user_images");
15  
16 0 $self->assert( defined $users, "table users is not defined" );
17 0 $self->assert( defined $grouped_user_images,
18 "table grouped_user_images is not defined" );
19  
20 0 my $paths = DB::Introspector::Util::RelInspect
21 ->find_mapped_paths_between_tables( $users, $grouped_user_images);
22  
23 0 $self->assert( defined $paths, "paths is undefined" );
24 0 $self->assert( @$paths == 1, "path length is ".@$paths." expected 1" );
25  
26  
27 0 my ($path) = @$paths;
28 0 $self->assert( defined $path, "path is undefined" );
29 0 $self->assert( $path->head_table->name eq $users->name,
30 "invalid table name found " . $path->head_table->name );
31  
32 0 $self->assert( $path->tail_table->name eq $grouped_user_images->name,
33 "invalid table name found " . $path->tail_table->name );
34  
35 0 $self->assert( $path->length == 2,
36 "path length is " . $path->length . " when expected 2" );
37  
38  
39 0 my @expected_head_columns = qw( user_id );
40 0 my @head_columns = $path->head_columns;
41  
42 0 foreach my $index (0..$#expected_head_columns) {
43 0 $self->assert(
44 $expected_head_columns[$index] eq $head_columns[$index],
45 "expected $expected_head_columns[$index] found $head_columns[$index]");
46 }
47 }
48  
49 0 ▶sub test_find_path_between_two_tables {
Subroutine test_find_path_between_two_tables: not called CC=1 SCAR=6.9
Pod undocumented
50 0 my $self = shift;
51  
52 0 my $users = $self->_introspector->find_table("users");
53 0 my $groups = $self->_introspector->find_table("groups");
54  
55 0 $self->assert( defined $users, "table users is not defined" );
56 0 $self->assert( defined $groups, "table groups is not defined" );
57  
58 0 my $paths = DB::Introspector::Util::RelInspect
59 ->find_paths_between_two_tables( $users, $groups);
60  
61 0 $self->assert( defined $paths, "paths is undefined" );
62 0 $self->assert( @$paths == 1, "path length is ".@$paths." expected 1" );
63  
64  
65 0 my ($path) = @$paths;
66 0 $self->assert( defined $path, "path is undefined" );
67  
68 0 $self->assert( $path->length == 2,
69 "path length is " . $path->length . " when expected 2" );
70  
71 0 $self->assert( $path->head_table->name eq $users->name,
72 "invalid table name found " . $path->head_table->name );
73  
74 0 $self->assert( $path->tail_table->name eq $groups->name,
75 "invalid table name found " . $path->tail_table->name );
76  
77  
78 }
79  
80 1 1;
« blib/lib/DB/Introspector/Base/Index.pm ↑ Summary test_lib/DB/IntrospectorTest.pm »