Hello to everyone,
First of all, I am using MODx Revo 2.2.4pl.
What I am trying to do is unit test the processors I have created for an Extra.
I use the PHPUnit Framework 3.6 via NetBeans 7.2.
I use a bootstrap file with the following content:
define('MODX_CORE_PATH', '/path/to/modx/core/');
define('MODX_CONFIG_KEY', 'config');
require_once MODX_CORE_PATH.'model/modx/modx.class.php';
require_once MODX_CORE_PATH.'model/modx/modprocessor.class.php';
and, then on the setUp method of each test case I put:
$this->modx = new modX();
$this->modx->initialize('mgr');
The problem I run into is that during one of my tests the error:
"failure" method being called on a non-object
is produced. Specifically, the test method's code is the following:
$this->processor->setProperty('id', 7);
$this->assertFalse( $this->processor->initialize() );
and on the processor the "initialize" method code goes like this:
$initialized = parent::initialize();
if ($initialized !== true) {
return $initialized;
}
$this->categoryId = $this->getProperty('category_id');
if ( empty($this->categoryId) ) {
$this->failure('No category was specified.');
return false;
}
return true;
So, as you can see, this method is supposed to halt initialization if no "category_id" parameter was given.
The test case stops with the aforementioned error which means that "$this->processor" of the test case is a non-object. But, the processor is initialized and runs properly for all the other test methods of the same test case.
Could anyone explain why this is happening?
Thank you very much.
[ed. note: leffyrant last edited this post 11 years, 7 months ago.]