1Test::Database::Driver(U3s)er Contributed Perl DocumentatTieosnt::Database::Driver(3)
2
3
4

NAME

6       Test::Database::Driver - Base class for Test::Database drivers
7

SYNOPSIS

9           package Test::Database::Driver::MyDatabase;
10           use strict;
11           use warnings;
12
13           use Test::Database::Driver;
14           our @ISA = qw( Test::Database::Driver );
15
16           sub _version {
17               my ($class) = @_;
18               ...;
19               return $version;
20           }
21
22           sub create_database {
23               my ( $self ) = @_;
24               ...;
25               return $handle;
26           }
27
28           sub drop_database {
29               my ( $self, $name ) = @_;
30               ...;
31           }
32
33           sub databases {
34               my ($self) = @_;
35               ...;
36               return @databases;
37           }
38

DESCRIPTION

40       "Test::Database::Driver" is a base class for creating "Test::Database"
41       drivers.
42

METHODS

44       The class provides the following methods:
45
46       new( %args )
47           Create a new "Test::Database::Driver" object.
48
49           If called as "Test::Database::Driver->new()", requires a "driver"
50           parameter to define the actual object class.
51
52       make_handle()
53           Create a new "Test::Database::Handle" object, attached to an
54           existing database or to a newly created one.
55
56           The decision whether to create a new database or not is made by
57           "Test::Database::Driver" based on the information in the mapper.
58           See "TEMPORARY STORAGE ORGANIZATION" for details.
59
60       make_dsn( %args )
61           Return a Data Source Name based on the driver's DSN, with the
62           key/value pairs contained in %args as additional parameters.
63
64           This is typically used by "dsn()" to make a DSN for a specific
65           database, based on the driver's DSN.
66
67       name()
68       dbd()
69           The driver's short name (everything after
70           "Test::Database::Driver::").
71
72       base_dir()
73           The directory where the driver should store all the files for its
74           databases, if needed. Typically used by file-based database
75           drivers.
76
77       version()
78           "version" object representing the version of the underlying
79           database enginge.  This object is build with the return value of
80           "_version()".
81
82       version_string()
83           Version string representing the version of the underlying database
84           enginge.  This string is the actual return value of "_version()".
85
86       dbd_version()
87           The version of the DBD used to connect to the database engine, as
88           returned by "VERSION()".
89
90       driver_dsn()
91           Return a driver Data Source Name, sufficient to connect to the
92           database engine without specifying an actual database.
93
94       username()
95           Return the connection username.
96
97       password()
98           Return the connection password.
99
100       connection_info()
101           Return the connection information triplet ("driver_dsn",
102           "username", "password").
103
104       version_matches( $request )
105           Return a boolean indicating if the driver's version matches the
106           version constraints in the given request (see Test::Database
107           documentation's section about requests).
108
109       The class also provides a few helpful commands that may be useful for
110       driver authors:
111
112       available_dbname()
113           Return an unused database name that can be used to create a new
114           database for the driver.
115
116       dsn( $dbname )
117           Build a Data Source Name  for the database with the given $dbname,
118           based on the driver's DSN.
119

WRITING A DRIVER FOR YOUR DATABASE OF CHOICE

121       The SYNOPSIS contains a good template for writing a
122       "Test::Database::Driver" class.
123
124       Creating a driver requires writing the following methods:
125
126       _version()
127           Return the version of the underlying database engine.
128
129       create_database( $name )
130           Create the database for the corresponding DBD driver.
131
132           Return a "Test::Database::Handle" in case of success, and nothing
133           in case of failure to create the database.
134
135       drop_database( $name )
136           Drop the database named $name.
137
138       Some methods have defaults implementations in "Test::Database::Driver",
139       but those can be overridden in the derived class:
140
141       is_filebased()
142           Return a boolean value indicating if the database engine is file-
143           based or not, i.e. if all the database information is stored in a
144           file or a directory, and no external database server is needed.
145
146       databases()
147           Return the names of all existing databases for this driver as a
148           list (the default implementation is only valid for file-based
149           drivers).
150

TEMPORARY STORAGE ORGANIZATION

152       Subclasses of "Test::Database::Driver" store useful information in the
153       system's temporary directory, under a directory named
154       Test-Database-$user ($user being the current user's name).
155
156       That directory contains the following files:
157
158       database files
159           The database files and directories created by file-based drivers
160           controlled by "Test::Database" are stored here, under names
161           matching tdd_DRIVER_N, where DRIVER is the lowercased name of the
162           driver and N is a number.
163
164       the mapping.yml file
165           A YAML file containing a "cwd()" / database name mapping, to enable
166           a given test suite to receive the same database handles in all the
167           test scripts that call the "Test::Database-"handles()> method.
168

AUTHOR

170       Philippe Bruhat (BooK), "<book@cpan.org>"
171
173       Copyright 2008-2010 Philippe Bruhat (BooK), all rights reserved.
174

LICENSE

176       This module is free software; you can redistribute it and/or modify it
177       under the same terms as Perl itself.
178
179
180
181perl v5.12.3                      2011-03-15         Test::Database::Driver(3)
Impressum