| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlsrv; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Doctrine\DBAL\Driver\PDOSqlsrv\Connection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Doctrine\DBAL\Driver\PDOSqlsrv\Driver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use PDO; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use function extension_loaded; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | class DriverTest extends AbstractDriverTest | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 12 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |     protected function setUp() | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |         if (! extension_loaded('pdo_sqlsrv')) { | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |             $this->markTestSkipped('pdo_sqlsrv is not installed.'); | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |         parent::setUp(); | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |         if ($this->_conn->getDriver() instanceof Driver) { | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |             return; | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |         $this->markTestSkipped('pdo_sqlsrv only test.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     protected function createDriver() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         return new Driver(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * {@inheritdoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     protected function getDatabaseNameForConnectionWithoutDatabaseNameParameter() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         return 'master'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * @param int[]|string[] $driverOptions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     protected function getConnection(array $driverOptions) : Connection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         return $this->_conn->getDriver()->connect( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |                 'host' => $GLOBALS['db_host'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                 'port' => $GLOBALS['db_port'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |             ], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             $GLOBALS['db_username'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             $GLOBALS['db_password'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             $driverOptions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     public function testConnectionOptions() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $connection = $this->getConnection(['APP' => 'APP_NAME']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $result     = $connection->query('SELECT APP_NAME()')->fetchColumn(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         self::assertSame('APP_NAME', $result); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     public function testDriverOptions() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $connection = $this->getConnection([PDO::ATTR_CASE => PDO::CASE_UPPER]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         self::assertSame(PDO::CASE_UPPER, $connection->getAttribute(PDO::ATTR_CASE)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 74 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 75 |  |  |  |