Ejemplo n.º 1
0
 function test_callStaticMethod()
 {
     $this->assertEqual(OX_Component::callStaticMethod('testExtension1', 'testGroup1', 'testComponent1', 'staticMethod'), 'staticMethodResult1');
     $this->assertEqual(OX_Component::callStaticMethod('testExtension1', 'testGroup1', 'testComponent1', 'staticMethodWithParams', 'foo'), 'staticMethodWithParams1=foo');
 }
 /**
  * A method to test the callStaticMethod() method.
  */
 function testCallStaticMethod()
 {
     // Set the error handling class' handleErrors() method as
     // the error handler for PHP for this test.
     $oTestErrorHandler = new TestErrorHandler();
     PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, array(&$oTestErrorHandler, 'handleErrors'));
     // Test with a bad module/package
     $return = MAX_Plugin::callStaticMethod('foo', 'bar', null, 'foo');
     $this->assertEqual(count($oTestErrorHandler->aErrors), 1);
     $this->assertEqual($oTestErrorHandler->aErrors[0]->message, 'Unable to include the file ' . MAX_PATH . '/plugins/foo/bar/bar' . MAX_PLUGINS_EXTENSION . '.');
     $this->assertFalse($result);
     $oTestErrorHandler->reset();
     // Unset the error handler
     PEAR::popErrorHandling();
     // Set the error handling class' handleErrors() method as
     // the error handler for PHP for this test.
     $oTestErrorHandler = new TestErrorHandler();
     PEAR::pushErrorHandling(PEAR_ERROR_CALLBACK, array(&$oTestErrorHandler, 'handleErrors'));
     // Test with a bad method
     $return = MAX_Plugin::callStaticMethod('reports', 'standard', 'advertisingAnalysisReport', 'foo');
     $this->assertEqual(count($oTestErrorHandler->aErrors), 1);
     $this->assertEqual($oTestErrorHandler->aErrors[0]->message, "Method 'foo()' not defined in class 'Plugins_Reports_Standard_AdvertisingAnalysisReport'.");
     $this->assertFalse($result);
     $oTestErrorHandler->reset();
     // Unset the error handler
     PEAR::popErrorHandling();
     unset($GLOBALS['_MAX']['CONF']['plugins']['openXTests']);
     unset($GLOBALS['_MAX']['CONF']['pluginGroupComponents']['Dummy']);
     TestEnv::installPluginPackage('openXTests');
     // Test with a real method, no parameters
     $return = OX_Component::callStaticMethod('deliveryLimitations', 'Dummy', 'Dummy', 'isAllowed');
     $this->assertTrue($return);
     // Test with a real method, with parameters
     $return = OX_Component::callStaticMethod('deliveryLimitations', 'Dummy', 'Dummy', 'isAllowed', 'disallow');
     $this->assertFalse($return);
     TestEnv::uninstallPluginPackage('openXTests');
 }