Add in Data::Perl::Collection::Set from DBIx-Data-Store-old so we can run tests.
[catagits/App-IdiotBox.git] / t / show / bucket.t
1 use strict;
2 use lib qw(t/lib/);
3 use warnings FATAL => 'all';
4 use Test::More;
5
6 use App::IdiotBox;
7 use Data::Perl::Collection::Set;
8 use Scalar::Util qw(weaken);
9
10 my $idiotbox = App::IdiotBox->new({
11  config => { template_dir => 'share/html' }
12 });
13
14 my $bucket = bless({
15   slug => 'lpw2009',
16   name => 'London Perl Workshop 2009',
17 }, 'App::IdiotBox::Bucket');
18
19 my %vid;
20
21 $bucket->{videos} = Data::Perl::Collection::Set->new(
22     members => [ map {
23       my $o = bless(
24         { %$_, bucket => $bucket, details => ''  },
25         'App::IdiotBox::Video'
26       );
27       weaken($o->{bucket});
28       $vid{$o->{slug}} = $o
29     }
30       { name => 'The M Word', slug => 'm-word', author => 'davorg' },
31       { name => 'Dreamcasting', slug => 'dream', author => 'mst' },
32   ]
33 );
34
35 sub slurp_html {
36   my $string;
37   my $fh = $_[0]->[-1];
38   while (defined (my $chunk = $fh->getline)) {
39     $string .= $chunk;
40   }
41   $string;
42
43
44 my $bucket_result = $idiotbox->show_bucket($bucket);
45
46 my $html = slurp_html($bucket_result);
47
48 warn $html;
49
50 warn "\n\n------\n\n";
51
52 my $video_result = $idiotbox->show_video($vid{dream});
53
54 $html = slurp_html($video_result);
55
56 warn $html;
57
58 pass;
59
60 done_testing;