X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fbasic.t;fp=t%2Fbasic.t;h=f3c3f8112abff7b4dc7a8dfe43009db240b6f808;hb=731e8b3e4dc45f47f80dfb89f34fac156fbe526f;hp=0000000000000000000000000000000000000000;hpb=7f92017a08dce9905018015070808338e02cf966;p=dbsrgits%2FDBIx-Class-Schema-ResultSetAccessors.git diff --git a/t/basic.t b/t/basic.t new file mode 100644 index 0000000..f3c3f81 --- /dev/null +++ b/t/basic.t @@ -0,0 +1,35 @@ +# DBIx::Class::Schema::ResultSetAccessors - check module loading and create testing directory + +use strict; +use warnings; + +use lib qw(t/lib); + +use Test::More; +use Test::Exception; + +BEGIN { + use_ok('MyApp1::Schema'); +} + +ok my $schema1 = MyApp1::Schema->connect('dbi:SQLite:dbname=:memory:', '', ''), + 'Got schema 1'; + +isa_ok $schema1->resultset('Artist'), 'DBIx::Class::ResultSet'; +can_ok $schema1, qw/cds artists/; +isa_ok $schema1->artists, 'DBIx::Class::ResultSet'; # generic resultset +isa_ok $schema1->cds, 'MyApp1::Schema::ResultSet::CD'; # custom ResultSet + +# overwrite the accessor name with resultset_accessor_name() +can_ok $schema1, qw/source_resultset/; +isa_ok $schema1->source_resultset, 'DBIx::Class::ResultSet'; + +throws_ok { + # must use required, because for some reason throws_ok cannot catch + # erros with "use" + require MyApp2::Schema; + MyApp2::Schema->connect('dbi:SQLite:dbname=:memory:', '', ''); +} qr/Schema method with the same name already exists/, + 'Schema method with the same name already exists'; + +done_testing;