add TODO on constraint check
[dbsrgits/DBIx-Class.git] / t / 99schema_roles.t
CommitLineData
62fa8aec 1use strict;
2use warnings;
3use lib qw(t/lib);
4use Test::More;
5
6BEGIN {
7 eval "use Moose";
8 plan $@
9 ? ( skip_all => 'needs Moose for testing' )
10 : ( tests => 11 );
11}
12
13=head1 NAME
14
15DBICNGTest::Schema::ResultSet:Person; Example Resultset
16
17=head1 DESCRIPTION
18
19Tests for the various Schema roles you can either use or apply
20
21=head1 TESTS
22
23=head2 initialize database
24
25create a schema and setup
26
27=cut
28
29use_ok 'DBICNGTest::Schema';
30
31ok my $db_file = Path::Class::File->new(qw/t var DBIxClassNG.db/)
32 => 'created a path for the test database';
33
34ok my $schema = DBICNGTest::Schema->connect_and_setup($db_file)
35 => 'Created a good Schema';
36
37is ref $schema->source('Person'), 'DBIx::Class::ResultSource::Table'
38 => 'Found Expected Person Source';
39
40is $schema->resultset('Person')->count, 5
41 => 'Got the correct number of people';
42
43is $schema->resultset('Gender')->count, 3
44 => 'Got the correct number of genders';
45
46
47=head2 check query counter
48
49Test the query counter role
50
51=cut
52
53use_ok 'DBIx::Class::Storage::DBI::Role::QueryCounter';
54DBIx::Class::Storage::DBI::Role::QueryCounter->meta->apply($schema->storage);
55
56is $schema->storage->query_count, 0
57 => 'Query Count is zero';
58
59is $schema->resultset('Person')->find(1)->name, 'john'
60 => 'Found John!';
61
62is $schema->resultset('Person')->find(2)->name, 'dan'
63 => 'Found Dan!';
64
65is $schema->storage->query_count, 2
66 => 'Query Count is zero';
67
68
69=head2 cleanup
70
71Cleanup after ourselves
72
73=cut
74
75unlink $db_file;
76
77
78=head1 AUTHORS
79
80See L<DBIx::Class> for more information regarding authors.
81
82=head1 LICENSE
83
84You may distribute this code under the same terms as Perl itself.
85
86=cut