Skip to content

Commit fb13440

Browse files
committed
Add InstallJoomla Method
1 parent e5e74b7 commit fb13440

File tree

1 file changed

+78
-37
lines changed

1 file changed

+78
-37
lines changed

src/JoomlaBrowser.php

Lines changed: 78 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,82 @@
66

77
class JoomlaBrowser extends WebDriver
88
{
9-
/**
10-
* The module required fields, to be set in the suite .yml configuration file.
11-
*
12-
* @var array
13-
*/
14-
protected $requiredFields = array('username', 'password', 'joomlaurl');
15-
16-
/**
17-
* The admin absolute URL.
18-
*
19-
* @var [type]
20-
*/
21-
protected $adminLoginUrl;
22-
23-
/**
24-
* Initializes the module setting the properties values.
25-
*
26-
* @return void
27-
*/
28-
public function _initialize()
29-
{
30-
parent::_initialize();
31-
$this->adminLoginUrl = $this->config['joomlaurl'] . '/administrator/index.php';
32-
}
33-
34-
/**
35-
* Function to Do Admin Login In Joomla!
36-
*
37-
* @return void
38-
*/
39-
public function doAdminLogin()
40-
{
41-
$this->amOnUrl($this->adminLoginUrl);
42-
$this->fillField('username', $this->config['username']);
43-
$this->fillField('Password', $this->config['password']);
44-
$this->click('Log in');
45-
}
9+
/**
10+
* The module required fields, to be set in the suite .yml configuration file.
11+
*
12+
* @var array
13+
*/
14+
protected $requiredFields = array(
15+
'url',
16+
'browser',
17+
'username',
18+
'password'
19+
);
20+
21+
/**
22+
* Function to Do Admin Login In Joomla!
23+
*
24+
* @return void
25+
*/
26+
public function doAdminLogin()
27+
{
28+
$I = $this;
29+
$I->amOnPage('/administrator/index.php');
30+
$I->fillField('username', $this->config['username']);
31+
$I->fillField('Password', $this->config['password']);
32+
$I->click('Log in');
33+
$I->waitForText('Control Panel', 10, 'H1');
34+
}
35+
36+
public function installJoomla()
37+
{
38+
$I = $this;
39+
40+
// Install Joomla CMS');
41+
42+
// @todo: activate the filesystem module
43+
//$I->expect('no configuration.php is in the Joomla CMS folder');
44+
//$I->dontSeeFileFound('configuration.php', $this->config['Joomla folder')];
45+
$I->amOnPage('/installation/index.php');
46+
47+
// I Wait for the text Main Configuration, meaning that the page is loaded
48+
$I->waitForText('Main Configuration', 10, 'h3');
49+
50+
$I->click("//div[@id='jform_language_chzn']/a"); // Language Selector
51+
$I->click("//li[text()='English (United Kingdom)']"); // English (United Kingdom)
52+
$I->fillField('Site Name', 'Joomla CMS test');
53+
$I->fillField('Description', 'Site for testing Joomla CMS');
54+
55+
// I get the configuration from acceptance.suite.yml (see: tests/_support/acceptancehelper.php)
56+
$I->fillField('Admin Email', $this->config['admin email']);
57+
$I->fillField('Admin Username', $this->config['username']);
58+
$I->fillField('Admin Password', $this->config['password']);
59+
$I->fillField('Confirm Admin Password', $this->config['password']);
60+
$I->click("//fieldset[@id='jform_site_offline']/label[2]"); // ['No Site Offline']
61+
$I->click('Next');
62+
// I Fill the form for creating the Joomla site Database'
63+
$I->waitForText('Database Configuration', 10, 'h3');
64+
65+
$I->selectOption('#jform_db_type', $this->config['database type']);
66+
$I->fillField('Host Name', $this->config['database host']);
67+
$I->fillField('Username', $this->config['database user']);
68+
$I->fillField('Password', $this->config['database password']);
69+
$I->fillField('Database Name', $this->config['database name']);
70+
$I->fillField('Table Prefix', $this->config['database prefix']);
71+
$I->click("//label[@for='jform_db_old1']"); // Remove Old Database button
72+
$I->click('Next');
73+
74+
// I Fill the form for creating the Joomla site database
75+
$I->waitForText('Finalisation', 10, 'h3');
76+
77+
if ($this->config['install sample data']) :
78+
$I->selectOption('#jform_sample_file', $this->config['sample data']);
79+
else :
80+
$I->selectOption('#jform_sample_file', '#jform_sample_file0'); // No sample data
81+
endif;
82+
$I->click('Install');
83+
84+
// Wait while Joomla gets installed
85+
$I->waitForText('Congratulations! Joomla! is now installed.', 30, 'h3');
86+
}
4687
}

0 commit comments

Comments
 (0)