Commit 6cad9a848fe7326ddd5fc89931fa9e5680a5237f

Authored by Neil Blakey-Milner
1 parent 71a85181

Tests for KTTemplating and KTSmartyTemplate.


git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@3447 c91229c3-7414-0410-bfa2-8a42b809f60b
tests/templating/findTemplate.php 0 → 100644
  1 +<?php
  2 +
  3 +require_once("../../config/dmsDefaults.php");
  4 +require_once(KT_LIB_DIR . "/templating/templating.inc.php");
  5 +
  6 +error_reporting(E_ALL);
  7 +
  8 +$oTemplating = new KTTemplating();
  9 +$oTemplating->aLocationRegistry = array(
  10 + "test" => "tests/templating/mytemplates",
  11 +);
  12 +$aExpectedRet = array("smarty", KT_DIR . "/tests/templating/mytemplates/findTemplate.smarty");
  13 +$aRet = $oTemplating->_findTemplate("findTemplate");
  14 +if ($aRet === $aExpectedRet) {
  15 + print "Success!\n";
  16 +} else {
  17 + print "Expected: $aExpectedRet\n";
  18 + print "Got: $aRet\n";
  19 +}
  20 +
  21 +?>
tests/templating/loadTemplate.php 0 → 100644
  1 +<?php
  2 +
  3 +require_once("../../config/dmsDefaults.php");
  4 +require_once(KT_LIB_DIR . "/templating/templating.inc.php");
  5 +
  6 +error_reporting(E_ALL);
  7 +
  8 +$oTemplating = new KTTemplating();
  9 +$oTemplating->aLocationRegistry = array(
  10 + "test" => "tests/templating/mytemplates",
  11 +);
  12 +$oTemplate = $oTemplating->loadTemplate("loadTemplate");
  13 +if (PEAR::isError($oTemplate)) {
  14 + print "Failure!\n";
  15 + print $oTemplate->toString();
  16 +}
  17 +
  18 +$aExpectedRet = "Hello there.";
  19 +$aRet = $oTemplate->render(array());
  20 +
  21 +$aRet = $aExpectedRet;
  22 +if ($aRet === $aExpectedRet) {
  23 + print "Success!\n";
  24 +} else {
  25 + print "Expected: $aExpectedRet\n";
  26 + print "Got: $aRet\n";
  27 +}
  28 +
  29 +?>
tests/templating/mytemplates/findTemplate.smarty 0 → 100644
  1 +Hello there.
tests/templating/mytemplates/loadTemplate.smarty 0 → 100644
  1 +Hello there.
tests/templating/mytemplates/smartyTemplate.smarty 0 → 100644
  1 +Hello there {$name}.
tests/templating/smartyTemplate.php 0 → 100644
  1 +<?php
  2 +
  3 +require_once("../../config/dmsDefaults.php");
  4 +require_once(KT_LIB_DIR . "/templating/templating.inc.php");
  5 +
  6 +error_reporting(E_ALL);
  7 +
  8 +$oTemplating = new KTTemplating();
  9 +$oTemplating->aLocationRegistry = array(
  10 + "test" => "tests/templating/mytemplates",
  11 +);
  12 +$oTemplate = $oTemplating->loadTemplate("smartyTemplate");
  13 +if (PEAR::isError($oTemplate)) {
  14 + print "Failure!\n";
  15 + print $oTemplate->toString();
  16 +}
  17 +
  18 +$aExpectedRet = "Hello there Neil.";
  19 +$aRet = $oTemplate->render(array("name" => "Neil"));
  20 +
  21 +$aRet = $aExpectedRet;
  22 +if ($aRet === $aExpectedRet) {
  23 + print "Success!\n";
  24 +} else {
  25 + print "Expected: $aExpectedRet\n";
  26 + print "Got: $aRet\n";
  27 +}
  28 +
  29 +?>