Last active
January 30, 2020 08:00
-
-
Save shulard/b9149db6b5f026df4f771a821fa0dfd8 to your computer and use it in GitHub Desktop.
Define dynamic kernel for a specific test case !
This file contains hidden or 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
<?php declare(strict_types=1); | |
namespace App\Tests\Features\SynchronousJob; | |
use App\Tests\Features\SynchronousTestCase; | |
use App\Tests\Features\SynchronousTestKernel; | |
class PushJobWithRetryOnTaskFailTest extends SynchronousTestCase | |
{ | |
protected static function createKernel(array $options = []) | |
{ | |
return new class('test', true) extends SynchronousTestKernel { | |
public function registerContainerConfiguration(LoaderInterface $loader) | |
{ | |
parent::registerContainerConfiguration($loader); | |
$loader->load(static function (ContainerBuilder $container) { | |
$retryGuesser = $container->getDefinition('app.jobs.task_retry_limitation'); | |
$container->setDefinition( | |
'App\Domain\Job\Model\Task\RetryCapabilities\RetryGuesser', | |
$retryGuesser | |
); | |
}); | |
} | |
}; | |
} | |
public function testAnAwesomeBehaviour(): void | |
{ | |
self::$container->get('App\Domain\Job\Model\Task\RetryCapabilities\RetryGuesser'); | |
//Retourne une instance de 'app.jobs.task_retry_limitation' | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment