From: Peter Rabbitson Date: Sun, 25 Apr 2010 16:29:07 +0000 (+0000) Subject: Test for copy() compatibility X-Git-Tag: 0.03001~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=0179986ebd43ed29207b56279a032cd965f7ee79;p=dbsrgits%2FDBIx-Class-Tree.git Test for copy() compatibility --- diff --git a/Makefile.PL b/Makefile.PL index cfcde51..2074e79 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -14,6 +14,7 @@ readme_from 'lib/DBIx/Class/Tree.pm'; resources 'repository' => 'http://dev.catalyst.perl.org/repos/bast/DBIx-Class-Tree/'; requires 'DBIx::Class' => '0.08100'; +test_requires 'Test::Exception'; WriteAll; diff --git a/t/lib/TreeTest.pm b/t/lib/TreeTest.pm index e77eea1..d7228ff 100644 --- a/t/lib/TreeTest.pm +++ b/t/lib/TreeTest.pm @@ -3,12 +3,13 @@ use strict; use warnings; use Test::More; +use Test::Exception; use TreeTest::Schema; our $NODE_COUNT = 80; sub count_tests { - my $count = 13; + my $count = 14; if( TreeTest::Schema::Node->can('position_column') ){ $count ++; } @@ -27,6 +28,12 @@ sub run_tests { my $node = $nodes->create({ name=>'child' }); $node->parent( $parent_id ); } + + lives_and ( sub { + warn "BEGIN!!!!!\n\n"; + is( $nodes->find(3)->copy({name => 'special'})->name,'special','copy test'); + }, 'copy does not throw'); + ok( ($nodes->count()==81), 'correct number of nodes in random tree' ); ok( ($nodes->find(3)->children->count()==7), 'node 3 has correct number of children' ); ok( ($nodes->find(22)->children->count()==3), 'node 22 has correct number of children' ); diff --git a/t/lib/TreeTest/Schema/Node.pm b/t/lib/TreeTest/Schema/Node.pm index 9c36d9e..2d887b0 100644 --- a/t/lib/TreeTest/Schema/Node.pm +++ b/t/lib/TreeTest/Schema/Node.pm @@ -2,8 +2,6 @@ package TreeTest::Schema::Node; use strict; use warnings; -use Carp qw( croak ); - use base qw( DBIx::Class ); __PACKAGE__->load_components(qw( @@ -13,14 +11,16 @@ __PACKAGE__->load_components(qw( __PACKAGE__->table('nodes'); -__PACKAGE__->add_columns(qw( - node_id +__PACKAGE__->add_columns( + node_id => { is_auto_increment => 1 }, + qw/ name parent_id position lft rgt -)); + / +); __PACKAGE__->set_primary_key( 'node_id' );