DBICx::TestDatabase::Subclass3pm
A dbicx::testdatabase you can add your own methods to
Usage
Your test database subclass:
package MyApp::TestDatabaseuse base qw(DBICx::TestDatabase::Subclass MyApp::Schema);sub foo {my $self = shift;return $self->resultset('Foo')->create({ foo => 'bar' });}
Later:
use MyApp::TestDatabase;my $schema = MyApp::TestDatabase->connect;my $foo_row = $schema->foo; # MyApp::TestDatabase::foomy $bars = $schema->resultset('Bar'); # MyApp::Schema::resultset
Overview
Sometimes DBICx::TestDatabase doesn't give you enough control over the object returned. This module lets you create a custom test database class.
Methods
connect
This method creates the temporary database and returns the connection. If your subclass needs to change the way connect works, do something like this:
sub connect {my ($class) = @_;say 'This happens before we create the test database.';my $schema = $class->next::method;say '$schema is the temporary test database';return $schema;}
Releases
9 releases since Debian 5.0 (Lenny); the text changed 4 times.