-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1263 from greg0ire/dbal-3-compat
Fixes for compatibility with DBAL 3
- Loading branch information
Showing
6 changed files
with
140 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace Doctrine\Bundle\DoctrineBundle\Tests\DependencyInjection\Fixtures; | ||
|
||
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; | ||
use Doctrine\Bundle\DoctrineBundle\Tests\TestCaseAllPublicCompilerPass; | ||
use Psr\Log\NullLogger; | ||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Kernel; | ||
|
||
class DbalTestKernel extends Kernel | ||
{ | ||
/** @var string|null */ | ||
private $projectDir; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('test', true); | ||
} | ||
|
||
public function registerBundles(): iterable | ||
{ | ||
return [ | ||
new FrameworkBundle(), | ||
new DoctrineBundle(), | ||
]; | ||
} | ||
|
||
public function registerContainerConfiguration(LoaderInterface $loader): void | ||
{ | ||
$loader->load(static function (ContainerBuilder $container): void { | ||
// @todo Setting the kernel.name parameter can be removed once the dependency on DoctrineCacheBundle has been dropped | ||
$container->setParameter('kernel.name', 'foo'); | ||
$container->loadFromExtension('framework', ['secret' => 'F00']); | ||
|
||
$container->loadFromExtension('doctrine', [ | ||
'dbal' => ['driver' => 'pdo_sqlite'], | ||
]); | ||
|
||
// Register a NullLogger to avoid getting the stderr default logger of FrameworkBundle | ||
$container->register('logger', NullLogger::class); | ||
|
||
// make all Doctrine services public, so we can fetch them in the test | ||
$container->getCompilerPassConfig()->addPass(new TestCaseAllPublicCompilerPass()); | ||
}); | ||
} | ||
|
||
public function getProjectDir(): string | ||
{ | ||
if ($this->projectDir === null) { | ||
$this->projectDir = sys_get_temp_dir() . '/sf_kernel_' . md5(mt_rand()); | ||
} | ||
|
||
return $this->projectDir; | ||
} | ||
|
||
public function getRootDir(): string | ||
{ | ||
return $this->getProjectDir(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Doctrine\Bundle\DoctrineBundle\Tests; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
|
||
class TestCaseAllPublicCompilerPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container): void | ||
{ | ||
foreach ($container->getDefinitions() as $id => $definition) { | ||
if (strpos($id, 'doctrine') === false) { | ||
continue; | ||
} | ||
|
||
$definition->setPublic(true); | ||
} | ||
|
||
foreach ($container->getAliases() as $id => $alias) { | ||
if (strpos($id, 'doctrine') === false) { | ||
continue; | ||
} | ||
|
||
$alias->setPublic(true); | ||
} | ||
} | ||
} |