5 use Test
::More
'tests' => 7;
16 my $db = NewDB
->new();
24 content
=> 'blah-blah',
40 content
=> 'blah-blah',
52 foreach my $post ( @posts ) {
53 my $comments = delete $post->{ comments
};
55 my $post = Post
->new( %$post );
57 $post->comments( $comments );
59 $post->save( cascade
=> 1 );
62 foreach my $article ( @articles ) {
63 my $comments = delete $article->{ comments
};
65 my $article = Article
->new( %$article );
67 $article->comments( $comments );
69 $article->save( cascade
=> 1 );
72 my $comments = Comment
::Manager
->get_objects();
74 is
( scalar @
$comments, 2 );
76 my $article_comments =
77 Comment
::Manager
->get_objects( query
=> [ type
=> 'article' ] );
79 is
( scalar @
$article_comments, 1 );
81 my $comment = $article_comments->[ 0 ];
82 is
( $comment->type, 'article' );
84 my $master = $comment->get_master_object();
87 is
( $master->title, 'FreeBSD' );
89 $comment = Comment
->new(master_id
=> 1, type
=> 'article');
91 is
($comment->type, 'article');
92 is
($comment->content, 'foo');
94 my $articles = Article
::Manager
->get_objects();
95 $_->delete( cascade
=> 1 ) foreach @
$articles;
97 my $posts = Post
::Manager
->get_objects();
98 $_->delete( cascade
=> 1 ) foreach @
$posts;