Skip to content

Commit 61bc21b

Browse files
committed
add tests for connections
1 parent 58be4c3 commit 61bc21b

File tree

9 files changed

+31
-34
lines changed

9 files changed

+31
-34
lines changed

src/Configuration/Connections/MysqlConnection.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace LaravelDoctrine\ORM\Configuration\Connections;
66

7+
use function array_merge;
8+
79
class MysqlConnection extends Connection
810
{
911
/**
@@ -13,9 +15,7 @@ class MysqlConnection extends Connection
1315
*/
1416
public function resolve(array $settings = []): array
1517
{
16-
$overrides = [
17-
'driver' => 'pdo_mysql',
18-
];
18+
$overrides = ['driver' => 'pdo_mysql'];
1919

2020
// Map Laravel keys to Doctrine DBAL keys
2121
if (isset($settings['database'])) {
@@ -34,7 +34,7 @@ public function resolve(array $settings = []): array
3434
}
3535

3636
// Set default for defaultTableOptions if not present
37-
if (!isset($settings['defaultTableOptions'])) {
37+
if (! isset($settings['defaultTableOptions'])) {
3838
$overrides['defaultTableOptions'] = [];
3939
}
4040

src/Configuration/Connections/OracleConnection.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace LaravelDoctrine\ORM\Configuration\Connections;
66

7-
use Illuminate\Support\Arr;
7+
use function array_merge;
88

99
class OracleConnection extends Connection
1010
{
@@ -15,9 +15,7 @@ class OracleConnection extends Connection
1515
*/
1616
public function resolve(array $settings = []): array
1717
{
18-
$overrides = [
19-
'driver' => 'oci8',
20-
];
18+
$overrides = ['driver' => 'oci8'];
2119

2220
// Map Laravel keys to Doctrine DBAL keys
2321
if (isset($settings['database'])) {
@@ -41,7 +39,7 @@ public function resolve(array $settings = []): array
4139
}
4240

4341
// Set default for defaultTableOptions if not present
44-
if (!isset($settings['defaultTableOptions'])) {
42+
if (! isset($settings['defaultTableOptions'])) {
4543
$overrides['defaultTableOptions'] = [];
4644
}
4745

src/Configuration/Connections/PgsqlConnection.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace LaravelDoctrine\ORM\Configuration\Connections;
66

7-
use Illuminate\Support\Arr;
7+
use function array_merge;
88

99
class PgsqlConnection extends Connection
1010
{
@@ -15,9 +15,7 @@ class PgsqlConnection extends Connection
1515
*/
1616
public function resolve(array $settings = []): array
1717
{
18-
$overrides = [
19-
'driver' => 'pdo_pgsql',
20-
];
18+
$overrides = ['driver' => 'pdo_pgsql'];
2119

2220
// Map Laravel keys to Doctrine DBAL keys
2321
if (isset($settings['database'])) {
@@ -36,7 +34,7 @@ public function resolve(array $settings = []): array
3634
}
3735

3836
// Set default for defaultTableOptions if not present
39-
if (!isset($settings['defaultTableOptions'])) {
37+
if (! isset($settings['defaultTableOptions'])) {
4038
$overrides['defaultTableOptions'] = [];
4139
}
4240

src/Configuration/Connections/SqliteConnection.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Illuminate\Support\Arr;
88
use Illuminate\Support\Str;
99

10+
use function array_merge;
11+
1012
class SqliteConnection extends Connection
1113
{
1214
/**
@@ -16,11 +18,9 @@ class SqliteConnection extends Connection
1618
*/
1719
public function resolve(array $settings = []): array
1820
{
19-
$overrides = [
20-
'driver' => 'pdo_sqlite',
21-
];
21+
$overrides = ['driver' => 'pdo_sqlite'];
2222

23-
$overrides['memory'] = $this->isMemory($settings);
23+
$overrides['memory'] = $this->isMemory($settings);
2424

2525
// Map Laravel keys to Doctrine DBAL keys
2626
if (isset($settings['database'])) {
@@ -32,14 +32,14 @@ public function resolve(array $settings = []): array
3232
$overrides['user'] = $settings['username'];
3333
unset($settings['username']);
3434
}
35-
35+
3636
if (isset($settings['options'])) {
3737
$overrides['driverOptions'] = $settings['options'];
3838
unset($settings['options']);
3939
}
4040

4141
// Set default for defaultTableOptions if not present
42-
if (!isset($settings['defaultTableOptions'])) {
42+
if (! isset($settings['defaultTableOptions'])) {
4343
$overrides['defaultTableOptions'] = [];
4444
}
4545

src/Configuration/Connections/SqlsrvConnection.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
namespace LaravelDoctrine\ORM\Configuration\Connections;
66

7-
use Illuminate\Support\Arr;
8-
97
use function array_merge;
108

119
class SqlsrvConnection extends Connection
@@ -17,9 +15,7 @@ class SqlsrvConnection extends Connection
1715
*/
1816
public function resolve(array $settings = []): array
1917
{
20-
$overrides = [
21-
'driver' => 'pdo_sqlsrv',
22-
];
18+
$overrides = ['driver' => 'pdo_sqlsrv'];
2319

2420
// Map Laravel keys to Doctrine DBAL keys
2521
if (isset($settings['database'])) {
@@ -47,7 +43,7 @@ public function resolve(array $settings = []): array
4743
}
4844

4945
// Set default for defaultTableOptions if not present
50-
if (!isset($settings['defaultTableOptions'])) {
46+
if (! isset($settings['defaultTableOptions'])) {
5147
$overrides['defaultTableOptions'] = [];
5248
}
5349

tests/Feature/Configuration/Connections/OracleConnectionTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,28 @@ public function testCanResolve(): void
2929
$resolved = $this->connection->resolve([
3030
'driver' => 'oci8',
3131
'host' => 'host',
32+
'service_name' => 'service_name',
3233
'database' => 'database',
3334
'username' => 'username',
3435
'password' => 'password',
3536
'charset' => 'charset',
3637
'port' => 'port',
3738
'prefix' => 'prefix',
38-
'defaultTableOptions' => [],
39+
'options' => [],
3940
'persistent' => 'persistent',
4041
]);
4142

4243
$this->assertEquals('oci8', $resolved['driver']);
4344
$this->assertEquals('host', $resolved['host']);
45+
$this->assertEquals('service_name', $resolved['servicename']);
4446
$this->assertEquals('database', $resolved['dbname']);
4547
$this->assertEquals('username', $resolved['user']);
4648
$this->assertEquals('password', $resolved['password']);
4749
$this->assertEquals('charset', $resolved['charset']);
4850
$this->assertEquals('port', $resolved['port']);
4951
$this->assertEquals('prefix', $resolved['prefix']);
5052
$this->assertCount(0, $resolved['defaultTableOptions']);
53+
$this->assertCount(0, $resolved['driverOptions']);
5154
$this->assertEquals('persistent', $resolved['persistent']);
5255
}
5356

tests/Feature/Configuration/Connections/PgsqlConnectionTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public function testCanResolve(): void
4141
'sslrootcert' => 'sslrootcert',
4242
'sslcrl' => 'sslcrl',
4343
'gssencmode' => 'gssencmode',
44-
'defaultTableOptions' => [],
45-
'driverOptions' => [],
44+
'application_name' => 'application_name',
45+
'options' => [],
4646
]);
4747

4848
$this->assertEquals('pdo_pgsql', $resolved['driver']);
@@ -59,6 +59,7 @@ public function testCanResolve(): void
5959
$this->assertEquals('sslcrl', $resolved['sslcrl']);
6060
$this->assertEquals('gssencmode', $resolved['gssencmode']);
6161
$this->assertEquals('prefix', $resolved['prefix']);
62+
$this->assertEquals('application_name', $resolved['application_name']);
6263
$this->assertCount(0, $resolved['defaultTableOptions']);
6364
$this->assertCount(0, $resolved['driverOptions']);
6465
}

tests/Feature/Configuration/Connections/SqliteConnectionTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public function testCanResolve(): void
3232
'username' => 'username',
3333
'password' => 'password',
3434
'prefix' => 'prefix',
35-
'defaultTableOptions' => [],
36-
'driverOptions' => [],
35+
'options' => [],
3736
]);
3837

3938
$this->assertEquals('pdo_sqlite', $resolved['driver']);

tests/Feature/Configuration/Connections/SqlsrvConnectionTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ public function testCanResolve(): void
3535
'port' => 'port',
3636
'prefix' => 'prefix',
3737
'charset' => 'charset',
38-
'defaultTableOptions' => [],
39-
'driverOptions' => [],
38+
'encrypt' => 'encrypt',
39+
'trust_server_certificate' => 'trust_server_certificate',
40+
'options' => [],
4041
]);
4142

4243
$this->assertEquals('pdo_sqlsrv', $resolved['driver']);
@@ -48,7 +49,8 @@ public function testCanResolve(): void
4849
$this->assertEquals('prefix', $resolved['prefix']);
4950
$this->assertEquals('charset', $resolved['charset']);
5051
$this->assertCount(0, $resolved['defaultTableOptions']);
51-
$this->assertCount(0, $resolved['driverOptions']);
52+
$this->assertEquals('encrypt', $resolved['driverOptions']['encrypt']);
53+
$this->assertEquals('trust_server_certificate', $resolved['driverOptions']['trustServerCertificate']);
5254
}
5355

5456
protected function tearDown(): void

0 commit comments

Comments
 (0)