Skip to content

Commit

Permalink
Fix AppKernel
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 committed Aug 29, 2022
1 parent a4ce8e5 commit fa0faa5
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 27 deletions.
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -34,9 +34,9 @@
"twig/twig": "^2.12 || ^3.0"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.1",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/doctrine-fixtures-bundle": "^3.4",
"doctrine/orm": "^2.5",
"doctrine/orm": "^2.8",
"doctrine/persistence": "^2.0 || ^3.0",
"friendsofphp/php-cs-fixer": "^3.4",
"gedmo/doctrine-extensions": "^3.0",
Expand All @@ -56,6 +56,7 @@
"sonata-project/doctrine-orm-admin-bundle": "^4.0",
"symfony/browser-kit": "^4.4 || ^5.4 || ^6.0",
"symfony/css-selector": "^4.4 || ^5.4 || ^6.0",
"symfony/filesystem": "^4.4 || ^5.4 || ^6.0",
"symfony/phpunit-bridge": "^6.1",
"vimeo/psalm": "^4.3.2",
"weirdan/doctrine-psalm-plugin": "^2.0"
Expand Down
2 changes: 1 addition & 1 deletion phpstan-object-manager.php
Expand Up @@ -15,7 +15,7 @@

require __DIR__.'/vendor/autoload.php';

$kernel = new AppKernel();
$kernel = new AppKernel('test', false);
$kernel->boot();

return $kernel->getContainer()->get('doctrine')->getManager();
6 changes: 6 additions & 0 deletions src/Filter/TranslationFieldFilter.php
Expand Up @@ -112,6 +112,9 @@ protected function association(ProxyQueryInterface $query, FilterData $data): ar
return [$alias, $fieldName];
}

/**
* @phpstan-param ProxyQueryInterface<object> $query
*/
private function applyGedmoFilters(ProxyQueryInterface $query, string $joinAlias, string $alias, string $field, string $value): void
{
$this->applyWhere($query, $query->getQueryBuilder()->expr()->orX(
Expand All @@ -129,6 +132,9 @@ private function applyGedmoFilters(ProxyQueryInterface $query, string $joinAlias
));
}

/**
* @phpstan-param ProxyQueryInterface<object> $query
*/
private function applyKnplabsFilters(ProxyQueryInterface $query, string $joinAlias, string $field, string $value): void
{
$this->applyWhere(
Expand Down
11 changes: 2 additions & 9 deletions tests/App/AppKernel.php
Expand Up @@ -34,19 +34,10 @@
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;

/**
* @psalm-suppress PropertyNotSetInConstructor https://github.com/vimeo/psalm/issues/2319 comming from
* https://github.com/psalm/psalm-plugin-symfony/blob/65586604237c9062c15adc92faee5f84d1698af6/src/Stubs/common/Component/HttpKernel/Kernel.stubphp
*/
final class AppKernel extends Kernel
{
use MicroKernelTrait;

public function __construct()
{
parent::__construct('test', true);
}

public function registerBundles(): iterable
{
return [
Expand Down Expand Up @@ -94,6 +85,8 @@ protected function configureRoutes($routes): void

protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void
{
$container->setParameter('app.base_dir', $this->getBaseDir());

if (interface_exists(AuthenticatorFactoryInterface::class)) {
$loader->load(__DIR__.'/config/config_v5.yml');
$loader->load(__DIR__.'/config/security_v5.yml');
Expand Down
2 changes: 1 addition & 1 deletion tests/App/config/config_v4.yml
Expand Up @@ -17,7 +17,7 @@ twig:
strict_variables: true

parameters:
env(DATABASE_URL): 'sqlite:////%kernel.cache_dir%/test_database.db'
env(DATABASE_URL): 'sqlite:////%app.base_dir%database.db'
locale: 'en'

sonata_block:
Expand Down
2 changes: 1 addition & 1 deletion tests/App/config/config_v5.yml
Expand Up @@ -18,7 +18,7 @@ twig:
strict_variables: true

parameters:
env(DATABASE_URL): 'sqlite:////%kernel.cache_dir%/test_database.db'
env(DATABASE_URL): 'sqlite:////%app.base_dir%database.db'
locale: 'en'

sonata_block:
Expand Down
6 changes: 0 additions & 6 deletions tests/Functional/GedmoCRUDTest.php
Expand Up @@ -13,7 +13,6 @@

namespace Sonata\TranslationBundle\Tests\Functional;

use Sonata\TranslationBundle\Tests\App\AppKernel;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -137,11 +136,6 @@ public function provideLocalesToEdit(): iterable
yield 'french' => ['fr', 'Roman édité'];
}

protected static function getKernelClass(): string
{
return AppKernel::class;
}

private function generateUrlWithLocale(string $url, string $locale): string
{
if ('' === $locale) {
Expand Down
6 changes: 0 additions & 6 deletions tests/Functional/KnpCRUDTest.php
Expand Up @@ -13,7 +13,6 @@

namespace Sonata\TranslationBundle\Tests\Functional;

use Sonata\TranslationBundle\Tests\App\AppKernel;
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -137,11 +136,6 @@ public function provideLocalesToEdit(): iterable
yield 'french' => ['fr', 'Roman édité'];
}

protected static function getKernelClass(): string
{
return AppKernel::class;
}

private function generateUrlWithLocale(string $url, string $locale): string
{
if ('' === $locale) {
Expand Down
6 changes: 5 additions & 1 deletion tests/custom_bootstrap.php
Expand Up @@ -15,8 +15,10 @@
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Filesystem\Filesystem;

$application = new Application(new AppKernel());
$kernel = new AppKernel($_SERVER['APP_ENV'], $_SERVER['APP_DEBUG']);
$application = new Application($kernel);
$application->setAutoExit(false);

$input = new ArrayInput([
Expand All @@ -41,3 +43,5 @@
'--no-interaction' => false,
]);
$application->run($input, new NullOutput());

(new Filesystem())->remove([$kernel->getCacheDir()]);

0 comments on commit fa0faa5

Please sign in to comment.