bless {
options => $options,
users => [],
+ stories => [],
+ comments => [],
test => $test,
}, $class;
}
return $user;
}
+sub create_comment {
+ my $self = shift;
+ my $params = {@_};
+ for my $k (qw(user title comment)) {
+ return if !$params->{$k};
+ }
+ my $discussion_id = $params->{discussion} || $params->{discussion_id};
+ if (!$discussion_id) {
+ return;
+ }
+ my $comment = Newslash::Util::Test::create_comment($self->app,
+ $params->{user},
+ $discussion_id,
+ $params->{title},
+ $params->{comment},
+ $params->{pid});
+ push @{$self->{comments}}, $comment;
+ return $comment;
+}
+
+sub create_story {
+ my $self = shift;
+ my $params = {@_};
+
+ my $intro_text = $params->{intro_text} || $params->{introtext};
+ my $bodytext = $params->{body_text} || $params->{bodytext};
+
+ my $story = Newslash::Util::Test::create_story($self->app, $params->{user},
+ params => $params);
+ push @{$self->{stories}}, $story;
+ return $story;
+}
+
+sub create_journal {
+ my $self = shift;
+ my $params = {@_};
+
+ my $j = Newslash::Util::Test::create_journal($self->app,
+ $params->{user},
+ params => $params);
+ push @{$self->{journals}}, $j;
+ return $j;
+}
+
sub cleanup {
my $self = shift;
- for my $user (@{$self->{users}}) {
- Newslash::Util::Test::delete_user($self->app, $user->{nickname});
+ my $item;
+
+ for $item (@{$self->{users}}) {
+ Newslash::Util::Test::delete_user($self->app, $item->{nickname});
+ }
+ for $item (@{$self->{comments}}) {
+ Newslash::Util::Test::delete_comment($self->app, $item->{cid});
+ }
+ for my $item (@{$self->{stories}}) {
+ Newslash::Util::Test::delete_story($self->app, $item->{stoid});
+ }
+ for my $item (@{$self->{journals}}) {
+ Newslash::Util::Test::delete_journal($self->app, $item->{jorunal_id});
}
}