Debian Codegraph @

lib/DBIx/Class/Schema/PopulateMore/Test/Schema.pm

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 package # hide from PAUSE
2 DBIx::Class::Schema::PopulateMore::Test::Schema;
3
4 use Path::Class;
5 use parent 'DBIx::Class::Schema';
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 __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 __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 my $class = shift @_;
60
61 my ($dsn, $user, $pass) = (
62 $ENV{DBIC_POPULATE_DSN} || $class->default_dsn,
63 $ENV{DBIC_POPULATE_USER} || '',
64 $ENV{DBIC_POPULATE_PASS} || '',
65 );
66
67 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 return "dbi:SQLite:dbname=:memory:";
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 my $self = shift @_;
92 $self->deploy();
93 return $self;
94 }
95
96 =head2 cleanup
97
98 cleanup any temporary files
99
100 =cut
101
102 sub cleanup {
103 my $self = shift @_;
104 }
105
106 sub DESTROY {
107 (shift)->cleanup;
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 1;