-
Notifications
You must be signed in to change notification settings - Fork 28
/
blog.t
35 lines (27 loc) · 1.11 KB
/
blog.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use Modern::Perl;
use Test::More;
use Schema;
use Test::Database;
my $schema = Test::Database->new->create(Schema => ':memory:');
my $blog_id = '1';
my $blog_title = 'Hello!';
my $blog_url_title = 'hello_';
my $blog = $schema->resultset('Blog')->find($blog_id);
is $blog->url_title => $blog_url_title, 'url title';
is ref $blog->created_time => 'DateTime', 'DateTime object';
is $blog->created_time_string => 'Wednesday, April 6, 2011 at 2:27AM',
'pretty time string';
#ok $blog->snippet;
# Tags
is $blog->tags->first->name => 'personal', 'blog tag';
ok !$schema->resultset('Blog')->by_tags(qw/bad/);
is [$schema->resultset('Blog')->by_tags(qw/personal/)]->[0]->title =>
$blog_title;
is [$schema->resultset('Blog')->by_tags(qw/test/)]->[0]->title => $blog_title;
is [$schema->resultset('Blog')->by_tags(qw/personal test/)]->[0]->title =>
$blog_title;
is $schema->resultset('Blog')->hidden->all => 1, '1 hidden entry';
is $schema->resultset('Blog')->not_hidden->all => 3, '3 non-hidden entries';
# Latest non-hidden entry
is $schema->resultset('Blog')->latest->title => 'Tech', 'latest entry';
done_testing;