Skip to content

Commit

Permalink
moodlehq#128 - add Oracle support
Browse files Browse the repository at this point in the history
  • Loading branch information
jpahullo committed Aug 10, 2021
1 parent 4e920bb commit 7818aeb
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3
oracle:
image: moodlehq/moodle-db-oracle-r2
env:
ORACLE_DISABLE_ASYNCH_IO: true
ports:
- 1521:1521

strategy:
fail-fast: false
Expand Down
2 changes: 1 addition & 1 deletion src/Command/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function configure()
->addOption('repo', null, InputOption::VALUE_REQUIRED, 'Moodle repository to clone', $repo)
->addOption('branch', null, InputOption::VALUE_REQUIRED, 'Moodle git branch to clone, EG: MOODLE_29_STABLE', $branch)
->addOption('plugin', null, InputOption::VALUE_REQUIRED, 'Path to Moodle plugin', $plugin)
->addOption('db-type', null, InputOption::VALUE_REQUIRED, 'Database type, mysqli, pgsql or mariadb', $type)
->addOption('db-type', null, InputOption::VALUE_REQUIRED, 'Database type, mysqli, pgsql, mariadb or oci', $type)
->addOption('db-user', null, InputOption::VALUE_REQUIRED, 'Database user')
->addOption('db-pass', null, InputOption::VALUE_REQUIRED, 'Database pass', '')
->addOption('db-name', null, InputOption::VALUE_REQUIRED, 'Database name', 'moodle')
Expand Down
4 changes: 2 additions & 2 deletions src/Installer/Database/DatabaseResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ private function resolveDatabaseType($type)
return $database;
}
}
throw new \DomainException(sprintf('Unknown database type (%s). Please use mysqli, pgsql or mariadb.', $type));
throw new \DomainException(sprintf('Unknown database type (%s). Please use mysqli, pgsql, mariadb or oci.', $type));
}

/**
* @return AbstractDatabase[]
*/
private function getDatabases()
{
return [new MySQLDatabase(), new PostgresDatabase(), new MariaDBDatabase()];
return [new MySQLDatabase(), new PostgresDatabase(), new MariaDBDatabase(), new OracleDatabase()];
}
}
2 changes: 1 addition & 1 deletion src/Installer/Database/OracleDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ class OracleDatabase extends AbstractDatabase {
public $type = 'oci';

public function getCreateDatabaseCommand() {
// For Oracle 12 or superior.
return "echo 'All done!'";
}
}
4 changes: 4 additions & 0 deletions tests/Installer/Database/DatabaseResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function testType()
'MoodlePluginCI\Installer\Database\MariaDBDatabase',
$resolver->resolveDatabase('mariadb')
);
$this->assertInstanceOf(
'MoodlePluginCI\Installer\Database\OracleDatabase',
$resolver->resolveDatabase('oci')
);
}

public function testTypeError()
Expand Down
30 changes: 30 additions & 0 deletions tests/Installer/Database/OracleDatabaseTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

/*
* This file is part of the Moodle Plugin CI package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* Copyright (c) 2018 Blackboard Inc. (http://www.blackboard.com)
* License http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace MoodlePluginCI\Tests\Installer\Database;

use MoodlePluginCI\Installer\Database\OracleDatabase;

class OracleDatabaseTest extends \PHPUnit_Framework_TestCase
{
public function testGetCreateDatabaseCommand()
{
$database = new OracleDatabase();
$database->name = 'TestName';
$database->user = 'TestUser';
$database->pass = 'TestPass';
$database->host = 'TestHost';

$expected = 'echo \'All done!\'';
$this->assertSame($expected, $database->getCreateDatabaseCommand());
}
}

0 comments on commit 7818aeb

Please sign in to comment.