File: schema_DBIC_Tag.t

package info (click to toggle)
libmojomojo-perl 1.01%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,272 kB
  • ctags: 879
  • sloc: perl: 14,055; sh: 145; xml: 120; ruby: 6; makefile: 2
file content (43 lines) | stat: -rwxr-xr-x 1,054 bytes parent folder | download | duplicates (5)
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
36
37
38
39
40
41
42
43
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

BEGIN {
    eval 'use DBD::SQLite';
    plan skip_all => 'need DBD::SQLite' if $@;

    eval 'use SQL::Translator';
    plan skip_all => 'need SQL::Translator' if $@;

    plan tests => 4;
}

use lib 't/lib';
use MojoMojoTestSchema;

my $schema = MojoMojoTestSchema->init_schema(populate => 1);
my ($page_ref) = $schema->resultset('Page')->path_pages('/');
my $page = $page_ref->[0];
is(scalar $page->tags, 0, 'no tags for root page');

my $tag = $schema->resultset('Tag')->create({
    tag => 'test',
    page => $page->id,
    person => 1
});
is(scalar $page->tags, 1, 'added 1 to the root page');

my $tag2 = $schema->resultset('Tag')->create({
    tag => 'test2',
    page => $page->id,
    person => 1
});
is($schema->resultset('Tag')->most_used()->count(), 2, 'added one more, 2 now');

my $tag3 = $schema->resultset('Tag')->create({
    tag => 'test3',
    page => $page->id,
    person => 1
});
is($schema->resultset('Tag')->by_page($page->id)->count(), 3, 'added one more, 3 now');