forked from movabletype/movabletype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path99-includeblogs.t
145 lines (129 loc) · 4.57 KB
/
99-includeblogs.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/perl
use strict;
use warnings;
use lib 't/lib', 'lib', 'extlib';
use Test::More tests => 8;
use MT;
use MT::Author;
use MT::Association;
use MT::Blog;
use MT::Comment;
use MT::Entry;
use MT::Role;
use MT::Tag;
use MT::Template;
use MT::Template::Context;
use MT::Test qw( :db :data );
# Adding another blog since MT::Test only creates one blog
my $blog = MT::Blog->new();
$blog->set_values({
name => 'none2',
site_url => 'http://narnia.na/nana2/',
archive_url => 'http://narnia.na/nana2/archives/',
site_path => 't/site2/',
archive_path => 't/site2/archives/',
archive_type => 'Individual,Monthly,Weekly,Daily,Category,Page',
archive_type_preferred => 'Individual',
description => "Narnia None Test Blog 2",
custom_dynamic_templates => 'custom',
convert_paras => 1,
allow_reg_comments => 1,
allow_unreg_comments => 0,
allow_pings => 1,
sort_order_posts => 'descend',
sort_order_comments => 'ascend',
remote_auth_token => 'token',
convert_paras_comments => 1,
google_api_key => 'r9Vj5K8PsjEu+OMsNZ/EEKjWmbCeQAv1',
cc_license => 'by-nc-sa http://creativecommons.org/licenses/by-nc-sa/2.0/ http://creativecommons.org/images/public/somerights20.gif',
server_offset => '-3.5',
children_modified_on => '20000101000000',
language => 'en_us',
file_extension => 'html',
});
$blog->id(2);
$blog->commenter_authenticators('enabled_TypeKey');
$blog->save() or die "Couldn't save blog 2: " . $blog->errstr;
# Create a new author for blog 2 and add author role for him
my $plim = MT::Author->new();
$plim->set_values({
name => 'Paolo',
nickname => 'Paolo',
email => 'plim@example.com',
auth_type => 'MT',
created_on => '19780131075000',
});
$plim->set_password("flute");
$plim->type( MT::Author::AUTHOR() );
$plim->save() or die "Couldn't save author record: " . $plim->errstr;
my $author_role = MT::Role->load({ name => 'Author' });
my $assoc = MT::Association->new();
$assoc = MT::Association->new();
$assoc->author_id( $plim->id );
$assoc->blog_id($blog->id);
$assoc->role_id( $author_role->id );
$assoc->type(1);
$assoc->save();
# Add an entry to blog 2
my $entry = MT::Entry->new();
$entry->set_values({
blog_id => 2,
title => 'A Rainy Day 2',
text => 'On a drizzly day last weekend 2',
text_more => 'I took my grandpa for a walk.',
excerpt => 'A story of a stroll.',
keywords => 'keywords',
created_on => '19780131074500',
authored_on => '19780131074500',
modified_on => '19780131074600',
authored_on => '19780131074500',
author_id => $plim->id,
pinged_urls => 'http://technorati.com/',
allow_comments => 1,
allow_pings => 1,
status => MT::Entry::RELEASE(),
});
$entry->tags( 'rain2', 'grandpa2', 'strolling2' );
$entry->save() or die "Couldn't save entry record: " . $entry->errstr;
# Add a comment to the new entry
my $cmt = MT::Comment->new();
$cmt->set_values({
text => 'This is a boring comment.',
entry_id => $entry->id,
author => 'v14GrUH 4 cheep',
visible => 1,
email => 'jake@fatman.com',
url => 'http://fatman.com/',
blog_id => $blog->id,
ip => '127.0.0.1',
created_on => '20040714182800',
});
$cmt->id(1);
$cmt->save() or die "Couldn't save comment record 1: " . $cmt->errstr;
# test if the objects were successfully created
ok ($entry->id, "New entry was created: " . $entry->title);
ok ($entry->tags, "New tags were created: " . $entry->tags);
ok ($cmt->id, "New comment was created: " . $cmt->text);
ok ($plim->id, "New author was created: " . $plim->name);
## NOW ON TO TESTING THE TAGS
my $tmpl;
# test for <mt:Entries include_blogs="all">
$tmpl = MT::Template->new;
$tmpl->blog_id ('1');
$tmpl->text ('<mt:Entries include_blogs="all"><mt:EntryTitle>, </mt:Entries>');
ok ($tmpl->output, "Got entries correctly: " . $tmpl->output);
# test for <mt:Comments include_blogs="all">
$tmpl = MT::Template->new;
$tmpl->blog_id ('1');
$tmpl->text ('<mt:Comments include_blogs="all"><mt:CommentBody>, </mt:Comments>');
ok ($tmpl->output, "Got comments correctly: " . $tmpl->output);
# test for <mt:Authors include_blogs="all">
$tmpl = MT::Template->new;
$tmpl->blog_id ('1');
$tmpl->text ('<mt:Authors include_blogs="all"><mt:AuthorName>, </mt:Authors>');
ok ($tmpl->output, "Template tag works correctly: " . $tmpl->output);
# test for <mt:Tags include_blogs="all">
$tmpl = MT::Template->new;
$tmpl->blog_id ('1');
$tmpl->text ('<mt:Tags include_blogs="all"><mt:TagName>, </mt:Tags>');
ok ($tmpl->output, "Template tag works correctly: " . $tmpl->output);