示例#1
0
	/**
	 * @todo Implement testAbort().
	 */
	public function testAbortDefault()
	{
		$this->saveFactoryState();

		$newDbo = $this->getMock('test');

		JFactory::$database = &$newDbo;

		$adapterMock = $this->getMock('test', array('_rollback_testtype'));

		$adapterMock->expects($this->once())
			->method('_rollback_testtype')
			->with($this->equalTo(array('type' => 'testtype')))
			->will($this->returnValue(true));


		//$this->object = JInstaller::getInstance();
		$this->object = new JInstaller;

		$this->object->setAdapter('testadapter', $adapterMock);

		$this->object->pushStep(array('type' => 'testtype'));

		$this->assertThat(
			$this->object->abort(null, 'testadapter'),
			$this->isTrue()
		);

		$this->restoreFactoryState();
	}
 /**
  * Set an installer adapter by name
  *
  * @access	public
  * @param	string	$name		Adapter name
  * @param	object	$adapter	Installer adapter object
  * @return	boolean True if successful
  * @since	1.5
  */
 public function setAdapter($name, &$adapter = null, $options = array())
 {
     if (!is_object($adapter)) {
         // Try to load the adapter object
         $fullpath = dirname(__FILE__) . DS . 'adapters' . DS . strtolower($name) . '.php';
         if (!file_exists($fullpath)) {
             return false;
         }
         // Try to load the adapter object
         require_once $fullpath;
         $class = "RokInstaller" . ucfirst($name);
         if (!class_exists($class)) {
             return false;
         }
         $adapter = new $class($this, $this->_db, $options);
     }
     if (!is_object($adapter)) {
         $ret = parent::setAdapter($name, $adapter);
         if (!$ret) {
             return $ret;
         }
     }
     $this->_adapters[$name] =& $adapter;
     return true;
 }
 /**
  * Test...
  *
  * @covers  JInstaller::abort
  *
  * @return void
  */
 public function testAbortDefault()
 {
     $adapterMock = $this->getMock('test', array('_rollback_testtype'));
     $adapterMock->expects($this->once())->method('_rollback_testtype')->with($this->equalTo(array('type' => 'testtype')))->will($this->returnValue(true));
     $this->object->setAdapter('testadapter', $adapterMock);
     $this->object->pushStep(array('type' => 'testtype'));
     $this->assertThat($this->object->abort(null, 'testadapter'), $this->isTrue());
 }
示例#4
0
 public function install()
 {
     foreach ($this->manifests as $i => $manifest) {
         $installer = new JInstaller();
         $installer->setPath('source', $this->parent->getPath('source'));
         //This is essentially what method="upgrade" does
         $installer->_overwrite = true;
         $xml =& JFactory::getXMLParser('Simple');
         $xml->loadFile($manifest);
         $installer->_manifest = $xml;
         $installer->setPath('manifest', $manifest);
         $root = $xml->document;
         $type = $root->attributes('type');
         //Don't install if the type isn't defined
         if (!$type) {
             unset($this->manifests[$i]);
             continue;
         }
         // Lazy load the adapter
         if (!isset($installer->_adapters[$type]) || !is_object($installer->_adapters[$type])) {
             $installer->setAdapter($type);
         }
         $installer->_adapters[$type]->install();
         $installer->install($this->parent->getPath('source'));
     }
     if (JFolder::exists($this->parent->getPath('source') . '/nooku')) {
         $this->manifests[] = $manifest = $this->parent->getPath('source') . '/nooku/manifest.xml';
         $installer = new JInstaller();
         $installer->setPath('source', $this->parent->getPath('source') . '/nooku');
         //This is essentially what method="upgrade" does
         $installer->_overwrite = true;
         $xml =& JFactory::getXMLParser('Simple');
         $xml->loadFile($manifest);
         $installer->_manifest = $xml;
         $installer->setPath('manifest', $manifest);
         $root = $xml->document;
         $type = $root->attributes('type');
         // Lazy load the adapter
         if (!isset($installer->_adapters[$type]) || !is_object($installer->_adapters[$type])) {
             $installer->setAdapter($type);
         }
         $installer->_adapters[$type]->install();
         $installer->install($this->parent->getPath('source'));
     }
     return $this;
 }
示例#5
0
 /**
  * Set an installer adapter by name
  *
  * @access	public
  * @param	string	$name		Adapter name
  * @param	object	$adapter	Installer adapter object
  * @return	boolean True if successful
  * @since	1.5
  */
 function setAdapter($name, $adapter = null)
 {
     $ret = parent::setAdapter($name, $adapter);
     if (!$ret) {
         return $ret;
     }
     if (!is_object($adapter)) {
         // Try to load the adapter object
         $adapter_file = dirname(__FILE__) . DS . 'adapters' . DS . strtolower($name) . '.php';
         if (JFile::exists($adapter_file)) {
             @(include_once $adapter_file);
             $class = 'RokInstaller' . ucfirst($name);
             if (!class_exists($class)) {
                 return false;
             }
             $adapter = new $class($this);
             $adapter->parent =& $this;
             $this->_adapters[strtolower($name)] =& $adapter;
         }
     }
     return true;
 }
 /**
  * method to run after an install/update/uninstall method
  *
  * @return void
  */
 public function postflight($type, $parent)
 {
     /* Install redform plugin */
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $db =& JFactory::getDBO();
     JFolder::copy(JPATH_SITE . DS . 'administrator' . DS . 'components' . DS . 'com_redevent' . DS . 'extras' . DS . 'redform', JPATH_SITE . DS . 'tmp' . DS . 'redform_redevent', '', true);
     $installer = new JInstaller();
     $installer->setAdapter('plugin');
     if (!$installer->install(JPATH_SITE . DS . 'tmp' . DS . 'redform_redevent')) {
         echo JText::_('COM_REDEVENT_Plugin_install_failed') . $installer->getError() . '<br />';
     } else {
         // autopublish the plugin
         $query = ' UPDATE #__extensions SET enabled = 1 WHERE folder = ' . $db->Quote('redform_integration') . ' AND element = ' . $db->Quote('redevent');
         $db->setQuery($query);
         if ($db->query()) {
             echo JText::_('COM_REDEVENT_Succesfully_installed_redform_integration_plugin') . '<br />';
         } else {
             echo JText::_('COM_REDEVENT_Error_publishing_redform_integration_plugin') . '<br />';
         }
     }
 }