invoke(null, '127.0.0.1', 15433, 'reporting', '7.4'); $this->assertSame( 'dblib:host=127.0.0.1:15433;dbname=reporting;version=7.4;charset=UTF-8', $dsn, ); $this->assertStringNotContainsString('PWD=', $dsn); $this->assertStringNotContainsString('UID=', $dsn); } public function test_production_dblib_transport_is_only_opted_in_for_the_marked_source(): void { $method = new ReflectionMethod(UpstreamOdbcConnection::class, 'shouldUsePdoDblib'); config()->set('upstreams.sources.operations_replica.use_pdo_dblib', true); config()->set('upstreams.sources.jiansun.use_pdo_dblib', false); $operations = $method->invoke(null, 'operations_replica', 'FreeTDS', 'request'); $jiansun = $method->invoke(null, 'jiansun', 'FreeTDS', 'request'); if (PHP_OS_FAMILY !== 'Windows' && extension_loaded('pdo_dblib')) { $this->assertTrue($operations); } else { $this->assertFalse($operations); } $this->assertFalse($jiansun); $this->assertFalse($method->invoke(null, 'operations_replica', 'FreeTDS', 'strict')); } public function test_sql_server_connection_enables_required_ansi_session_options(): void { $pdo = new class extends PDO { /** @var array */ public array $statements = []; public function __construct() { } public function exec(string $statement): int|false { $this->statements[] = $statement; return 0; } }; $method = new ReflectionMethod(UpstreamOdbcConnection::class, 'initializeSqlServerSession'); $result = $method->invoke(null, $pdo); $this->assertSame($pdo, $result); $this->assertSame([ 'SET ANSI_NULLS ON', 'SET ANSI_WARNINGS ON', ], $pdo->statements); } }