File Coverage

Class/DBI/FormBuilder/DBI/Test.pm
Criterion Covered Total %
statement 29 31 93.5
branch n/a
condition n/a
subroutine 11 13 84.6
pod n/a
total 40 44 90.9


line stmt bran cond sub pod time code
1             {
2             package Class::DBI::FormBuilder::DBI::Test;
3 30     30   1514143 use base 'Class::DBI';
  30         87  
  30         108306  
4 30     30   4123343 use Class::DBI::FormBuilder PrettyPrint => 1;
  30         108  
  30         202  
5             # use the db set up in 01.create.t
6             Class::DBI::FormBuilder::DBI::Test->set_db("Main", "dbi:SQLite2:dbname=test.db");
7             }
8              
9             { # might_have
10             package Job;
11 30     30   468 use base 'Class::DBI::FormBuilder::DBI::Test';
  30         62  
  30         6205  
12             Job->table( 'job' );
13             Job->columns( All => qw/id person jobtitle employer salary/ );
14             Job->columns( Stringify => qw/jobtitle/ );
15             Job->has_a( person => 'Person' );
16             }
17            
18             { # has_a
19             package Town;
20 30     30   163 use base 'Class::DBI::FormBuilder::DBI::Test';
  30         54  
  30         4280  
21             #Town->form_builder_defaults( { smartness => 3 } );
22             Town->table("town");
23             Town->columns(All => qw/id name pop lat long country/);
24             Town->columns(Stringify => qw/name/);
25             }
26              
27             { # has_many
28             # this one must be declared before Person, because Person will
29             # examine the has_a in Toy when setting up its has_many toys.
30             package CDBIFB::Toy;
31 30     30   227 use base 'Class::DBI::FormBuilder::DBI::Test';
  30         73  
  30         4789  
32             CDBIFB::Toy->table('toy');
33             CDBIFB::Toy->columns( All => qw/id person name descr/ );
34             CDBIFB::Toy->columns( Stringify => qw/name/ );
35             CDBIFB::Toy->has_a( person => 'Person' );
36             }
37              
38             {
39             package Person;
40 30     30   164 use base 'Class::DBI::FormBuilder::DBI::Test';
  30         68  
  30         14039  
41             #Person->form_builder_defaults( { smartness => 3 } );
42             Person->table("person");
43             Person->columns(All => qw/id name town street/);
44             Person->columns(Stringify => qw/name/);
45             Person->has_a( town => 'Town' );
46             Person->has_many( toys => 'CDBIFB::Toy' );
47             Person->might_have( job => Job => qw/jobtitle employer salary/ );
48             }
49              
50             {
51             package Wackypk;
52 30     30   189 use base 'Class::DBI::FormBuilder::DBI::Test';
  30         52  
  30         6322  
53             Wackypk->table("wackypk");
54             # wooble is the pk
55             Wackypk->columns(All => qw/flooble wooble flump poo/);
56             Wackypk->columns(Primary => 'wooble'); # or put wooble 1st in the list above
57             }
58              
59             {
60             package CDBIFB::Alias;
61 30     30   182 use base 'Class::DBI::FormBuilder::DBI::Test';
  30         93  
  30         15075  
62             CDBIFB::Alias->table( 'alias' );
63             CDBIFB::Alias->columns(All => qw/id colour fruit town/);
64             CDBIFB::Alias->columns(Stringify => 'fruit' );
65            
66             CDBIFB::Alias->has_a( town => 'Town' );
67            
68             CDBIFB::Alias->has_many( alias_has_many => 'AliasHasMany' );
69             CDBIFB::Alias->might_have( job => Job => qw/jobtitle employer salary/ );
70            
71            
72 0     0   0 sub accessor_name { "get_$_[1]" } # deprecated somewhere
73 0     0   0 sub mutator_name { "set_$_[1]" } # deprecated somewhere
74 150     150   68141 sub accessor_name_for { "get_$_[1]" }
75 150     150   4727 sub mutator_name_for { "set_$_[1]" }
76             }
77              
78             {
79             package AliasHasMany;
80 30     30   174 use base 'Class::DBI::FormBuilder::DBI::Test';
  30         63  
  30         5043  
81             AliasHasMany->table( 'alias_has_many' );
82             AliasHasMany->columns( All => qw/id alias foo/ );
83             AliasHasMany->columns( Stringify => 'foo' );
84             AliasHasMany->has_a( alias => 'CDBIFB::Alias' );
85             }
86            
87            
88             1;