/** * This test is weak and may need removal at some point * * @covers JInstaller::abort * * @expectedException RuntimeException * * @return void */ public function testAbortDebug() { $configMock = $this->getMock('test', array('get')); $configMock->expects($this->atLeastOnce())->method('get')->with($this->equalTo('debug'))->will($this->returnValue(true)); JFactory::$config = $configMock; $this->assertThat($this->object->abort(), $this->isTrue()); }
/** * This test is weak and may need removal at some point */ public function testAbortDebug() { $configMock = $this->getMock('test', array('get')); $configMock->expects($this->atLeastOnce()) ->method('get') ->will($this->returnValue(true)); $this->setExpectedError(array('code' => 500)); //$this->object = JInstaller::getInstance(); $this->saveFactoryState(); $newDbo = $this->getMock('test'); JFactory::$database = &$newDbo; $this->object = new JInstaller; JFactory::$config = $configMock; $this->assertThat( $this->object->abort(), $this->isTrue() ); $this->restoreFactoryState(); }
/** * Test that an abort message results in a raised warning */ public function testAbortMsg() { $this->saveFactoryState(); $newDbo = $this->getMock('test'); JFactory::$database =& $newDbo; //$this->object = JInstaller::getInstance(); $this->object = new JInstaller(); $this->setExpectedError(array('code' => 100, 'message' => 'Warning Text')); $this->assertThat($this->object->abort('Warning Text'), $this->isTrue()); $this->restoreFactoryState(); }
/** * Generic install method for extensions * * @return boolean True on success * * @since 3.4 */ public function install() { // Get the extension's description $description = (string) $this->getManifest()->description; if ($description) { $this->parent->message = JText::_($description); } else { $this->parent->message = ''; } // Set the extension's name and element $this->name = $this->getName(); $this->element = $this->getElement(); /* * --------------------------------------------------------------------------------------------- * Extension Precheck and Setup Section * --------------------------------------------------------------------------------------------- */ // Setup the install paths and perform other prechecks as necessary try { $this->setupInstallPaths(); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } // Check to see if an extension by the same name is already installed. try { $this->checkExistingExtension(); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } // Check if the extension is present in the filesystem try { $this->checkExtensionInFilesystem(); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } // If we are on the update route, run any custom setup routines if ($this->route == 'update') { try { $this->setupUpdates(); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } } /* * --------------------------------------------------------------------------------------------- * Installer Trigger Loading * --------------------------------------------------------------------------------------------- */ $this->setupScriptfile(); try { $this->triggerManifestScript('preflight'); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } /* * --------------------------------------------------------------------------------------------- * Filesystem Processing Section * --------------------------------------------------------------------------------------------- */ // If the extension directory does not exist, lets create it try { $this->createExtensionRoot(); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } // Copy all necessary files try { $this->copyBaseFiles(); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } // Parse optional tags $this->parseOptionalTags(); /* * --------------------------------------------------------------------------------------------- * Database Processing Section * --------------------------------------------------------------------------------------------- */ try { $this->storeExtension(); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } try { $this->parseQueries(); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } // Run the custom method based on the route try { $this->triggerManifestScript($this->route); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } /* * --------------------------------------------------------------------------------------------- * Finalization and Cleanup Section * --------------------------------------------------------------------------------------------- */ try { $this->finaliseInstall(); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } // And now we run the postflight try { $this->triggerManifestScript('postflight'); } catch (RuntimeException $e) { // Install failed, roll back changes $this->parent->abort($e->getMessage()); return false; } return $this->extension->extension_id; }
public function abort($msg = null, $type = null) { $this->_error = $msg; return parent::abort(null, $type); }
/** * Test that if the type is not good we fall back properly * * @covers JInstaller::abort * * @return void */ public function testAbortBadType() { $this->object->pushStep(array('type' => 'badstep')); $this->assertFalse($this->object->abort(null, false)); }