VERSION var
[blog.pm-common-perl-mods.git] / Rose-DB-Object-VCS / t / commit.t
blob67feb5a1c528ec2c3a5fc8560a2a19a41d921902
1 #!/usr/bin/perl
3 use strict;
4 use warnings;
6 use Test::More 'tests' => 12;
8 use lib 't/lib';
10 use NewDB;
11 use Post;
12 use Post::Manager;
14 my $db = NewDB->new();
16 $db->init();
18 my $post = Post->new(
19 title => 'Wow',
20 content => 'Look there!',
21 user_id => 1
23 $post->commit();
25 ok( $post->addtime );
26 is( $post->revision, 1 );
27 is( $post->user_id, 1 );
28 is( $post->title, 'Wow' );
29 is( $post->content, 'Look there!' );
31 $post = Post->new( id => $post->id );
32 $post->load();
33 is( $post->revision, 1 );
35 my $old_addtime = $post->addtime;
36 sleep( 1 );
38 $post->commit;
39 is( $post->revision, 1, 'Commit without changes' );
41 $post->title( $post->title );
42 $post->commit;
43 is( $post->revision, 1, 'Commit without changes' );
45 $post->title( 'Wuw' );
46 $post->user_id( 2 );
47 $post->commit();
49 isnt( $old_addtime, $post->addtime );
51 is( $post->revision, 2 );
52 is( $post->title, 'Wuw' );
54 is( scalar @{ $post->diffs }, 1 );
56 $post->delete( cascade => 1 );