PopulateMore/Test/Schema.pm

filter: Statementstmt 88.8% 16 / 18 Branchbran n/a Conditioncond 42.8% 3 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 71.4% 5 / 7 Podpod 100% 4 / 4 totaltotal 70.0% 28 / 40 CC 4 SCAR 10.3
CC
4
Cov
76%
connect_and_setup
5.0
cleanup
2.0
DESTROY
2.0
CRAP 2.8
« PopulateMore/Inflator/Find.pm ↑ Summary PopulateMore/Visitor.pm »
1 package # hide from PAUSE
2 DBIx::Class::Schema::PopulateMore::Test::Schema;
3  
4 3 ▶use Path::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use parent 'DBIx::Class::Schema';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 =head1 NAME
9  
10 DBIx::Class::Schema::PopulateMore::Test::Schema; Test Schema
11  
12 =head1 DESCRIPTION
13  
14 Defines the base case for loading DBIC Schemas. This schema currently defines
15 three sources, Person, FriendList, and Gender
16  
17 =head1 PACKAGE METHODS
18  
19 The following is a list of package methods declared with this class.
20  
21 =head2 load_components
22  
23 Load the components
24  
25 =cut
26  
27 3 __PACKAGE__->load_components(qw/
28 Schema::PopulateMore
29 /);
30  
31  
32 =head2 load_namespaces
33  
34 Automatically load the classes and resultsets from their default namespaces.
35  
36 =cut
37  
38 3 __PACKAGE__->load_namespaces(
39 default_resultset_class => 'ResultSet',
40 );
41  
42  
43 =head1 ATTRIBUTES
44  
45 This class defines the following attributes.
46  
47 =head1 METHODS
48  
49 This module declares the following methods
50  
51 =head2 connect_and_setup
52  
53 Creates a schema, deploys a database and sets the testing data. By default we
54 use a L<DBD::SQLite> database created
55  
56 =cut
57  
58 sub connect_and_setup {
59 2 ▶ my $class = shift @_;
Subroutine connect_and_setup: called CC=4 SCAR=16.1
Pod documented
60
61 my ($dsn, $user, $pass) = (
62 $ENV{DBIC_POPULATE_DSN} || $class->default_dsn,
63 $ENV{DBIC_POPULATE_USER} || '',
64 2 ▶ $ENV{DBIC_POPULATE_PASS} || '',
Condition42%3/7
$ENV{'DBIC_POPULATE_DSN'} || $class->default_dsn
l!l&&r!l&&!r
020
$ENV{'DBIC_POPULATE_USER'} || ''
l!l
02
$ENV{'DBIC_POPULATE_PASS'} || ''
l!l
02
MC/DC0%0/2
$ENV{'DBIC_POPULATE_DSN'} || $class->default_dsn
$ENV{'DBIC_POPULATE_DSN'} $class->default_dsn
MC/DC0%0/1
$ENV{'DBIC_POPULATE_USER'} || ''
$ENV{'DBIC_POPULATE_USER'}
MC/DC0%0/1
$ENV{'DBIC_POPULATE_PASS'} || ''
$ENV{'DBIC_POPULATE_PASS'}
Truth table33%1/3
A || B
A= $ENV{'DBIC_POPULATE_DSN'}B= $class->default_dsn
ABresult
1X1
011
000
Truth table50%1/2
A
A= $ENV{'DBIC_POPULATE_USER'}
Aresult
11
00
Truth table50%1/2
A
A= $ENV{'DBIC_POPULATE_PASS'}
Aresult
11
00
65 );
66
67 2 return $class
68 ->connect($dsn, $user, $pass, { AutoCommit => 1 })
69 ->setup;
70 }
71  
72 =head2 default_dsn
73  
74 returns a dsn string, suitable for passing to L<DBD::SQLite>, creating the
75 database as a temporary file.
76  
77 =cut
78  
79 sub default_dsn
80 {
81 2 ▶ return "dbi:SQLite:dbname=:memory:";
Subroutine default_dsn: called CC=1 SCAR=0.0
Pod documented
82 }
83  
84 =head2 setup
85  
86 deploy a database and populate it with the initial data
87  
88 =cut
89  
90 sub setup {
91 2 ▶ my $self = shift @_;
Subroutine setup: called CC=1 SCAR=0.0
Pod documented
92 2 $self->deploy();
93 2 return $self;
94 }
95  
96 =head2 cleanup
97  
98 cleanup any temporary files
99  
100 =cut
101  
102 sub cleanup {
103 0 ▶ my $self = shift @_;
Subroutine cleanup: not called CC=1 SCAR=6.9
Pod documented
104 }
105  
106 sub DESTROY {
107 0 ▶ (shift)->cleanup;
Subroutine DESTROY: not called CC=1 SCAR=6.9
108 }
109  
110 =head1 AUTHOR
111  
112 Please see L<DBIx::Class::Schema::PopulateMore> For authorship information
113  
114 =head1 LICENSE
115  
116 Please see L<DBIx::Class::Schema::PopulateMore> For licensing terms.
117  
118 =cut
119  
120  
121  
122 3 1;
« PopulateMore/Inflator/Find.pm ↑ Summary PopulateMore/Visitor.pm »