TestKernel.php 3.28 KiB
<?php declare(strict_types=1);
/*
 * This file is part of "irstea/api-metadata".
 * Copyright (C) 2019 IRSTEA
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License and the GNU
 * Lesser General Public License along with this program. If not, see
 * <https://www.gnu.org/licenses/>.
namespace Irstea\ApiMetadata\Tests\Fixtures;
use ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle;
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
use Irstea\ApiMetadata\Bridge\Symfony\Bundle\IrsteaApiMetadataBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Bundle\WebServerBundle\WebServerBundle;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\RouteCollectionBuilder;
/**
 * Class TestKernel.
class TestKernel extends Kernel
    use MicroKernelTrait;
    /**
     * {@inheritdoc}
    public function registerBundles()
        return [
            new FrameworkBundle(),
            new DoctrineBundle(),
            new WebServerBundle(),
            new ApiPlatformBundle(),
            new IrsteaApiMetadataBundle(),
            new TestBundle(),
    /**
     * {@inheritdoc}
    protected function configureRoutes(RouteCollectionBuilder $routes)
        $routes->import('.', '/', 'api_platform');
    /**
     * {@inheritdoc}
    protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader)
        $c->setParameter('env(DATABASE_DRIVER)', 'pdo_sqlite');
        $c->setParameter('env(DATABASE_URL)', 'sqlite:///%kernel.cache_dir%/database.sqlite3');
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
$c->loadFromExtension('framework', [ 'secret' => __DIR__, 'test' => true, ]); $c->loadFromExtension('doctrine', [ 'dbal' => [ 'driver' => '%env(DATABASE_DRIVER)%', 'charset' => 'utf8', 'url' => '%env(DATABASE_URL)%', ], 'orm' => [ 'auto_generate_proxy_classes' => true, 'auto_mapping' => true, 'mappings' => [ 'TestBundle' => [ 'is_bundle' => true, 'type' => 'annotation', ], ], ], ]); $c->loadFromExtension('api_platform', [ 'mapping' => [ 'paths' => [ __DIR__ . '/Entity', ], ], ]); } /** * {@inheritdoc} */ public function getProjectDir(): string { return __DIR__; } }