9 ? ( skip_all => 'needs Moose for testing' )
15 DBICNGTest::Schema::ResultSet:Person; Example Resultset
19 Tests for the various Schema roles you can either use or apply
23 =head2 initialize database
25 create a schema and setup
29 use_ok 'DBICNGTest::Schema';
31 ok my $db_file = Path::Class::File->new(qw/t var DBIxClassNG.db/)
32 => 'created a path for the test database';
34 ok my $schema = DBICNGTest::Schema->connect_and_setup($db_file)
35 => 'Created a good Schema';
37 is ref $schema->source('Person'), 'DBIx::Class::ResultSource::Table'
38 => 'Found Expected Person Source';
40 is $schema->resultset('Person')->count, 5
41 => 'Got the correct number of people';
43 is $schema->resultset('Gender')->count, 3
44 => 'Got the correct number of genders';
47 =head2 check query counter
49 Test the query counter role
53 use_ok 'DBIx::Class::Storage::DBI::Role::QueryCounter';
54 DBIx::Class::Storage::DBI::Role::QueryCounter->meta->apply($schema->storage);
56 is $schema->storage->query_count, 0
57 => 'Query Count is zero';
59 is $schema->resultset('Person')->find(1)->name, 'john'
62 is $schema->resultset('Person')->find(2)->name, 'dan'
65 is $schema->storage->query_count, 2
66 => 'Query Count is zero';
71 Cleanup after ourselves
80 See L<DBIx::Class> for more information regarding authors.
84 You may distribute this code under the same terms as Perl itself.