-
Notifications
You must be signed in to change notification settings - Fork 36
/
RoboFile.php
59 lines (50 loc) · 2.13 KB
/
RoboFile.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
require_once 'src/bootstrap.php';
class RoboFile extends \Robo\Tasks
{
// use \Robo\Task\Development\loadTasks;
use \Robo\Common\TaskIO;
public function __construct()
{
$this->opencart_config = [
'db_hostname' => 'localhost',
'db_username' => 'root',
'db_password' => 'root',
'db_database' => 'oc_travis_test_db',
'db_driver' => 'mysqli',
'username' => 'admin',
'password' => 'admin',
'email' => '[email protected]',
'http_server' => getenv('HTTP_SERVER')
];
}
public function opencartSetup()
{
$this->taskDeleteDir('www')->run();
$this->taskFileSystemStack()
->mirror('vendor/opencart/opencart/upload', 'www')
->copy('src/upload/system/config/test-config.php', 'www/system/config/test-config.php')
->copy('src/upload/system/library/session/test.php', 'www/system/library/session/test.php')
->copy('src/upload/admin/controller/startup/test_startup.php','www/admin/controller/startup/test_startup.php')
->chmod('www', 0777, 0000, true)
->run();
// Create new database, drop if exists already
try {
$conn = new PDO("mysql:host=" . $this->opencart_config['db_hostname'], $this->opencart_config['db_username'], $this->opencart_config['db_password']);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$conn->exec("DROP DATABASE IF EXISTS `" . $this->opencart_config['db_database'] . "`");
$conn->exec("CREATE DATABASE `" . $this->opencart_config['db_database'] . "`");
} catch (PDOException $e) {
$this->say("<error> Database error: " . $e->getMessage());
}
$conn = null;
$install = $this->taskExec('php')->arg('www/install/cli_install.php')->arg('install');
foreach ($this->opencart_config as $option => $value) {
$install->option($option, $value);
}
ob_start();
$install->run();
ob_end_clean();
$this->taskDeleteDir('www/install')->run();
}
}