/** * install the database * * @since 3.0.0 * * @return boolean */ protected function _database() { $installer = new Installer($this->_config); $installer->init(); $installer->rawDrop(); return Db::getStatus() === 1; }
/** * tearDown * * @since 3.0.0 */ public function tearDown() { $installer = new Installer($this->_config); $installer->init(); $installer->rawDrop(); $this->_config->set('dbPrefix', $this->_configArray['dbPrefix']); }
/** * install the database * * @since 3.0.0 * * @param array $optionArray * * @return boolean */ protected function _database($optionArray = []) { $adminName = $this->prompt('admin-name', $optionArray); $adminUser = $this->prompt('admin-user', $optionArray); $adminPassword = $this->prompt('admin-password', $optionArray); $adminEmail = $this->prompt('admin-email', $optionArray); if ($adminName && $adminUser && $adminPassword && $adminEmail) { $installer = new Installer($this->_config); $installer->init(); $installer->rawCreate(); $installer->insertData(['adminName' => $adminName, 'adminUser' => $adminUser, 'adminPassword' => $adminPassword, 'adminEmail' => $adminEmail]); return Db::getStatus() === 2; } return false; }
/** * reinstall * * @since 2.4.0 */ protected static function _reinstall() { $installer = new Installer(GlobalConfig::getInstance()); $installer->init(); $installer->rawDrop(); $installer->rawCreate(); $installer->insertData(array('adminName' => 'Admin', 'adminUser' => 'admin', 'adminPassword' => 'admin', 'adminEmail' => 'admin@localhost')); /* process modules */ foreach (self::$_config['modules'] as $key => $value) { if (is_dir('modules/' . $key)) { $module = new $value(); $module->install(); } } /* access and filter */ Db::forTablePrefix('groups')->findMany()->set(array('modules' => null, 'filter' => 1))->save(); }
/** * testRawDrop * * @since 2.4.0 */ public function testRawDrop() { /* setup */ $installer = new Installer(); $installer->init($this->_config); $installer->rawDrop(); /* actual */ $actual = Db::countTablePrefix(); /* compare */ $this->assertEquals(0, $actual); }
/** * install the database * * @since 3.0.0 * * @param array $installArray * * @return array */ protected function _install($installArray = []) { $adminName = $installArray['adminName']; $adminUser = $installArray['adminUser']; $adminPassword = $installArray['adminPassword']; $adminEmail = $installArray['adminEmail']; if ($adminName && $adminUser && $adminPassword && $adminEmail) { $installer = new Installer($this->_config); $installer->init(); $installer->rawDrop(); $installer->rawCreate(); $installer->insertData(['adminName' => $installArray['adminName'], 'adminUser' => $installArray['adminUser'], 'adminPassword' => $installArray['adminPassword'], 'adminEmail' => $installArray['adminEmail']]); return Db::getStatus() === 2; } return false; }
/** * testModule * * @since 3.0.0 */ public function testModule() { /* setup */ $installer = new Installer($this->_config); $installer->init(); $installer->rawCreate(); $this->_request->setServer('argv', ['console.php', 'uninstall', 'module', '--alias', 'TestDummy']); $uninstallCommand = new Command\Uninstall($this->_registry, $this->_request, $this->_config); /* actual */ $actual = $uninstallCommand->run('cli'); /* compare */ $this->assertTrue($actual); }