Passed
Push — master ( 4230b8...ce562a )
by Joao
01:53
created

SqlServerDblibDatabaseTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 18
c 1
b 0
f 0
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 16 3
A getExpectedUsersVersion1() 0 9 2
1
<?php
2
3
use ByJG\DbMigration\Database\DblibDatabase;
4
use ByJG\DbMigration\Migration;
5
use ByJG\Util\Uri;
6
7
require_once 'BaseDatabase.php';
8
9
/**
10
 * @requires extension pdo_dblib
11
 */
12
class SqlServerDblibDatabaseTest extends BaseDatabase
13
{
14
    /**
15
     * @var Migration
16
     */
17
    protected $migrate = null;
18
19
    protected $scheme = "dblib";
20
21
    public function setUp(): void
22
    {
23
        $host = getenv('MSSQL_TEST_HOST');
24
        if (empty($host)) {
25
            $host = "127.0.0.1";
26
        }
27
        $password = getenv('MSSQL_PASSWORD');
28
        if (empty($password)) {
29
            $password = 'Pa55word';
30
        }
31
32
        $uri = $this->scheme . "://sa:${password}@${host}/migratedatabase";
33
34
        $this->migrate = new Migration(new Uri($uri), __DIR__ . '/../example/sql_server', true, $this->migrationTable);
35
        $this->migrate->registerDatabase($this->scheme, DblibDatabase::class);
36
        parent::setUp();
37
    }
38
39
    public function getExpectedUsersVersion1()
40
    {
41
        if ($this->scheme == "sqlsrv") {
42
            return parent::getExpectedUsersVersion1();
43
        }
44
45
        return [
46
            ["id" => 1, "name" => 'John Doe', 'createdate' => '2016-01-10 00:00:00'],
47
            ["id" => 2, "name" => 'Jane Doe', 'createdate' => '2015-12-30 00:00:00']
48
        ];
49
    }
50
51
}
52