GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
DBICx::TestDatabase::Subclass(3) User Contributed Perl Documentation DBICx::TestDatabase::Subclass(3)

DBICx::TestDatabase::Subclass - a DBICx::TestDatabase you can add your own methods to

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

Sometimes DBICx::TestDatabase doesn't give you enough control over the object returned. This module lets you create a custom test database class.

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;
    }

If you want a simple test database based on a DBIC schema, just use DBICx::TestDatabase.

Jonathan Rockway "<jrockway@cpan.org>"

Copyright (c) 2007 Jonathan Rockway.

This program is free software. You may use, modify, and redistribute it under the same terms as Perl itself.

2013-07-29 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.