Skip to content

Instantly share code, notes, and snippets.

@dhoss
Created April 14, 2010 23:49
Show Gist options
  • Save dhoss/366490 to your computer and use it in GitHub Desktop.
Save dhoss/366490 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use Test::More;
use lib "t/lib";
use Schema;
my $schema = Schema->connect('dbi:SQLite::memory:');
$schema->deploy;
my $rs = $schema->resultset('Test');
my $chief = $rs->create(
{
name => 'grand chief',
children => [
{
name => 'subordinate 1',
children => [ map { { name => 'rookie 1.' . $_ } } qw/1 2 3/, ],
},
{
name => 'subordinate 2',
children => [ map { { name => 'rookie 2.' . $_ } } qw/1 2/, ],
},
]
}
);
ok( check_rs( $chief, [ [ undef, 1 ] ] ) );
ok( check_rs( $chief, [ "1", "1.1" ] ) );
sub check_rs {
my ( $node, $expected_pairs ) = @_;
## check to make sure the parent is correct, and the path is correct
$node->discard_changes;
warn "Parent accessor " . $node->parent->path;
warn "node path: " . $node->path;
unless ( ( $node->parent->path eq $expected_pairs->[0] ) && ( $node->path eq $expected_pairs->[0][0] ) ) {
return 0;
}
return 1;
}
done_testing();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment