root/branches/release-36/t/21-app-callbacks.t @ 2069

Revision 2069, 1.9 kB (checked in by mpaschal, 19 months ago)

Split these tests up (can't instantiate two MTs in one run)

  • Property svn:mime-type set to text/plain
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/usr/bin/perl
2# $Id$
3use strict;
4use warnings;
5
6use Test::More tests => 3;
7use CGI;
8use DB_File;
9
10use lib 'extlib';
11use lib 't/lib';
12use lib 'lib';
13
14use MT;
15use MT::Plugin;
16use MT::Entry;
17use MT::App::CMS;
18use MT::Permission;
19
20use vars qw($T_CFG);
21
22use lib 't';
23require 'test-common.pl';
24
25### Test app callbacks
26
27my @result_cats = ();
28
29my $cms = MT::App::CMS->new(Config => $T_CFG);
30
31my $plugin = MT::Plugin->new({name => "21-callbacks.t"});
32
33my $entry2 = MT::Entry->load({}, { limit => 1 });
34
35my $app_post_save_called;
36MT->add_callback('AppPostEntrySave', 1, $plugin,
37                 sub {
38                       $app_post_save_called = 1;
39                       my @plcmts = MT::Placement->load({entry_id => $_[2]->id});
40                       for my $plcmt (@plcmts) {
41                           push @result_cats, $plcmt->category_id;
42                       }
43                   } );
44
45MT::unplug();
46my $q = CGI->new();
47#$q->param(id => $entry2->id);
48$q->param(blog_id => $entry2->blog_id);
49$q->param(category_ids => 17);
50# $q->param(username => 'Chuck D');
51# $q->param(password => 'bass');
52$q->param(text => "Buddha blessed and boo-ya blasted;
53these are the words that she manifested.");
54$cms->{query} = $q;
55$cms->{perms} = MT::Permission->new();
56$cms->{perms}->can_post(1);
57$cms->{author} = MT::Author->new();
58$cms->{author}->name("Mel E. Mel");
59$cms->{author}->id(1);
60
61# fake out the magic; we're not testing that right now
62no warnings qw(once redefine);
63*MT::App::CMS::validate_magic = sub { 1; };
64use warnings qw(once redefine);
65
66my $handler = $cms->handler_to_coderef( $cms->handlers_for_mode('save_entry') );
67my $ret = $handler->($cms);
68ok(!defined $ret && $cms->{redirect}, 'entry save was successful');
69diag('Error: ' . $cms->errstr) if !defined $ret && !$cms->{redirect};
70
71ok($app_post_save_called, 'AppPostEntrySave callback was called');
72is($result_cats[0], 17, 'result_cats = 17');
73
Note: See TracBrowser for help on using the browser.