5 use make_dbictest_db_multi_m2m;
8 use DBIx::Class::Schema::Loader;
10 my $schema_counter = 0;
13 my $hashmap = schema_with(
15 foos_2s => "other_foos",
16 bars_2s => "other_bars",
20 foreach ([qw(Foo bars)], [qw(Bar foos)]) {
21 my ($source, $rel) = @{$_};
22 my $row = $hashmap->resultset($source)->find(1);
23 foreach my $link ("", "other_") {
24 can_ok $row, "${link}${rel}";
29 my $submap = schema_with(
32 if ($args->{type} eq "many_to_many") {
33 like $args->{link_class},
34 qr/\ADBICTest::Schema::${schema_counter}::Result::FooBar(?:One|Two)\z/,
36 like $args->{link_moniker}, qr/\AFooBar(?:One|Two)\z/,
38 like $args->{link_rel_name}, qr/\Afoo_bar_(?:ones|twos)\z/,
41 return $args->{name}."_".(split /_/, $args->{link_rel_name})[-1];
45 foreach ([qw(Foo bars)], [qw(Bar foos)]) {
46 my ($source, $rel) = @{$_};
47 my $row = $submap->resultset($source)->find(1);
48 foreach ([ones => 1], [twos => 2]) {
49 my ($link, $count) = @{$_};
50 my $m2m = "${rel}_${link}";
52 is $row->$m2m->count, $count, "$m2m count";
59 #### generates a new schema with the given opts every time it's called
62 DBIx::Class::Schema::Loader::make_schema_at(
63 'DBICTest::Schema::'.$schema_counter,
64 { naming => 'current', @_ },
65 [ $make_dbictest_db_multi_m2m::dsn ],
67 "DBICTest::Schema::$schema_counter"->clone;