I am new to unit testing, and have been creating new component, controller, and model tests using SimpleTest. I am using CakePHP Test Suite version 1.2.0.0. I am having trouble creating a view for a helper, and the internet has yielded me no assistance. Here is the helper code:
class MyHelper extends AppHelper
{
var $helpers = array('Session');
function dostuff()
{
$helpervar = $this->Session->read('Data');
if(empty($helpervar))
{
return;
}
}
}
And my test code is here:
App::import('Helper', 'MyHelper');
class MyHelperTest extends CakeTestCase {
function startTest() {
$this->MyHelper = new MyHelperHelper();
}
function testRender() {
$this->MyHelper->dostuff();
}
function tearDown() {
unset($this->Controller);
ClassRegistry::flush();
}
}
And the error I receive:
Fatal error: Call to a member function read() on a non-object.
I am wondering if I need to create a mock view. I am new to all this so any information would be very much appreciated! Thanks!