5 use make_dbictest_db_multi_m2m;
7 use DBIx::Class::Schema::Loader;
9 my $schema_counter = 0;
12 my $hashmap = schema_with(
14 foos_2s => "other_foos",
15 bars_2s => "other_bars",
19 foreach ([qw(Foo bars)], [qw(Bar foos)]) {
20 my ($source, $rel) = @{$_};
21 my $row = $hashmap->resultset($source)->find(1);
22 foreach my $link ("", "other_") {
23 can_ok $row, "${link}${rel}";
28 my $submap = schema_with(
31 if ($args->{type} eq "many_to_many") {
32 like $args->{link_class},
33 qr/\ADBICTest::Schema::${schema_counter}::Result::FooBar(?:One|Two)\z/,
35 like $args->{link_moniker}, qr/\AFooBar(?:One|Two)\z/,
37 like $args->{link_rel_name}, qr/\Afoo_bar_(?:ones|twos)\z/,
40 return $args->{name}."_".(split /_/, $args->{link_rel_name})[-1];
44 foreach ([qw(Foo bars)], [qw(Bar foos)]) {
45 my ($source, $rel) = @{$_};
46 my $row = $submap->resultset($source)->find(1);
47 foreach ([ones => 1], [twos => 2]) {
48 my ($link, $count) = @{$_};
49 my $m2m = "${rel}_${link}";
51 is $row->$m2m->count, $count, "$m2m count";
58 #### generates a new schema with the given opts every time it's called
61 DBIx::Class::Schema::Loader::make_schema_at(
62 'DBICTest::Schema::'.$schema_counter,
63 { naming => 'current', @_ },
64 [ $make_dbictest_db_multi_m2m::dsn ],
66 "DBICTest::Schema::$schema_counter"->clone;