X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fshow%2Fbucket.t;fp=t%2Fshow%2Fbucket.t;h=5f1df832419c6ad9457e46da6ecef3830c65c1b6;hb=71fd155003c63e8d51dbb7d7ab992752506579aa;hp=0000000000000000000000000000000000000000;hpb=d7497a232029fa939d2ac7eb51e6979d12acd1a3;p=catagits%2FApp-IdiotBox.git diff --git a/t/show/bucket.t b/t/show/bucket.t new file mode 100644 index 0000000..5f1df83 --- /dev/null +++ b/t/show/bucket.t @@ -0,0 +1,59 @@ +use strict; +use warnings FATAL => 'all'; +use Test::More; + +use App::IdiotBox; +use Data::Perl::Collection::Set; +use Scalar::Util qw(weaken); + +my $idiotbox = App::IdiotBox->new({ + config => { template_dir => 'share/html' } +}); + +my $bucket = bless({ + slug => 'lpw2009', + name => 'London Perl Workshop 2009', +}, 'App::IdiotBox::Bucket'); + +my %vid; + +$bucket->{videos} = Data::Perl::Collection::Set->new( + members => [ map { + my $o = bless( + { %$_, bucket => $bucket, details => '' }, + 'App::IdiotBox::Video' + ); + weaken($o->{bucket}); + $vid{$o->{slug}} = $o + } + { name => 'The M Word', slug => 'm-word', author => 'davorg' }, + { name => 'Dreamcasting', slug => 'dream', author => 'mst' }, + ] +); + +sub slurp_html { + my $string; + my $fh = $_[0]->[-1]; + while (defined (my $chunk = $fh->getline)) { + $string .= $chunk; + } + $string; +} + +my $bucket_result = $idiotbox->show_bucket($bucket); + +my $html = slurp_html($bucket_result); + +warn $html; + +warn "\n\n------\n\n"; + +my $video_result = $idiotbox->show_video($vid{dream}); + +$html = slurp_html($video_result); + +warn $html; + +pass; + +done_testing;