From: <bo...@kr...> - 2006-01-30 14:03:23
|
Log Message: ----------- Test for template_chooser Added Files: ----------- krang/t: template_chooser.t Revision Data ------------- --- /dev/null +++ t/template_chooser.t @@ -0,0 +1,32 @@ +# test the template chooser widget + +use Krang::ClassFactory qw(pkg); +use Test::More qw(no_plan); +use strict; +use warnings; +use Krang::ClassLoader 'Script'; +use Krang::ClassLoader Conf => qw(InstanceElementSet); +use Krang::ClassLoader 'ElementLibrary'; +use CGI; + +BEGIN{ use_ok('Krang::Widget', 'template_chooser') } + +# clean up when finished +my $old_instance = pkg('Conf')->instance; +END { pkg('Conf')->instance($old_instance) } + +# use the TestSet1 instance, if there is one +foreach my $instance (pkg('Conf')->instances) { + pkg('Conf')->instance($instance); + if (InstanceElementSet eq 'TestSet1') { + last; + } +} + +# set up the template chooser +my $chooser = template_chooser(name => 'name', query => CGI->new); + +# check if the chooser offers all elements +for my $element (pkg('ElementLibrary')->element_names) { + like($chooser, qr/$element/, "templae_chooser offers element '$element'"); +} |