Skip to content

Commit

Permalink
Conditionally add driver options 'encrypt' and 'trust_server_certific…
Browse files Browse the repository at this point in the history
…ate' to SqlsrvConnection
  • Loading branch information
YaakovR committed Dec 20, 2022
1 parent 9eea57d commit dabc165
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Configuration/Connections/SqlsrvConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ public function resolve(array $settings = [])
'charset' => Arr::get($settings, 'charset'),
'defaultTableOptions' => Arr::get($settings, 'defaultTableOptions', []),
'serverVersion' => Arr::get($settings, 'serverVersion'),
'wrapperClass' => Arr::get($settings, 'wrapperClass')
'wrapperClass' => Arr::get($settings, 'wrapperClass'),
'driverOptions' => array_merge([],
isset($settings['encrypt'])
? ['encrypt' => Arr::get($settings, 'encrypt')]
: [],
isset($settings['trust_server_certificate'])
? ['trustServerCertificate' => Arr::get($settings, 'trust_server_certificate')]
: [],
),
];
}
}
2 changes: 2 additions & 0 deletions tests/Configuration/Connections/SqlsrvConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function test_can_resolve()
'prefix' => 'prefix',
'charset' => 'charset',
'defaultTableOptions' => [],
'driverOptions' => [],
]);

$this->assertEquals('pdo_sqlsrv', $resolved['driver']);
Expand All @@ -48,6 +49,7 @@ public function test_can_resolve()
$this->assertEquals('prefix', $resolved['prefix']);
$this->assertEquals('charset', $resolved['charset']);
$this->assertCount(0, $resolved['defaultTableOptions']);
$this->assertCount(0, $resolved['driverOptions']);
}

protected function tearDown(): void
Expand Down

0 comments on commit dabc165

Please sign in to comment.