Merge branch '4.3' into 4.4
* 4.3: [Twig] Remove dead code Add gitignore file for Symfony 4.3 Add gitignore file for Symfony 3.4 [Inflector] Add .gitignore file [Messenger] Fix exception message of failed message is dropped on retry Add default value for Accept header [HttpClient] Add .gitignore file [Finder] Adjust regex to correctly match comments in gitignore contents [Security] Removed unused argument in Test [Console] Get dimensions from stty on windows if possible [Inflector] add support 'see' to 'ee' for singularize 'fees' to 'fee'
This commit is contained in:
commit
3c78fde548
@ -34,9 +34,7 @@ class FormThemeTokenParserTest extends TestCase
|
||||
$stream = $env->tokenize($source);
|
||||
$parser = new Parser($env);
|
||||
|
||||
if (method_exists($expected, 'setSourceContext')) {
|
||||
$expected->setSourceContext($source);
|
||||
}
|
||||
$expected->setSourceContext($source);
|
||||
|
||||
$this->assertEquals($expected, $parser->parse($stream)->getNode('body')->getNode(0));
|
||||
}
|
||||
|
@ -112,13 +112,10 @@ class TwigExtractorTest extends TestCase
|
||||
try {
|
||||
$extractor->extract($resources, new MessageCatalogue('en'));
|
||||
} catch (Error $e) {
|
||||
if (method_exists($e, 'getSourceContext')) {
|
||||
$this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', \DIRECTORY_SEPARATOR), $e->getFile());
|
||||
$this->assertSame(1, $e->getLine());
|
||||
$this->assertSame('Unclosed "block".', $e->getMessage());
|
||||
} else {
|
||||
$this->expectExceptionMessageRegExp('/Unclosed "block" in ".*extractor(\\/|\\\\)syntax_error\\.twig" at line 1/');
|
||||
}
|
||||
$this->assertSame(\dirname(__DIR__).strtr('/Fixtures/extractor/syntax_error.twig', '/', \DIRECTORY_SEPARATOR), $e->getFile());
|
||||
$this->assertSame(1, $e->getLine());
|
||||
$this->assertSame('Unclosed "block".', $e->getMessage());
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
@ -61,11 +61,7 @@ class TwigExtractor extends AbstractFileExtractor implements ExtractorInterface
|
||||
if ($file instanceof \SplFileInfo) {
|
||||
$path = $file->getRealPath() ?: $file->getPathname();
|
||||
$name = $file instanceof SplFileInfo ? $file->getRelativePathname() : $path;
|
||||
if (method_exists($e, 'setSourceContext')) {
|
||||
$e->setSourceContext(new Source('', $name, $path));
|
||||
} else {
|
||||
$e->setTemplateName($name);
|
||||
}
|
||||
$e->setSourceContext(new Source('', $name, $path));
|
||||
}
|
||||
|
||||
throw $e;
|
||||
|
@ -15,7 +15,6 @@ namespace Symfony\Bundle\TwigBundle;
|
||||
|
||||
use Symfony\Bridge\Twig\TwigEngine as BaseEngine;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Templating\TemplateReference;
|
||||
use Symfony\Component\Config\FileLocatorInterface;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Templating\TemplateNameParserInterface;
|
||||
@ -40,28 +39,6 @@ class TwigEngine extends BaseEngine implements EngineInterface
|
||||
$this->locator = $locator;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function render($name, array $parameters = [])
|
||||
{
|
||||
try {
|
||||
return parent::render($name, $parameters);
|
||||
} catch (Error $e) {
|
||||
if ($name instanceof TemplateReference && !method_exists($e, 'setSourceContext')) {
|
||||
try {
|
||||
// try to get the real name of the template where the error occurred
|
||||
$name = $e->getTemplateName();
|
||||
$path = (string) $this->locator->locate($this->parser->parse($name));
|
||||
$e->setTemplateName($path);
|
||||
} catch (\Exception $e2) {
|
||||
}
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
|
@ -21,6 +21,7 @@ use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\Component\Console\Terminal;
|
||||
|
||||
/**
|
||||
* The QuestionHelper class provides helpers to interact with the user.
|
||||
@ -117,7 +118,7 @@ class QuestionHelper extends Helper
|
||||
$inputStream = $this->inputStream ?: STDIN;
|
||||
$autocomplete = $question->getAutocompleterCallback();
|
||||
|
||||
if (null === $autocomplete || !$this->hasSttyAvailable()) {
|
||||
if (null === $autocomplete || !Terminal::hasSttyAvailable()) {
|
||||
$ret = false;
|
||||
if ($question->isHidden()) {
|
||||
try {
|
||||
@ -381,7 +382,7 @@ class QuestionHelper extends Helper
|
||||
return $value;
|
||||
}
|
||||
|
||||
if ($this->hasSttyAvailable()) {
|
||||
if (Terminal::hasSttyAvailable()) {
|
||||
$sttyMode = shell_exec('stty -g');
|
||||
|
||||
shell_exec('stty -echo');
|
||||
@ -467,18 +468,4 @@ class QuestionHelper extends Helper
|
||||
|
||||
return self::$shell;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether Stty is available or not.
|
||||
*/
|
||||
private function hasSttyAvailable(): bool
|
||||
{
|
||||
if (null !== self::$stty) {
|
||||
return self::$stty;
|
||||
}
|
||||
|
||||
exec('stty 2>&1', $output, $exitcode);
|
||||
|
||||
return self::$stty = 0 === $exitcode;
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ class Terminal
|
||||
{
|
||||
private static $width;
|
||||
private static $height;
|
||||
private static $stty;
|
||||
|
||||
/**
|
||||
* Gets the terminal width.
|
||||
@ -54,6 +55,22 @@ class Terminal
|
||||
return self::$height ?: 50;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function hasSttyAvailable()
|
||||
{
|
||||
if (null !== self::$stty) {
|
||||
return self::$stty;
|
||||
}
|
||||
|
||||
exec('stty 2>&1', $output, $exitcode);
|
||||
|
||||
return self::$stty = 0 === $exitcode;
|
||||
}
|
||||
|
||||
private static function initDimensions()
|
||||
{
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
@ -62,12 +79,21 @@ class Terminal
|
||||
// or [w, h] from "wxh"
|
||||
self::$width = (int) $matches[1];
|
||||
self::$height = isset($matches[4]) ? (int) $matches[4] : (int) $matches[2];
|
||||
} elseif (self::hasSttyAvailable()) {
|
||||
self::initDimensionsUsingStty();
|
||||
} elseif (null !== $dimensions = self::getConsoleMode()) {
|
||||
// extract [w, h] from "wxh"
|
||||
self::$width = (int) $dimensions[0];
|
||||
self::$height = (int) $dimensions[1];
|
||||
}
|
||||
} elseif ($sttyString = self::getSttyColumns()) {
|
||||
} else {
|
||||
self::initDimensionsUsingStty();
|
||||
}
|
||||
}
|
||||
|
||||
private static function initDimensionsUsingStty()
|
||||
{
|
||||
if ($sttyString = self::getSttyColumns()) {
|
||||
if (preg_match('/rows.(\d+);.columns.(\d+);/i', $sttyString, $matches)) {
|
||||
// extract [w, h] from "rows h; columns w;"
|
||||
self::$width = (int) $matches[2];
|
||||
|
@ -19,6 +19,7 @@ use Symfony\Component\Console\Output\StreamOutput;
|
||||
use Symfony\Component\Console\Question\ChoiceQuestion;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
use Symfony\Component\Console\Question\Question;
|
||||
use Symfony\Component\Console\Terminal;
|
||||
|
||||
/**
|
||||
* @group tty
|
||||
@ -181,7 +182,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
|
||||
public function testAskWithAutocomplete()
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
if (!Terminal::hasSttyAvailable()) {
|
||||
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||
}
|
||||
|
||||
@ -291,7 +292,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
|
||||
public function testAskWithAutocompleteWithNonSequentialKeys()
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
if (!Terminal::hasSttyAvailable()) {
|
||||
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||
}
|
||||
|
||||
@ -310,7 +311,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
|
||||
public function testAskWithAutocompleteWithExactMatch()
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
if (!Terminal::hasSttyAvailable()) {
|
||||
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||
}
|
||||
|
||||
@ -346,7 +347,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
*/
|
||||
public function testAskWithAutocompleteWithMultiByteCharacter($character)
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
if (!Terminal::hasSttyAvailable()) {
|
||||
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||
}
|
||||
|
||||
@ -370,7 +371,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
|
||||
public function testAutocompleteWithTrailingBackslash()
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
if (!Terminal::hasSttyAvailable()) {
|
||||
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||
}
|
||||
|
||||
@ -732,7 +733,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
|
||||
public function testTraversableAutocomplete()
|
||||
{
|
||||
if (!$this->hasSttyAvailable()) {
|
||||
if (!Terminal::hasSttyAvailable()) {
|
||||
$this->markTestSkipped('`stty` is required to test autocomplete functionality');
|
||||
}
|
||||
|
||||
@ -817,13 +818,6 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
|
||||
|
||||
return $mock;
|
||||
}
|
||||
|
||||
private function hasSttyAvailable()
|
||||
{
|
||||
exec('stty 2>&1', $output, $exitcode);
|
||||
|
||||
return 0 === $exitcode;
|
||||
}
|
||||
}
|
||||
|
||||
class AutocompleteValues implements \IteratorAggregate
|
||||
|
@ -18,17 +18,31 @@ class TerminalTest extends TestCase
|
||||
{
|
||||
private $colSize;
|
||||
private $lineSize;
|
||||
private $ansiCon;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->colSize = getenv('COLUMNS');
|
||||
$this->lineSize = getenv('LINES');
|
||||
$this->ansiCon = getenv('ANSICON');
|
||||
$this->resetStatics();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
putenv($this->colSize ? 'COLUMNS='.$this->colSize : 'COLUMNS');
|
||||
putenv($this->lineSize ? 'LINES' : 'LINES='.$this->lineSize);
|
||||
putenv($this->ansiCon ? 'ANSICON='.$this->ansiCon : 'ANSICON');
|
||||
$this->resetStatics();
|
||||
}
|
||||
|
||||
private function resetStatics()
|
||||
{
|
||||
foreach (['height', 'width', 'stty'] as $name) {
|
||||
$property = new \ReflectionProperty(Terminal::class, $name);
|
||||
$property->setAccessible(true);
|
||||
$property->setValue(null);
|
||||
}
|
||||
}
|
||||
|
||||
public function test()
|
||||
@ -56,4 +70,28 @@ class TerminalTest extends TestCase
|
||||
$this->assertSame(0, $terminal->getWidth());
|
||||
$this->assertSame(0, $terminal->getHeight());
|
||||
}
|
||||
|
||||
public function testSttyOnWindows()
|
||||
{
|
||||
if ('\\' !== \DIRECTORY_SEPARATOR) {
|
||||
$this->markTestSkipped('Must be on windows');
|
||||
}
|
||||
|
||||
$sttyString = exec('(stty -a | grep columns) 2>&1', $output, $exitcode);
|
||||
if (0 !== $exitcode) {
|
||||
$this->markTestSkipped('Must have stty support');
|
||||
}
|
||||
|
||||
$matches = [];
|
||||
if (0 === preg_match('/columns.(\d+)/i', $sttyString, $matches)) {
|
||||
$this->fail('Could not determine existing stty columns');
|
||||
}
|
||||
|
||||
putenv('COLUMNS');
|
||||
putenv('LINES');
|
||||
putenv('ANSICON');
|
||||
|
||||
$terminal = new Terminal();
|
||||
$this->assertSame((int) $matches[1], $terminal->getWidth());
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class Gitignore
|
||||
*/
|
||||
public static function toRegex(string $gitignoreFileContent): string
|
||||
{
|
||||
$gitignoreFileContent = preg_replace('/^[^\\\\]*#.*/', '', $gitignoreFileContent);
|
||||
$gitignoreFileContent = preg_replace('/^[^\\\r\n]*#.*/m', '', $gitignoreFileContent);
|
||||
$gitignoreLines = preg_split('/\r\n|\r|\n/', $gitignoreFileContent);
|
||||
$gitignoreLines = array_map('trim', $gitignoreLines);
|
||||
$gitignoreLines = array_filter($gitignoreLines);
|
||||
|
@ -107,7 +107,31 @@ class GitignoreTest extends TestCase
|
||||
#IamComment
|
||||
/app/cache/',
|
||||
['app/cache/file.txt', 'app/cache/subdir/ile.txt'],
|
||||
['a/app/cache/file.txt'],
|
||||
['a/app/cache/file.txt', '#IamComment', 'IamComment'],
|
||||
],
|
||||
[
|
||||
'
|
||||
/app/cache/
|
||||
#LastLineIsComment',
|
||||
['app/cache/file.txt', 'app/cache/subdir/ile.txt'],
|
||||
['a/app/cache/file.txt', '#LastLineIsComment', 'LastLineIsComment'],
|
||||
],
|
||||
[
|
||||
'
|
||||
/app/cache/
|
||||
\#file.txt
|
||||
#LastLineIsComment',
|
||||
['app/cache/file.txt', 'app/cache/subdir/ile.txt', '#file.txt'],
|
||||
['a/app/cache/file.txt', '#LastLineIsComment', 'LastLineIsComment'],
|
||||
],
|
||||
[
|
||||
'
|
||||
/app/cache/
|
||||
\#file.txt
|
||||
#IamComment
|
||||
another_file.txt',
|
||||
['app/cache/file.txt', 'app/cache/subdir/ile.txt', '#file.txt', 'another_file.txt'],
|
||||
['a/app/cache/file.txt', 'IamComment', '#IamComment'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
3
src/Symfony/Component/HttpClient/.gitignore
vendored
Normal file
3
src/Symfony/Component/HttpClient/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
@ -54,6 +54,10 @@ trait HttpClientTrait
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($options['normalized_headers']['accept'])) {
|
||||
$options['normalized_headers']['accept'] = [$options['headers'][] = 'Accept: *'];
|
||||
}
|
||||
|
||||
if (isset($options['body'])) {
|
||||
$options['body'] = self::normalizeBody($options['body']);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ class HttpClientTraitTest extends TestCase
|
||||
public function testAuthBearerOption()
|
||||
{
|
||||
[, $options] = self::prepareRequest('POST', 'http://example.com', ['auth_bearer' => 'foobar'], HttpClientInterface::OPTIONS_DEFAULTS);
|
||||
$this->assertSame(['Authorization: Bearer foobar'], $options['headers']);
|
||||
$this->assertSame(['Accept: *', 'Authorization: Bearer foobar'], $options['headers']);
|
||||
$this->assertSame(['Authorization: Bearer foobar'], $options['normalized_headers']['authorization']);
|
||||
}
|
||||
|
||||
|
3
src/Symfony/Component/Inflector/.gitignore
vendored
Normal file
3
src/Symfony/Component/Inflector/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
@ -120,6 +120,9 @@ final class Inflector
|
||||
// bureaus (bureau)
|
||||
['suae', 4, false, true, 'eau'],
|
||||
|
||||
// fees (fee), trees (tree), employees (employee)
|
||||
['see', 3, true, true, 'ee'],
|
||||
|
||||
// roses (rose), garages (garage), cassettes (cassette),
|
||||
// waltzes (waltz), heroes (hero), bushes (bush), arches (arch),
|
||||
// shoes (shoe)
|
||||
|
@ -38,7 +38,7 @@ class InflectorTest extends TestCase
|
||||
['bases', ['bas', 'base', 'basis']],
|
||||
['batches', ['batch', 'batche']],
|
||||
['beaux', 'beau'],
|
||||
['bees', ['be', 'bee']],
|
||||
['bees', 'bee'],
|
||||
['boxes', 'box'],
|
||||
['boys', 'boy'],
|
||||
['bureaus', 'bureau'],
|
||||
@ -68,7 +68,9 @@ class InflectorTest extends TestCase
|
||||
['echoes', ['echo', 'echoe']],
|
||||
['elves', ['elf', 'elve', 'elff']],
|
||||
['emphases', ['emphas', 'emphase', 'emphasis']],
|
||||
['employees', 'employee'],
|
||||
['faxes', 'fax'],
|
||||
['fees', 'fee'],
|
||||
['feet', 'foot'],
|
||||
['feedback', 'feedback'],
|
||||
['foci', 'focus'],
|
||||
@ -143,14 +145,14 @@ class InflectorTest extends TestCase
|
||||
['theses', ['thes', 'these', 'thesis']],
|
||||
['thieves', ['thief', 'thieve', 'thieff']],
|
||||
['treasons', 'treason'],
|
||||
['trees', ['tre', 'tree']],
|
||||
['trees', 'tree'],
|
||||
['waltzes', ['waltz', 'waltze']],
|
||||
['wives', 'wife'],
|
||||
|
||||
// test casing: if the first letter was uppercase, it should remain so
|
||||
['Men', 'Man'],
|
||||
['GrandChildren', 'GrandChild'],
|
||||
['SubTrees', ['SubTre', 'SubTree']],
|
||||
['SubTrees', 'SubTree'],
|
||||
|
||||
// Known issues
|
||||
//['insignia', 'insigne'],
|
||||
|
3
src/Symfony/Component/Mailer/.gitignore
vendored
Normal file
3
src/Symfony/Component/Mailer/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Component/Mailer/Bridge/Amazon/.gitignore
vendored
Normal file
3
src/Symfony/Component/Mailer/Bridge/Amazon/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Component/Mailer/Bridge/Google/.gitignore
vendored
Normal file
3
src/Symfony/Component/Mailer/Bridge/Google/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Component/Mailer/Bridge/Mailchimp/.gitignore
vendored
Normal file
3
src/Symfony/Component/Mailer/Bridge/Mailchimp/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Component/Mailer/Bridge/Mailgun/.gitignore
vendored
Normal file
3
src/Symfony/Component/Mailer/Bridge/Mailgun/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Component/Mailer/Bridge/Postmark/.gitignore
vendored
Normal file
3
src/Symfony/Component/Mailer/Bridge/Postmark/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Component/Messenger/.gitignore
vendored
Normal file
3
src/Symfony/Component/Messenger/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
@ -13,12 +13,15 @@ namespace Symfony\Component\Messenger\Tests\Command;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\Messenger\Command\FailedMessagesRetryCommand;
|
||||
use Symfony\Component\Messenger\Envelope;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Messenger\Retry\RetryStrategyInterface;
|
||||
use Symfony\Component\Messenger\Stamp\ReceivedStamp;
|
||||
use Symfony\Component\Messenger\Stamp\RedeliveryStamp;
|
||||
use Symfony\Component\Messenger\Transport\Receiver\ListableReceiverInterface;
|
||||
use Symfony\Component\Messenger\Worker;
|
||||
|
||||
class FailedMessagesRetryCommandTest extends TestCase
|
||||
{
|
||||
@ -34,16 +37,52 @@ class FailedMessagesRetryCommandTest extends TestCase
|
||||
// the bus should be called in the worker
|
||||
$bus->expects($this->exactly(2))->method('dispatch')->willReturn(new Envelope(new \stdClass()));
|
||||
|
||||
$command = new FailedMessagesRetryCommand(
|
||||
'failure_receiver',
|
||||
$receiver,
|
||||
$bus,
|
||||
$dispatcher
|
||||
);
|
||||
$command = new FailedMessagesRetryCommand('failure_receiver', $receiver, $bus, $dispatcher);
|
||||
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(['id' => [10, 12]]);
|
||||
|
||||
$this->assertStringContainsString('[OK]', $tester->getDisplay());
|
||||
}
|
||||
|
||||
public function testExceptionOnRetry()
|
||||
{
|
||||
$receiver = $this->createMock(ListableReceiverInterface::class);
|
||||
$receiver->expects($this->once())->method('find')->with(10)->willReturn(new Envelope(new \stdClass()));
|
||||
// message will eventually be ack'ed in Worker
|
||||
$receiver->expects($this->once())->method('ack');
|
||||
|
||||
$dispatcher = $this->createMock(EventDispatcherInterface::class);
|
||||
$bus = $this->createMock(MessageBusInterface::class);
|
||||
// the bus should be called in the worker
|
||||
$bus->expects($this->at(0))
|
||||
->method('dispatch')
|
||||
->with($this->callback(function (Envelope $envelope) {
|
||||
$lastReceivedStamp = $envelope->last(ReceivedStamp::class);
|
||||
|
||||
return $lastReceivedStamp instanceof ReceivedStamp && \is_string($lastReceivedStamp->getTransportName());
|
||||
}))
|
||||
->will($this->throwException(new \Exception('Mock test exception')));
|
||||
|
||||
$bus->expects($this->at(1))
|
||||
->method('dispatch')
|
||||
->with($this->callback(function (Envelope $envelope) {
|
||||
$lastRedeliveryStamp = $envelope->last(RedeliveryStamp::class);
|
||||
|
||||
return $lastRedeliveryStamp instanceof RedeliveryStamp &&
|
||||
\is_string($lastRedeliveryStamp->getExceptionMessage()) &&
|
||||
$lastRedeliveryStamp->getFlattenException() instanceof FlattenException;
|
||||
}))
|
||||
->willReturn(new Envelope(new \stdClass()));
|
||||
|
||||
$retryStrategy = $this->createMock(RetryStrategyInterface::class);
|
||||
$retryStrategy->expects($this->once())->method('isRetryable')->with($this->isInstanceOf(Envelope::class))->willReturn(true);
|
||||
|
||||
$command = new FailedMessagesRetryCommand('failure_receiver', $receiver, $bus, $dispatcher, $retryStrategy);
|
||||
|
||||
$tester = new CommandTester($command);
|
||||
$tester->execute(['id' => [10]]);
|
||||
|
||||
$this->assertStringContainsString('[OK]', $tester->getDisplay());
|
||||
}
|
||||
}
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Symfony\Component\Messenger;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\Messenger\Event\WorkerMessageFailedEvent;
|
||||
use Symfony\Component\Messenger\Event\WorkerMessageHandledEvent;
|
||||
use Symfony\Component\Messenger\Event\WorkerMessageReceivedEvent;
|
||||
@ -150,7 +151,7 @@ class Worker implements WorkerInterface
|
||||
|
||||
// add the delay and retry stamp info + remove ReceivedStamp
|
||||
$retryEnvelope = $envelope->with(new DelayStamp($delay))
|
||||
->with(new RedeliveryStamp($retryCount, $transportName))
|
||||
->with(new RedeliveryStamp($retryCount, $transportName, $throwable->getMessage(), $this->flattenedException($throwable)))
|
||||
->withoutAll(ReceivedStamp::class);
|
||||
|
||||
// re-send the message
|
||||
@ -213,4 +214,17 @@ class Worker implements WorkerInterface
|
||||
|
||||
return $retryStrategy->isRetryable($envelope);
|
||||
}
|
||||
|
||||
private function flattenedException(\Throwable $throwable): ?FlattenException
|
||||
{
|
||||
if (!class_exists(FlattenException::class)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($throwable instanceof HandlerFailedException) {
|
||||
$throwable = $throwable->getNestedExceptions()[0];
|
||||
}
|
||||
|
||||
return FlattenException::createFromThrowable($throwable);
|
||||
}
|
||||
}
|
||||
|
3
src/Symfony/Component/PropertyInfo/.gitignore
vendored
Normal file
3
src/Symfony/Component/PropertyInfo/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
@ -87,7 +87,7 @@ class GuardAuthenticatorHandlerTest extends TestCase
|
||||
/**
|
||||
* @dataProvider getTokenClearingTests
|
||||
*/
|
||||
public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderKey, $actualProviderKey)
|
||||
public function testHandleAuthenticationClearsToken($tokenProviderKey, $actualProviderKey)
|
||||
{
|
||||
$this->tokenStorage->expects($this->never())
|
||||
->method('setToken')
|
||||
@ -108,10 +108,10 @@ class GuardAuthenticatorHandlerTest extends TestCase
|
||||
public function getTokenClearingTests()
|
||||
{
|
||||
$tests = [];
|
||||
// correct token class and matching firewall => clear the token
|
||||
$tests[] = ['Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken', 'the_firewall_key', 'the_firewall_key'];
|
||||
$tests[] = ['Symfony\Component\Security\Guard\Token\PostAuthenticationGuardToken', 'the_firewall_key', 'different_key'];
|
||||
$tests[] = ['Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', 'the_firewall_key', 'the_firewall_key'];
|
||||
// matching firewall => clear the token
|
||||
$tests[] = ['the_firewall_key', 'the_firewall_key'];
|
||||
$tests[] = ['the_firewall_key', 'different_key'];
|
||||
$tests[] = ['the_firewall_key', 'the_firewall_key'];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
3
src/Symfony/Component/Workflow/.gitignore
vendored
Normal file
3
src/Symfony/Component/Workflow/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Contracts/Cache/.gitignore
vendored
Normal file
3
src/Symfony/Contracts/Cache/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Contracts/EventDispatcher/.gitignore
vendored
Normal file
3
src/Symfony/Contracts/EventDispatcher/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Contracts/HttpClient/.gitignore
vendored
Normal file
3
src/Symfony/Contracts/HttpClient/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Contracts/Service/.gitignore
vendored
Normal file
3
src/Symfony/Contracts/Service/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
3
src/Symfony/Contracts/Translation/.gitignore
vendored
Normal file
3
src/Symfony/Contracts/Translation/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
Reference in New Issue
Block a user