forked from movabletype/movabletype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path81-pagination.t
62 lines (55 loc) · 1.6 KB
/
81-pagination.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/perl
use strict;
use warnings;
use lib qw( t/lib lib extlib ../lib ../extlib );
use Test::More tests => 20;
BEGIN {
$ENV{MT_APP} = 'MT::App::Comments';
$ENV{MT_CONFIG} = 'mysql-test.cfg';
}
use MT;
use MT::Blog;
use MT::Comment;
use MT::Entry;
use MT::Template;
use MT::Test qw( :app :db :data );
my @blogs = MT::Blog->load();
foreach my $blog (@blogs) {
my $tmpl = MT::Template->load(
{
name => 'Comment Listing',
blog_id => $blog->id,
}
);
unless ($tmpl) {
my $text =
<<TEXT;
{
"direction": "<mt:Var name="commentDirection">",
"comments": "<mt:Comments sort_order="\$commentDirection"><mt:Include module="Comment Detail" replace="\","\\" replace='"','\"' strip_linefeeds="1"></mt:Comments>"
}
TEXT
$tmpl = MT::Template->new;
$tmpl->blog_id($blog->id);
$tmpl->name('Comment Listing');
$tmpl->text($text);
$tmpl->save;
}
}
my @entries = MT::Entry->load();
foreach my $entry (@entries) {
my $app = _run_app( 'MT::App::Comments', { __mode => 'comment_listing', entry_id => $entry->id } );
my $output = delete $app->{__test_output};
ok ($output, "comment_listing ran and returned something");
my @comments = MT::Comment->load({ entry_id => $entry->id });
next unless (@comments);
foreach my $comment (@comments) {
my $id = $comment->id;
if ( $comment->visible() ) {
ok ($output =~ /comment-$id/, "Comment was found: $output");
}
else {
ok ($output !~ /comment-$id/, "Invisible comment was hidden: $output");
}
}
}