Convert variable names to camel case
[MAILPOET-1796]
This commit is contained in:
@@ -17,46 +17,46 @@ class ConnectionFactoryTest extends \MailPoetTest {
|
||||
|
||||
public function _before() {
|
||||
parent::_before();
|
||||
$this->env_backup['db_host'] = Env::$db_host;
|
||||
$this->env_backup['db_is_ipv6'] = Env::$db_is_ipv6;
|
||||
$this->env_backup['db_port'] = Env::$db_port;
|
||||
$this->env_backup['db_socket'] = Env::$db_socket;
|
||||
$this->env_backup['db_charset'] = Env::$db_charset;
|
||||
$this->envBackup['db_host'] = Env::$dbHost;
|
||||
$this->envBackup['db_is_ipv6'] = Env::$dbIsIpv6;
|
||||
$this->envBackup['db_port'] = Env::$dbPort;
|
||||
$this->envBackup['db_socket'] = Env::$dbSocket;
|
||||
$this->envBackup['db_charset'] = Env::$dbCharset;
|
||||
}
|
||||
|
||||
public function testItSetsUpConnection() {
|
||||
$connection_factory = new ConnectionFactory();
|
||||
$connection = $connection_factory->createConnection();
|
||||
$connectionFactory = new ConnectionFactory();
|
||||
$connection = $connectionFactory->createConnection();
|
||||
|
||||
expect($connection)->isInstanceOf(SerializableConnection::class);
|
||||
expect($connection->getWrappedConnection())->isInstanceOf(PDO::class);
|
||||
expect($connection->getDriver())->isInstanceOf(PDOMySql\Driver::class);
|
||||
expect($connection->getDatabasePlatform())->isInstanceOf(MySqlPlatform::class);
|
||||
expect($connection->getHost())->equals(Env::$db_host);
|
||||
expect($connection->getPort())->equals(Env::$db_port);
|
||||
expect($connection->getHost())->equals(Env::$dbHost);
|
||||
expect($connection->getPort())->equals(Env::$dbPort);
|
||||
expect($connection->getParams())->notContains('unix_socket');
|
||||
expect($connection->getUsername())->equals(Env::$db_username);
|
||||
expect($connection->getPassword())->equals(Env::$db_password);
|
||||
expect($connection->getParams()['charset'])->equals(Env::$db_charset);
|
||||
expect($connection->getDatabase())->equals(Env::$db_name);
|
||||
expect($connection->getUsername())->equals(Env::$dbUsername);
|
||||
expect($connection->getPassword())->equals(Env::$dbPassword);
|
||||
expect($connection->getParams()['charset'])->equals(Env::$dbCharset);
|
||||
expect($connection->getDatabase())->equals(Env::$dbName);
|
||||
|
||||
expect(Type::getType(JsonType::NAME))->isInstanceOf(JsonType::class);
|
||||
expect(Type::getType(JsonOrSerializedType::NAME))->isInstanceOf(JsonOrSerializedType::class);
|
||||
}
|
||||
|
||||
public function testItIgnoresEmptyCharset() {
|
||||
Env::$db_charset = '';
|
||||
$connection_factory = new ConnectionFactory();
|
||||
$connection = $connection_factory->createConnection();
|
||||
Env::$dbCharset = '';
|
||||
$connectionFactory = new ConnectionFactory();
|
||||
$connection = $connectionFactory->createConnection();
|
||||
expect($connection->getParams())->hasntKey('charset');
|
||||
}
|
||||
|
||||
public function testItSetsUpSocket() {
|
||||
Env::$db_host = null;
|
||||
Env::$db_port = null;
|
||||
Env::$db_socket = 'socket';
|
||||
$connection_factory = new ConnectionFactory();
|
||||
$connection = $connection_factory->createConnection();
|
||||
Env::$dbHost = null;
|
||||
Env::$dbPort = null;
|
||||
Env::$dbSocket = 'socket';
|
||||
$connectionFactory = new ConnectionFactory();
|
||||
$connection = $connectionFactory->createConnection();
|
||||
|
||||
expect($connection->getHost())->null();
|
||||
expect($connection->getPort())->null();
|
||||
@@ -64,29 +64,29 @@ class ConnectionFactoryTest extends \MailPoetTest {
|
||||
}
|
||||
|
||||
public function testItSetsUpIpV6() {
|
||||
Env::$db_is_ipv6 = true;
|
||||
Env::$dbIsIpv6 = true;
|
||||
|
||||
Env::$db_host = '::1';
|
||||
$connection_factory = new ConnectionFactory();
|
||||
$connection = $connection_factory->createConnection();
|
||||
Env::$dbHost = '::1';
|
||||
$connectionFactory = new ConnectionFactory();
|
||||
$connection = $connectionFactory->createConnection();
|
||||
expect($connection->getHost())->equals('[::1]');
|
||||
|
||||
Env::$db_host = 'b57e:9b70:ab96:6a0b:5ba2:49e3:ebba:a036';
|
||||
$connection_factory = new ConnectionFactory();
|
||||
$connection = $connection_factory->createConnection();
|
||||
Env::$dbHost = 'b57e:9b70:ab96:6a0b:5ba2:49e3:ebba:a036';
|
||||
$connectionFactory = new ConnectionFactory();
|
||||
$connection = $connectionFactory->createConnection();
|
||||
expect($connection->getHost())->equals('[b57e:9b70:ab96:6a0b:5ba2:49e3:ebba:a036]');
|
||||
|
||||
// try to actually connect to the DB over IPv6
|
||||
Env::$db_host = '::ffff:' . gethostbyname($this->env_backup['db_host']);
|
||||
$connection_factory = new ConnectionFactory();
|
||||
$connection = $connection_factory->createConnection();
|
||||
Env::$dbHost = '::ffff:' . gethostbyname($this->envBackup['db_host']);
|
||||
$connectionFactory = new ConnectionFactory();
|
||||
$connection = $connectionFactory->createConnection();
|
||||
expect($connection->getWrappedConnection())->isInstanceOf(PDO::class);
|
||||
expect($connection->executeQuery('SELECT 1')->fetchColumn())->same('1');
|
||||
}
|
||||
|
||||
public function testItSetsDriverOptions() {
|
||||
$connection_factory = new ConnectionFactory();
|
||||
$connection = $connection_factory->createConnection();
|
||||
$connectionFactory = new ConnectionFactory();
|
||||
$connection = $connectionFactory->createConnection();
|
||||
|
||||
$result = $connection->executeQuery('
|
||||
SELECT
|
||||
@@ -101,40 +101,40 @@ class ConnectionFactoryTest extends \MailPoetTest {
|
||||
|
||||
// check timezone, SQL mode, wait timeout
|
||||
expect($result['@@session.sql_mode'])->notContains('ONLY_FULL_GROUP_BY');
|
||||
expect($result['@@session.time_zone'])->equals(Env::$db_timezone_offset);
|
||||
expect($result['@@session.time_zone'])->equals(Env::$dbTimezoneOffset);
|
||||
expect($result['@@session.wait_timeout'])->greaterOrEquals(60);
|
||||
|
||||
// check "SET NAMES ... COLLATE ..."
|
||||
expect($result['@@session.character_set_client'])->equals(Env::$db_charset);
|
||||
expect($result['@@session.character_set_connection'])->equals(Env::$db_charset);
|
||||
expect($result['@@session.character_set_results'])->equals(Env::$db_charset);
|
||||
expect($result['@@session.collation_connection'])->equals(Env::$db_collation);
|
||||
expect($result['@@session.character_set_client'])->equals(Env::$dbCharset);
|
||||
expect($result['@@session.character_set_connection'])->equals(Env::$dbCharset);
|
||||
expect($result['@@session.character_set_results'])->equals(Env::$dbCharset);
|
||||
expect($result['@@session.collation_connection'])->equals(Env::$dbCollation);
|
||||
}
|
||||
|
||||
public function testItSelectivelyUpdatesWaitTimeoutOption() {
|
||||
// timeout will be kept from DB defaults
|
||||
$connection_factory = $this->make(ConnectionFactory::class, [
|
||||
$connectionFactory = $this->make(ConnectionFactory::class, [
|
||||
'min_wait_timeout' => 1,
|
||||
]);
|
||||
$connection = $connection_factory->createConnection();
|
||||
$connection = $connectionFactory->createConnection();
|
||||
$current = $connection->executeQuery('SELECT @@session.wait_timeout')->fetchColumn();
|
||||
expect($current)->greaterThan(1);
|
||||
|
||||
// timeout will be set to higher value
|
||||
$connection_factory = $this->make(ConnectionFactory::class, [
|
||||
$connectionFactory = $this->make(ConnectionFactory::class, [
|
||||
'min_wait_timeout' => 999999,
|
||||
]);
|
||||
$connection = $connection_factory->createConnection();
|
||||
$connection = $connectionFactory->createConnection();
|
||||
$current = $connection->executeQuery('SELECT @@session.wait_timeout')->fetchColumn();
|
||||
expect($current)->equals(999999);
|
||||
}
|
||||
|
||||
public function _after() {
|
||||
parent::_after();
|
||||
Env::$db_host = $this->env_backup['db_host'];
|
||||
Env::$db_port = $this->env_backup['db_port'];
|
||||
Env::$db_is_ipv6 = $this->env_backup['db_is_ipv6'];
|
||||
Env::$db_socket = $this->env_backup['db_socket'];
|
||||
Env::$db_charset = $this->env_backup['db_charset'];
|
||||
Env::$dbHost = $this->envBackup['db_host'];
|
||||
Env::$dbPort = $this->envBackup['db_port'];
|
||||
Env::$dbIsIpv6 = $this->envBackup['db_is_ipv6'];
|
||||
Env::$dbSocket = $this->envBackup['db_socket'];
|
||||
Env::$dbCharset = $this->envBackup['db_charset'];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user