示例#1
0
 /**
  * Constructor
  * 
  * @param array $optsArray Option configuration data
  * 
  * @return Cpanel_Service_Abstract
  */
 public function __construct($optsArray = array())
 {
     parent::__construct($optsArray);
     if (!$this->listner) {
         Cpanel_Listner_Observer_GenericLogger::initLogger($this, 1, array('level' => 'std'));
     }
     return $this;
 }
示例#2
0
 /**
  * The class is a Singleton.  The constructor, however is public due to
  * inheritance from Cpanel_Core_Object.
  * 
  * @param arrays $optsArray Option configuration data
  * 
  * @return Cpanel_PublicAPI  
  * @throws Exception If      instantiated directly. {@link getInstance()}
  */
 public function __construct($optsArray = false)
 {
     // Force the use of getInstance
     if (self::$_canInstantiate !== true) {
         throw new Exception(__CLASS__ . ' must be instantiated with ' . __CLASS__ . '::getInstance().');
     }
     if (!is_array($optsArray)) {
         $optsArray = array('cpanel' => array());
     } elseif (!array_key_exists('cpanel', $optsArray)) {
         $optsArray = array('cpanel' => $optsArray);
     }
     parent::__construct($optsArray);
     // TODO decouple into config option
     // Handle timezone
     $tz = ini_get('date.timezone');
     $tz = $tz ? $tz : 'UTC';
     date_default_timezone_set($tz);
     // TODO: refactor for dynamic loading and custom loading
     // Attach listner
     Cpanel_Listner_Observer_GenericLogger::initLogger($this, 1, array('level' => 'std'));
     // Create registry
     $this->registerRegistry();
     return $this;
 }
示例#3
0
 public function testCurlQueryAttemptsToLogData()
 {
     $listner = $this->getMock('Cpanel_Listner_Subject_Logger', array('log'));
     $listner->expects($this->once())->method('log');
     $rObj = $this->getRObj();
     $rq = $this->getRQ(array('curlExec', 'buildCurlHeaders'));
     Cpanel_Listner_Observer_GenericLogger::initLogger($rq, 1, array('level' => 'std'), $listner);
     $rq->expects($this->any())->method('buildCurlHeaders')->with($this->anything(), $rObj)->will($this->returnValue(array()));
     $rq->expects($this->any())->method('curlExec')->will($this->returnValue(true));
     $rq->curlQuery($rObj);
 }
示例#4
0
 public function getOptsArray()
 {
     $obj = new stdClass();
     Cpanel_Listner_Observer_GenericLogger::initLogger($obj, 1, array('level' => 'silent'));
     return array('host' => '1.1.1.1', 'user' => 'foo', 'listner' => $obj->listner);
 }