Skip to content

Commit ad0751d

Browse files
authored
Merge pull request #154 from puneet0191/customDbDetails
Adding support for Custom Db name and Prefix
2 parents 03c1335 + 8d60fe3 commit ad0751d

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

src/JoomlaBrowser.php

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,25 @@ public function doFrontendLogout()
196196
/**
197197
* Installs Joomla
198198
*
199+
* @param string|null $databaseName Optional Database Name. If not passed the one in acceptance.suite.yml will be used
200+
* @param string|null $databasePrefix Optional Database Prefix. If not passed the one in acceptance.suite.yml will be used
201+
*
199202
* @return void
200203
*
201204
* @since 3.0.0
202205
*/
203-
public function installJoomla()
206+
public function installJoomla($databaseName = null, $databasePrefix = null)
204207
{
208+
if (is_null($databaseName))
209+
{
210+
$databaseName = $this->config['database name'];
211+
}
212+
213+
if (is_null($databasePrefix))
214+
{
215+
$databasePrefix = $this->config['database prefix'];
216+
}
217+
205218
$this->debug('I open Joomla Installation Configuration Page');
206219
$this->amOnPage('/installation/index.php');
207220
$this->debug('I check that FTP tab is not present in installation. Otherwise it means that I have not enough '
@@ -258,9 +271,9 @@ public function installJoomla()
258271
$this->debug('I fill Database Password');
259272
$this->fillField(['id' => 'jform_db_pass'], $this->config['database password']);
260273
$this->debug('I fill Database Name');
261-
$this->fillField(['id' => 'jform_db_name'], $this->config['database name']);
274+
$this->fillField(['id' => 'jform_db_name'], $databaseName);
262275
$this->debug('I fill Database Prefix');
263-
$this->fillField(['id' => 'jform_db_prefix'], $this->config['database prefix']);
276+
$this->fillField(['id' => 'jform_db_prefix'], $databasePrefix);
264277
$this->debug('I click Remove Old Database ');
265278
$this->selectOptionInRadioField('Old Database Process', 'Remove');
266279
$this->debug('I click Next');
@@ -286,13 +299,16 @@ public function installJoomla()
286299
/**
287300
* Install Joomla removing the Installation folder at the end of the execution
288301
*
302+
* @param string|null $databaseName Optional Database Name. If not passed the one in acceptance.suite.yml will be used
303+
* @param string|null $databasePrefix Optional Database Prefix. If not passed the one in acceptance.suite.yml will be used
304+
*
289305
* @return void
290306
*
291307
* @since 3.0.0
292308
*/
293-
public function installJoomlaRemovingInstallationFolder()
309+
public function installJoomlaRemovingInstallationFolder($databaseName = null, $databasePrefix = null)
294310
{
295-
$this->installJoomla();
311+
$this->installJoomla($databaseName, $databasePrefix);
296312

297313
$this->debug('Removing Installation Folder');
298314
$this->click(['xpath' => "//input[@value='Remove \"installation\" folder']"]);
@@ -308,22 +324,24 @@ public function installJoomlaRemovingInstallationFolder()
308324
* Installs Joomla with Multilingual Feature active
309325
*
310326
* @param array $languages Array containing the language names to be installed
327+
* @param string|null $databaseName Optional Database Name. If not passed the one in acceptance.suite.yml will be used
328+
* @param string|null $databasePrefix Optional Database Prefix. If not passed the one in acceptance.suite.yml will be used
311329
*
312330
* @example: $this->installJoomlaMultilingualSite(['Spanish', 'French']);
313331
*
314332
* @return void
315333
*
316334
* @since 3.0.0
317335
*/
318-
public function installJoomlaMultilingualSite($languages = array())
336+
public function installJoomlaMultilingualSite($languages = array(), $databaseName = null, $databasePrefix = null)
319337
{
320338
if (!$languages)
321339
{
322340
// If no language is passed French will be installed by default
323341
$languages[] = 'French';
324342
}
325343

326-
$this->installJoomla();
344+
$this->installJoomla($databaseName, $databasePrefix);
327345

328346
$this->debug('I go to Install Languages page');
329347
$this->click(['id' => 'instLangs']);

0 commit comments

Comments
 (0)