|
130 | 130 | $driver = Double::instance(['extends' => Driver::class, 'methods' => '__construct']); |
131 | 131 | allow($driver)->toReceive('getName')->andReturn('pdo_mysql'); |
132 | 132 |
|
133 | | - allow($connection)->toReceive('getParams')->andReturn([]); |
| 133 | + $pdoMysqlInitCommandAttr = defined(Mysql::class . '::ATTR_INIT_COMMAND') |
| 134 | + ? Mysql::ATTR_INIT_COMMAND |
| 135 | + : PDO::MYSQL_ATTR_INIT_COMMAND; |
| 136 | + |
| 137 | + allow($connection)->toReceive('getParams')->andReturn([ |
| 138 | + 'user' => 'mysqluser', |
| 139 | + 'password' => 'mysqlpassword', |
| 140 | + 'dbname' => 'mysqldbname', |
| 141 | + 'host' => 'mysqlhost', |
| 142 | + 'port' => '3306', |
| 143 | + 'driverOptions' => [ |
| 144 | + $pdoMysqlInitCommandAttr => "SET NAMES 'UTF8'", |
| 145 | + ], |
| 146 | + 'driverClass' => Driver::class, |
| 147 | + ]); |
134 | 148 | allow($connection)->toReceive('getUsername')->andReturn('root'); |
135 | 149 | allow($connection)->toReceive('getPassword')->andReturn(''); |
136 | 150 | allow($connection)->toReceive('getDriver')->andReturn($driver); |
|
165 | 179 | : PDO::MYSQL_ATTR_INIT_COMMAND; |
166 | 180 |
|
167 | 181 | allow($connection)->toReceive('getParams')->andReturn([ |
| 182 | + 'user' => 'mysqluser', |
| 183 | + 'password' => 'mysqlpassword', |
| 184 | + 'dbname' => 'mysqldbname', |
| 185 | + 'host' => 'mysqlhost', |
| 186 | + 'port' => '3306', |
168 | 187 | 'driverOptions' => [ |
169 | 188 | $pdoMysqlInitCommandAttr => "SET NAMES 'UTF8'", |
170 | 189 | ], |
| 190 | + 'driverClass' => Driver::class, |
171 | 191 | ]); |
172 | 192 | allow($connection)->toReceive('getUsername')->andReturn('root'); |
173 | 193 | allow($connection)->toReceive('getPassword')->andReturn(''); |
|
0 commit comments