DBICx::...Subclass(3)
π DBICx::...Subclass(3) β bestie edition π
okay so this is the DBICx::...Subclass(3) page from User Contributed Perl Documentation, and itβs literally here to let you build a test database class thatβs yours. No cap. π¦
π NAME π
DBICx::TestDatabase::Subclass - a DBICx::TestDatabase you can add your own methods to. Thatβs the whole assignment, bestie. π
β¨ SYNOPSIS β¨
Your test database subclass:
package MyApp::TestDatabase
use 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::foo
my $bars = $schema->resultset('Bar'); # MyApp::Schema::resultset
πΈ DESCRIPTION πΈ
Sometimes DBICx::TestDatabase doesn't give you enough control over the object returned. This module lets you create a custom test database class. Itβs giving βI want it my wayβ and honestly? Iconic. π«Ά
π 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;
}
π SEE ALSO π
If you want a simple test database based on a DBIC schema, just use DBICx::TestDatabase. Easy. Slay. π
π AUTHOR π
Jonathan Rockway "<jrockway@cpan.org>"
π LICENSE π
Copyright (c) 2007 Jonathan Rockway.
This program is free software. You may use, modify, and redistribute it under the same terms as Perl itself.
thatβs the whole page, bestie β source/version perl v5.42.0, dated 2017-10-12, manual name DBICx::...Subclass(3). πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-DBICx-TestDatabase 0.05-bp160.1.10 Β· Artistic-1.0 or GPL-1.0+
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms