SHARE
TWEET

test

a guest Jul 22nd, 2011 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # lets test that our new template variable for the fileloop in the main view method returns the
  2. # right values for the new field in the attached files loop: <tmpl_var extension>
  3. # first we create a new template with only the <tmpl_var extension> field in it
  4. # --------------------------------------------------------------------------------------------------
  5.  
  6. my $viewTemplate = $node->addChild({className=>'WebGUI::Asset::Template'});
  7.  
  8. my $tmplContent = "<tmpl_if attachment_loop><tmpl_loop attachment_loop><tmpl_var extension>|</tmpl_loop></tmpl_if>";
  9.  
  10.  
  11. my $newTemplateSettings = {
  12.         namespace => 'Article',
  13.         template   => $tmplContent,
  14. };
  15.  
  16.  
  17. my @extTestFiles = ("rotation_test.png","littleTextFile","jquery.js","tooWide.gif");
  18.  
  19. foreach my $f (@extTestFiles) {
  20.     my $pathedFile = WebGUI::Test->getTestCollateralPath($f);
  21.     my $storedFilename = $storage->addFileFromFilesystem($pathedFile);
  22. }
  23.  
  24. $viewTemplate->update($newTemplateSettings);
  25. $article->update({templateId=>$viewTemplate->getId});
  26. $article->prepareView;
  27.  
  28. my $newFieldoutput = $article->view;
  29. $newFieldoutput =~ s/\|$//;
  30.  
  31. my @tmplExtensions = split /\|/,$newFieldoutput;
  32.  
  33. my $extPassed = 1;
  34.  
  35. # rememer there is a tar file already stored from earlier test, we reuse this.
  36. if ( $tmplExtensions[0] ne "tar") {$extPassed = 0;}
  37. if ( $tmplExtensions[1] ne "png") {$extPassed = 0;}
  38. if ( $tmplExtensions[2] ne "") {$extPassed = 0;}
  39. if ( $tmplExtensions[3] ne "js") {$extPassed = 0;}
  40. if ( $tmplExtensions[4] ne "gif") {$extPassed = 0;}
  41.  
  42. ok ($extPassed, 'extension template variable in fileLoop working');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top