Test::DBUnit::Generator - dbunit dataset generator
use Test::DBUnit::Generator; my $connection = DBIx::Connection->new( name => 'test', dsn => $ENV{DB_TEST_CONNECTION}, username => $ENV{DB_TEST_USERNAME}, password => $ENV{DB_TEST_PASSWORD}, ); my $generator = Test::DBUnit::Generator->new( connection => $connection, datasets => { emp => 'SELECT * FROM emp', dept => 'SELECT * FROM demp', }, ); print $generator->xml_dataset; print $generator->dataset; pritn $generator->schema_validator( has_table => 1, has_columns => 1, has_pk => 1, has_fk => 1, has_index => 1, );
This class generates xml or perl test datasets based on passed in sql. Additionally it can generate schema validator code.
Specifies order of the dataset in the generation result.
my $generator = Test::DBUnit::Generator->new( connection => $connection, datasets_order => ['emp', 'dept'], datasets => { emp => 'SELECT * FROM emp', dept => 'SELECT * FROM demp', }, );
Returns xml content that contains dataset
Generated dataset as perl code
Generates schema validation code. Takes the following options as paramters:
has_table => 1, has_columns => 1, has_pk => 1, has_fk => 1, has_index => 1,
Returns dataset structure
To install Test::DBUnit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::DBUnit
CPAN shell
perl -MCPAN -e shell install Test::DBUnit
For more information on module installation, please visit the detailed CPAN module installation guide.