public function testGetEventInstance() { $this->Events->something = 'foo'; $Event = EventCore::getInstance(); $this->assertTrue(isset($Event->something)); $result = $Event->something; $expected = 'foo'; $this->assertEquals($expected, $result); unset($Event); $this->assertFalse(isset($this->Event)); }
public function startTest() { $this->Event = EventCore::getInstance(); }
<?php /** * Load all the plugin dirs */ App::build(array('plugins' => array(APP . 'infinitas' . DS, APP . 'extensions' . DS))); /** * Load plugin events */ App::import('Libs', 'Events.Events'); EventCore::getInstance(); /** * Make sure the json defines are loaded. */ if (!defined('JSON_ERROR_NONE')) { define('JSON_ERROR_NONE', 0); } if (!defined('JSON_ERROR_DEPTH')) { define('JSON_ERROR_DEPTH', 1); } if (!defined('JSON_ERROR_CTRL_CHAR')) { define('JSON_ERROR_CTRL_CHAR', 3); } if (!defined('JSON_ERROR_SYNTAX')) { define('JSON_ERROR_SYNTAX', 4); } /** * Escape things for preg_match * * will escape a string for goind preg match. * http://www.php.net/manual/en/function.preg-replace.php#92456
/** * Loads and initialises an event class * * @param string $className * @param string $filename * */ private function __loadEventClass($className, $filename = false) { if ($filename === false) { $baseName = Inflector::underscore($className) . '.php'; $pluginName = Inflector::camelize(preg_replace('/_events.php$/', '', $baseName)); $pluginPath = App::pluginPath($pluginName); $filename = $pluginPath . $baseName; } if (!class_exists('LibsEvent')) { //App::Import('file', 'LibsEvent', true, array(), App::pluginPath('libs').'libs_events.php'); } App::Import('file', $className, true, array(), $filename); try { $_this =& EventCore::getInstance(); $_this->__eventClasses[$className] =& new $className(); return true; } catch (Exception $e) { return false; } }
public function startTest() { $this->Event = EventCore::getInstance(); $this->Cron = ClassRegistry::init('Crons.Cron'); }
/** * Extracts the plugin name out of the class name and caches the value * so that the strtolower and other stuff does not need to be called * so many times. * * @param string $className the name of the class being called * @return string the plugin being called. * @access private */ protected function _extractPluginName($className) { $_this = EventCore::getInstance(); if (!isset($_this->pluginNameCache->{$className})) { $_this->pluginNameCache->{$className} = substr($className, 0, strlen($className) - 6); } return $_this->pluginNameCache->{$className}; }