Before the XsltHelperTest class call App::import('Helper', 'XsltHelper'); Good luck and happy testing!
-- Matias Lespiau http://www.gignus.com/ On Jan 28, 2008 4:46 PM, Wayne Fay <[EMAIL PROTECTED]> wrote: > > So I've created my own View helper (it just dispatches to the XSL > module), and now I want to test it with SimpleTest etc. > > My class is named XsltHelper and has a function docToDoc: > class XsltHelper extends AppHelper { > function docToDoc($xml, $xsl) { > $xslt = new xsltProcessor(); > $xslt->importStyleSheet($xsl); > $result = $xslt->transformToDoc($xml); > $xslt = null; > return $result; > } > } > > Everything works fine in my views, I've tested it there already. > > Now I want to get this helper under test, so I've created a > xslt.test.php under tests/cases/helpers and it looks like: > > class XsltHelperTest extends UnitTestCase { > var $in = '<?xml version="1.0"?><foo>Hello XSL</foo>'; > var $xsl = '<?xml version="1.0"?> <xsl:stylesheet > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > version="1.0"><xsl:template match="foo"><bar><xsl:value-of > select="."/></bar></xsl:template></xsl:stylesheet>'; > var $out = '<?xml version="1.0" encoding="UTF-8"?><bar>Hello > XSL</bar>'; > //var $helpers = array('Xslt'); > > function setUp() { > $this->Xslt =& new XsltHelper(); > } > > function testDocToDoc() { > $res = $this->Xslt->docToDoc($in, $xsl1); > $this->assertEqual($out1, $res); > } > > function tearDown() { > unset($this->Xslt); > } > } > > But I'm getting this error: > Individual test case: helpers\xslt.test.php > > Fatal error: Class 'XsltHelper' not found in > C:\dev\cake\cake_1.2.0.6311-beta\app\tests\cases\helpers\xslt.test.php > on line 24 > > Anyone know what I'm doing wrong? I can find very little documentation > online regarding testing your own Helpers. I tried adding the var > $helpers line but it didn't do anything for me, so I commented it out. > > Thanks! > Wayne > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---