1DBICx::TestDatabase(3)User Contributed Perl DocumentationDBICx::TestDatabase(3)
2
3
4
6 DBICx::TestDatabase - create a temporary database from a
7 DBIx::Class::Schema
8
10 Given a DBIx::Class::Schema at "MyApp::Schema", create a test database
11 like this:
12
13 use DBICx::TestDatabase;
14 my $schema = DBICx::TestDatabase->new('MyApp::Schema');
15
16 Then you can use $schema normally:
17
18 $schema->resultset('Blah')->create({ blah => '123' });
19
20 When your program exits, the temporary database will go away.
21
23 This module creates a temporary SQLite database, deploys your DBIC
24 schema, and then connects to it. This lets you easily test your DBIC
25 schema. Since you have a fresh database for every test, you don't have
26 to worry about cleaning up after your tests, ordering of tests
27 affecting failure, etc.
28
30 new($schema)
31 Loads $schema and returns a connection to it.
32
33 connect
34 Alias for new.
35
37 You can control the behavior of this module at runtime by setting
38 environment variables.
39
40 DBIC_KEEP_TEST
41 If this variable is true, then the test database will not be deleted at
42 "END" time. Instead, a message containing the paths of the test
43 databases will be printed.
44
45 This is good if you want to look at the database your test generated,
46 for debugging.
47
49 Jonathan Rockway "<jrockway@cpan.org>"
50
52 Copyright (c) 2007 Jonathan Rockway.
53
54 This program is free software. You may use, modify, and redistribute
55 it under the same terms as Perl itself.
56
57
58
59perl v5.12.1 2008-07-07 DBICx::TestDatabase(3)