-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Michael Albrecht <[email protected]>
- Loading branch information
Showing
35 changed files
with
381 additions
and
390 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace Neusta\ConverterBundle\Tests; | ||
|
||
use Neusta\ConverterBundle\Tests\Support\Attribute\ConfigureContainer; | ||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
|
||
abstract class ConfigurableKernelTestCase extends KernelTestCase | ||
{ | ||
/** @var list<ConfigureContainer> */ | ||
private static iterable $kernelConfigurations = []; | ||
|
||
protected static function getKernelClass(): string | ||
{ | ||
return \TestKernel::class; | ||
} | ||
|
||
protected static function createKernel(array $options = []): \TestKernel | ||
{ | ||
$kernel = parent::createKernel($options); | ||
\assert($kernel instanceof \TestKernel); | ||
|
||
foreach (self::$kernelConfigurations as $configuration) { | ||
$configuration->configure($kernel); | ||
} | ||
|
||
$kernel->handleOptions($options); | ||
|
||
return $kernel; | ||
} | ||
|
||
/** | ||
* @internal | ||
* | ||
* @before | ||
*/ | ||
public function _getKernelConfigurationFromAttributes(): void | ||
{ | ||
$class = new \ReflectionClass($this); | ||
$method = $class->getMethod($this->getName(false)); | ||
|
||
$attributes = []; | ||
foreach ($class->getAttributes(ConfigureContainer::class) as $attribute) { | ||
$attributes[] = $attribute->newInstance(); | ||
} | ||
|
||
foreach ($method->getAttributes(ConfigureContainer::class) as $attribute) { | ||
$attributes[] = $attribute->newInstance(); | ||
} | ||
|
||
self::$kernelConfigurations = $attributes; | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
self::$kernelConfigurations = []; | ||
parent::tearDown(); | ||
} | ||
} |
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
Oops, something went wrong.