I am trying to run tests on helper functions, so I created a cron job to test them. I have already verified that the cronjob itself is set up correctly (it is running when I have simple logging statements in it). Now I want to set it up to run functions from my helper file.
In config.xml
:
...
<crontab>
<jobs>
<testjob>
<schedule><cron_expr>*/1 * * * *</cron_expr></schedule>
<run><model>module/crontest::testSuite</model></run>
</testjob>
</jobs>
</crontab>
<helpers>
<module>
<class>Namespace_Module_Helper</class>
</module>
</helpers>
...
Then in my Crontest.php
file, under Model
:
class Namespace_Module_Model_Crontest
{
protected $helper = Mage::helper('module');
protected $testData = null;
public function testSuite() {
Mage::log("HELPER FUNCTION TESTS", null, 'test.log', true);
$testData = $helper->getApiUrl();
Mage::log("Ran getApiUrl: {$testData}", null, 'test.log', true);
}
When this runs (every minute), nothing appears in any log file. However, I believe I have narrowed down the problem to the first variable declaration: $helper
. I think I'm doing that wrong, because when that line was removed, I got errors, and it was evident that the cron job was running. But with the line, it's failing silently and I'm not sure why. What is wrong with how I'm calling the helper functions?