forked from moodlehq/moodle-plugin-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
783ec09
commit 05c4bc5
Showing
6 changed files
with
81 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?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 2024 Justus Dieckmann | ||
* License http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace MoodlePluginCI\Installer\Database; | ||
|
||
/** | ||
* MSSQL Database. | ||
*/ | ||
class MSSQLDatabase extends AbstractDatabase | ||
{ | ||
public string $user = 'sa'; | ||
public string $type = 'sqlsrv'; | ||
|
||
public function getCreateDatabaseCommand(): array | ||
{ | ||
$host = $this->host; | ||
if (!empty($this->port)) { | ||
$host .= ",$this->port"; | ||
} | ||
|
||
return array_filter([ | ||
'sqlcmd', | ||
'-U', | ||
$this->user, | ||
!empty($this->pass) ? '-P' : '', | ||
!empty($this->pass) ? $this->pass : '', | ||
'-S', | ||
$host, | ||
'-Q', | ||
sprintf('CREATE DATABASE %s COLLATE Latin1_General_CI_AI;', $this->name), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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\MSSQLDatabase; | ||
|
||
class MSSQLDatabaseTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testGetCreateDatabaseCommand() | ||
{ | ||
$database = new MSSQLDatabase(); | ||
$database->name = 'TestName'; | ||
$database->user = 'TestUser'; | ||
$database->pass = 'TestPass'; | ||
$database->host = 'TestHost'; | ||
|
||
$expected = 'sqlcmd -U TestUser -P TestPass -S TestHost -Q CREATE DATABASE TestName COLLATE Latin1_General_CI_AI;'; | ||
$this->assertSame($expected, implode(' ', $database->getCreateDatabaseCommand())); | ||
} | ||
} |