示例#1
0
 /**
  * Indirectly test CroogoEventManager::detachPluginSubscribers()
  * triggerred by calling CroogoPlugin::unload(null)
  */
 public function testDetachPluginSubscribers()
 {
     $loaded = CakePlugin::loaded('Shops');
     $this->assertNotEmpty($loaded);
     $eventName = 'Controller.Users.activationFailure';
     $event = Croogo::dispatchEvent($eventName, $this->Users);
     $this->assertTrue($event->result, sprintf('Event: %s', $eventName));
     CroogoPlugin::unload('Shops');
     $eventName = 'Controller.Users.activationFailure';
     $event = Croogo::dispatchEvent($eventName, $this->Users);
     $this->assertNull($event->result, sprintf('Event: %s', $eventName));
 }
示例#2
0
 /**
  * Deactivate plugin
  *
  * @param string $plugin Plugin name
  * @return boolean true when successful, false or error message when failed
  */
 public function deactivate($plugin)
 {
     if (!CakePlugin::loaded($plugin)) {
         return __d('croogo', 'Plugin "%s" is not active.', $plugin);
     }
     $pluginActivation = $this->getActivator($plugin);
     if (!isset($pluginActivation) || isset($pluginActivation) && method_exists($pluginActivation, 'beforeDeactivation') && $pluginActivation->beforeDeactivation($this->_Controller)) {
         $this->removeBootstrap($plugin);
         if (isset($pluginActivation) && method_exists($pluginActivation, 'onDeactivation')) {
             $pluginActivation->onDeactivation($this->_Controller);
         }
         CroogoPlugin::unload($plugin);
         Cache::delete('file_map', '_cake_core_');
         return true;
     } else {
         return __d('croogo', 'Plugin could not be deactivated. Please, try again.');
     }
 }
示例#3
0
 /**
  * testUsedBy
  */
 public function testUsedBy()
 {
     Cache::delete('pluginDeps', 'cached_settings');
     CroogoPlugin::load('Widgets');
     CroogoPlugin::load('Editors');
     CroogoPlugin::load('Articles');
     CroogoPlugin::cacheDependencies();
     $usedBy = $this->CroogoPlugin->usedBy('Widgets');
     $this->assertTrue(in_array('Articles', $usedBy));
     $this->assertTrue(in_array('Editors', $usedBy));
     CroogoPlugin::unload('Articles');
     CroogoPlugin::unload('Editors');
     CroogoPlugin::unload('Widgets');
 }