Skip to content

Commit

Permalink
Merge pull request #53 from SymfonyTest/merge-1.x
Browse files Browse the repository at this point in the history
Merge branch 1.x into master
  • Loading branch information
Nyholm authored Aug 20, 2021
2 parents 1c1922b + d0abf94 commit d7cbc75
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 14 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.

## 1.8.1

### Fixed

- Symfony 6 compatibility issues

## 1.8.0

### Added
Expand Down
14 changes: 14 additions & 0 deletions psalm.baseline.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.8.1@f73f2299dbc59a3e6c4d66cff4605176e728ee69">
<file src="src/AppKernel.php">
<InvalidReturnStatement occurrences="1">
<code>$bundles</code>
</InvalidReturnStatement>
<InvalidReturnType occurrences="1">
<code>iterable</code>
</InvalidReturnType>
<ReservedWord occurrences="1">
<code>$loader-&gt;getResolver()-&gt;resolve($file, 'php')</code>
</ReservedWord>
<UndefinedClass occurrences="1">
<code>RouteCollectionBuilder</code>
</UndefinedClass>
</file>
<file src="src/BaseBundleTestCase.php">
<UndefinedClass occurrences="1">
<code>ResettableContainerInterface</code>
Expand Down
44 changes: 33 additions & 11 deletions src/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\Loader\PhpFileLoader as RoutingPhpFileLoader;
use Symfony\Component\Routing\RouteCollection;
use Symfony\Component\Routing\RouteCollectionBuilder;

/**
Expand Down Expand Up @@ -79,17 +82,17 @@ public function addConfigFile($configFile)
$this->configFiles[] = $configFile;
}

public function getCacheDir()
public function getCacheDir(): string
{
return sys_get_temp_dir().'/NyholmBundleTest/'.$this->cachePrefix;
}

public function getLogDir()
public function getLogDir(): string
{
return sys_get_temp_dir().'/NyholmBundleTest/log';
}

public function getProjectDir()
public function getProjectDir(): string
{
if (null === $this->fakedProjectDir) {
return realpath(__DIR__.'/../../../../');
Expand All @@ -114,7 +117,7 @@ public function setProjectDir($projectDir)
$this->fakedProjectDir = $projectDir;
}

public function registerBundles()
public function registerBundles(): iterable
{
$this->bundlesToRegister = array_unique($this->bundlesToRegister);
$bundles = [];
Expand Down Expand Up @@ -169,21 +172,40 @@ public function registerContainerConfiguration(LoaderInterface $loader)
*/
public function loadRoutes(LoaderInterface $loader)
{
$routes = new RouteCollectionBuilder($loader);
if (class_exists(RoutingConfigurator::class)) {
$file = (new \ReflectionObject($this))->getFileName();
/** @var RoutingPhpFileLoader $kernelLoader */
$kernelLoader = $loader->getResolver()->resolve($file, 'php');
$kernelLoader->setCurrentDir(\dirname($file));

$collection = new RouteCollection();
$configurator = new RoutingConfigurator($collection, $kernelLoader, $file, $file, $this->getEnvironment());

if ($this->routingFile) {
$configurator->import($this->routingFile);
} else {
$configurator->import(__DIR__.'/config/routing.yml');
}

if ($this->routingFile) {
$routes->import($this->routingFile);
return $collection;
} else {
$routes->import(__DIR__.'/config/routing.yml');
}
// Legacy
$routes = new RouteCollectionBuilder($loader);

return $routes->build();
if ($this->routingFile) {
$routes->import($this->routingFile);
} else {
$routes->import(__DIR__.'/config/routing.yml');
}

return $routes->build();
}
}

/**
* {@inheritdoc}
*/
protected function buildContainer()
protected function buildContainer(): ContainerBuilder
{
$container = parent::buildContainer();

Expand Down
3 changes: 2 additions & 1 deletion tests/Functional/BundleConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
use Nyholm\BundleTest\Tests\Fixtures\ConfigurationBundle\ConfigurationBundle;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* @author Laurent VOULLEMIER <[email protected]>
*/
final class BundleConfigurationTest extends KernelTestCase
{
protected static function createKernel(array $options = [])
protected static function createKernel(array $options = []): KernelInterface
{
KernelTestCase::$class = AppKernel::class;

Expand Down
3 changes: 2 additions & 1 deletion tests/Functional/BundleInitializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
use Nyholm\BundleTest\AppKernel;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpKernel\KernelInterface;

/**
* @author Tobias Nyholm <[email protected]>
*/
class BundleInitializationTest extends KernelTestCase
{
protected static function createKernel(array $options = [])
protected static function createKernel(array $options = []): KernelInterface
{
KernelTestCase::$class = AppKernel::class;

Expand Down
3 changes: 2 additions & 1 deletion tests/Functional/BundleRoutingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
use Nyholm\BundleTest\AppKernel;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Routing\RouterInterface;

class BundleRoutingTest extends KernelTestCase
{
protected static function createKernel(array $options = [])
protected static function createKernel(array $options = []): KernelInterface
{
KernelTestCase::$class = AppKernel::class;

Expand Down

0 comments on commit d7cbc75

Please sign in to comment.