Skip to content

Commit

Permalink
Run the CS fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Dec 4, 2019
1 parent 114678a commit c262c81
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
15 changes: 6 additions & 9 deletions manager-bundle/src/ContaoManager/Plugin.php
Expand Up @@ -68,6 +68,11 @@ class Plugin implements BundlePluginInterface, ConfigPluginInterface, RoutingPlu
*/
private $dbalConnectionFactory;

public function __construct(callable $dbalConnectionFactory = null)
{
$this->dbalConnectionFactory = $dbalConnectionFactory ?: [DriverManager::class, 'getConnection'];
}

/**
* Sets the path to enable autoloading of legacy Contao modules.
*/
Expand All @@ -76,11 +81,6 @@ public static function autoloadModules(string $modulePath): void
static::$autoloadModules = $modulePath;
}

public function __construct(callable $dbalConnectionFactory = null)
{
$this->dbalConnectionFactory = $dbalConnectionFactory ?: [DriverManager::class, 'getConnection'];
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -316,9 +316,6 @@ private function handlePrependLocale(array $extensionConfigs, ContainerBuilder $
/**
* Adds the database server version to the Doctrine DBAL configuration.
*
* If there are no DB credentials yet (install tool), we have to set the
* server version to prevent a DBAL exception (see #1422).
*
* @return array<string,array<string,array<string,array<string,mixed>>>>
*/
private function addDefaultServerVersion(array $extensionConfigs, ContainerBuilder $container): array
Expand All @@ -344,7 +341,7 @@ private function addDefaultServerVersion(array $extensionConfigs, ContainerBuild
// If there are no DB credentials yet (install tool), we have to set
// the server version to prevent a DBAL exception (see #1422)
try {
$connection = call_user_func($this->dbalConnectionFactory, $params);
$connection = \call_user_func($this->dbalConnectionFactory, $params);
$connection->connect();
$connection->close();
} catch (DriverException $e) {
Expand Down
12 changes: 10 additions & 2 deletions manager-bundle/tests/ContaoManager/PluginTest.php
Expand Up @@ -400,8 +400,15 @@ public function testRetrievesTheConnectionParametersFromTheConfiguration(): void
];

$connection = $this->createMock(Connection::class);
$connection->expects($this->once())->method('connect');
$connection->expects($this->once())->method('close');
$connection
->expects($this->once())
->method('connect')
;

$connection
->expects($this->once())
->method('close')
;

$dbalConnectionFactory = function ($params) use ($connection) {
$this->assertSame(
Expand All @@ -411,6 +418,7 @@ public function testRetrievesTheConnectionParametersFromTheConfiguration(): void
],
$params
);

return $connection;
};

Expand Down

0 comments on commit c262c81

Please sign in to comment.