use_ok('DBIx::Class::ResultSource::View');
}
-my $view = DBIx::Class::ResultSource::View->new( { name => 'Upsilon' } );
+my $view = DBIx::Class::ResultSource::View->new( { name => 'Quux' } );
isa_ok( $view, 'DBIx::Class::ResultSource' );
isa_ok( $view, 'DBIx::Class' );
can_ok( $view, $_ ) for qw/new from depends_on/;
-#diag( map {"$_\n"} @{ mro::get_linear_isa($view) } );
-#diag( DwarnS $view);
+#################################
my $schema = ViewDeps->connect;
-ok($schema, 'Connected to ViewDeps schema OK');
+ok( $schema, 'Connected to ViewDeps schema OK' );
-#diag(DwarnS $schema);
+my @bar_deps = keys %{ $schema->resultset('Bar')->result_source->depends_on };
-#diag keys %{$schema->resultset('Bar')->result_source->depends_on};
+my @foo_deps = keys %{ $schema->resultset('Foo')->result_source->depends_on };
-my @dependencies = keys %{$schema->resultset('Bar')->result_source->depends_on};
+isa_ok( $schema->resultset('Bar')->result_source,
+ 'DBIx::Class::ResultSource::View', 'Bar' );
-is($dependencies[0], 'mixin', 'Bar is indeed reported to depend on mixin');
+is( $bar_deps[0], 'mixin', 'which is reported to depend on mixin.' );
+is( $foo_deps[0], undef, 'Foo has no dependencies...' );
+
+isa_ok(
+ $schema->resultset('Foo')->result_source,
+ 'DBIx::Class::ResultSource::View',
+ 'though Foo'
+);
+#diag($schema->resultset('Baz')->result_source->table_class);
+isa_ok($schema->resultset('Baz')->result_source, 'DBIx::Class::ResultSource::Table', "Baz on the other hand");
+dies_ok { ViewDeps::Result::Baz->result_source_instance->depends_on(
+ { ViewDeps::Result::Mixin->result_source_instance->name => 1 }
+ ) } "...and you cannot use depends_on with that";
done_testing;
package # hide from PAUSE
ViewDeps;
+## Used in 105view_deps.t
use strict;
use warnings;
use parent qw(DBIx::Class::Schema);
-use aliased 'DBIx::Class::ResultSource::View' => 'View';
__PACKAGE__->load_namespaces;
-#for my $p (__PACKAGE__) {
- #$p->load_namespaces;
- #$_->attach_additional_sources
- #for grep $_->isa(View), map $p->source($_), $p->sources;
-#}
-
1;
use warnings;
use parent qw(ViewDeps::Result::Foo);
-require ViewDeps::Result::Mixin;
+use ViewDeps::Result::Mixin;
__PACKAGE__->table('bar');
);
__PACKAGE__->belongs_to(
- 'b_thang',
+ 'table',
'ViewDeps::Result::JustATable',
{ 'foreign.id' => 'self.b' },
);
__PACKAGE__->has_many(
'foos',
'ViewDeps::Result::Foo',
- { 'foreign.a' => 'self.id' }
+ { 'foreign.id' => 'self.id' }
);
1;
--- /dev/null
+package # hide from PAUSE
+ ViewDeps::Result::Baz;
+## Used in 105view_deps.t
+
+use strict;
+use warnings;
+use parent qw(DBIx::Class::Core);
+
+__PACKAGE__->table('bar');
+
+__PACKAGE__->add_columns( id => { data_type => 'integer' } );
+
+__PACKAGE__->belongs_to(
+ 'table',
+ 'ViewDeps::Result::JustATable',
+ { 'foreign.id' => 'self.b' },
+);
+
+__PACKAGE__->has_many( 'foos', 'ViewDeps::Result::Foo',
+ { 'foreign.a' => 'self.id' } );
+
+1;
-package # hide from PAUSE
+package # hide from PAUSE
ViewDeps::Result::Foo;
use strict;
use aliased 'DBIx::Class::ResultSource::View';
__PACKAGE__->table_class(View);
-
__PACKAGE__->table('foo');
-
__PACKAGE__->add_columns(
- id => { data_type => 'integer', is_auto_increment => 1 },
- a => { data_type => 'integer', is_nullable => 1 }
+ id => { data_type => 'integer', is_auto_increment => 1 },
+ a => { data_type => 'integer', is_nullable => 1 }
);
__PACKAGE__->set_primary_key('id');
-__PACKAGE__->belongs_to(
- 'bar',
- 'ViewDeps::Result::Bar',
- { 'foreign.id' => 'self.a' }
-);
+__PACKAGE__->belongs_to( 'bar', 'ViewDeps::Result::Bar',
+ { 'foreign.id' => 'self.a' } );
1;
-package # hide from PAUSE
+package # hide from PAUSE
ViewDeps::Result::JustATable;
+## Used in 105view_deps.t
use base qw(DBIx::Class::Core);
__PACKAGE__->table('just_a_table');
__PACKAGE__->add_columns(
- id => { data_type => 'integer', is_auto_increment => 1 },
- name => { data_type => 'varchar', size => 255 }
+ id => { data_type => 'integer', is_auto_increment => 1 },
+ name => { data_type => 'varchar', size => 255 }
);
__PACKAGE__->set_primary_key('id');
-__PACKAGE__->has_many(
- 'bars',
- 'ViewDeps::Result::Bar',
- { 'foreign.b' => 'self.id' }
-);
-
+__PACKAGE__->has_many( 'bars', 'ViewDeps::Result::Bar',
+ { 'foreign.b' => 'self.id' } );
1;
package # hide from PAUSE
ViewDeps::Result::Mixin;
+## Used in 105view_deps.t
use strict;
use warnings;