]> git.donarmstrong.com Git - debbugs.git/blob - t/22_oo_interface.t
it's now submitter->email
[debbugs.git] / t / 22_oo_interface.t
1 # -*- mode: cperl;-*-
2
3 use Test::More;
4
5 use warnings;
6 use strict;
7
8 # Here, we're going to shoot messages through a set of things that can
9 # happen.
10
11 # First, we're going to send mesages to receive.
12 # To do so, we'll first send a message to submit,
13 # then send messages to the newly created bugnumber.
14
15 use IO::File;
16 use File::Temp qw(tempdir);
17 use Cwd qw(getcwd);
18 use Debbugs::MIME qw(create_mime_message);
19 use File::Basename qw(dirname basename);
20 use Test::WWW::Mechanize;
21 use HTTP::Status qw(RC_NOT_MODIFIED);
22 # The test functions are placed here to make things easier
23 use lib qw(t/lib);
24 use DebbugsTest qw(:all);
25
26 # This must happen before anything is used, otherwise Debbugs::Config will be
27 # set to wrong values.
28 my %config = create_debbugs_configuration();
29
30 my $tests = 0;
31 use_ok('Debbugs::Bug');
32 $tests++;
33 use_ok('Debbugs::Collection::Bug');
34 $tests++;
35
36 # create 4 bugs
37 for (1..4) {
38     submit_bug(subject => 'Submitting a bug '.$_,
39                pseudoheaders => {Severity => 'normal',
40                                  Tags => 'wontfix moreinfo',
41                                 },
42               );
43 }
44 run_processall();
45
46 my $bc = Debbugs::Collection::Bug->new(bugs => [1..4]);
47
48 my $bug;
49 ok($bug = $bc->get(1),
50    "Created a bug correctly"
51   );
52 $tests++;
53
54 ok(!$bug->archiveable,
55    "Newly created bugs are not archiveable"
56   );
57 $tests++;
58
59 is($bug->submitter->email,'foo@bugs.something',
60    "Submitter works"
61   );
62 $tests++;
63
64 ok($bug->tags->tag_is_set('wontfix'),
65    "Wontfix tag set"
66   );
67 $tests++;
68
69 is($bug->tags->as_string(),
70    'moreinfo wontfix',
71    "as_string works"
72   );
73 $tests++;
74
75 ### run some tests with the database creation
76
77 ## create the database
78 my $pgsql = create_postgresql_database();
79 update_postgresql_database($pgsql);
80
81 use_ok('Debbugs::DB');
82 $tests++;
83 my $s;
84 ok($s = Debbugs::DB->connect($pgsql->dsn),
85    "Able to connect to database");
86 $tests++;
87
88 $bc = Debbugs::Collection::Bug->new(bugs => [1..4],
89                                  schema => $s);
90 ok($bug = $bc->get(1),
91    "Created a bug correctly with DB"
92   );
93 $tests++;
94
95 done_testing($tests);
96