Skip to content

Commit 5630b52

Browse files
committed
Merge branch '3.4' into 4.4
* 3.4: Add Tagalog translations for validator messages 94, 95, 96 and 99 PHPUnit's assertContains() performs strict comparisons now. [ClassLoader][Routing] Fix namespace parsing on php 8. Fix deprecated libxml_disable_entity_loader Made reference to PHPUnit\Util\XML::loadfile php5-compatible. [Validator] Add missing translations for german and vietnamese Modernized deprecated PHPUnit assertion calls [Console] The message of "class not found" errors has changed in php 8. The PHPUnit\Util\XML class has been removed in PHPUnit 9.3. [Console] Make sure we pass a numeric array of arguments to call_user_func_array(). [Serializer] Fix that it will never reach DOMNode [Validator] sync translations [VarDumper] Improve previous fix on light array coloration [Cache] Fix #37667
2 parents 55d0702 + 71da881 commit 5630b52

File tree

3 files changed

+28
-28
lines changed

3 files changed

+28
-28
lines changed

Descriptor/TextDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ protected function describeApplication(Application $application, array $options
212212
// calculate max. width based on available commands per namespace
213213
$width = $this->getColumnWidth(array_merge(...array_values(array_map(function ($namespace) use ($commands) {
214214
return array_intersect($namespace['commands'], array_keys($commands));
215-
}, $namespaces))));
215+
}, array_values($namespaces)))));
216216

217217
if ($describedNamespace) {
218218
$this->writeText(sprintf('<comment>Available commands for the "%s" namespace:</comment>', $describedNamespace), $options);

Tests/ApplicationTest.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -559,9 +559,9 @@ public function testFindAlternativeExceptionMessageMultiple()
559559
$this->fail('->find() throws a CommandNotFoundException if command does not exist, with alternatives');
560560
} catch (\Exception $e) {
561561
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives');
562-
$this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives');
563-
$this->assertRegExp('/foo1:bar/', $e->getMessage());
564-
$this->assertRegExp('/foo:bar/', $e->getMessage());
562+
$this->assertMatchesRegularExpression('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives');
563+
$this->assertMatchesRegularExpression('/foo1:bar/', $e->getMessage());
564+
$this->assertMatchesRegularExpression('/foo:bar/', $e->getMessage());
565565
}
566566

567567
// Namespace + plural
@@ -570,8 +570,8 @@ public function testFindAlternativeExceptionMessageMultiple()
570570
$this->fail('->find() throws a CommandNotFoundException if command does not exist, with alternatives');
571571
} catch (\Exception $e) {
572572
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist, with alternatives');
573-
$this->assertRegExp('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives');
574-
$this->assertRegExp('/foo1/', $e->getMessage());
573+
$this->assertMatchesRegularExpression('/Did you mean one of these/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives');
574+
$this->assertMatchesRegularExpression('/foo1/', $e->getMessage());
575575
}
576576

577577
$application->add(new \Foo3Command());
@@ -583,8 +583,8 @@ public function testFindAlternativeExceptionMessageMultiple()
583583
$this->fail('->find() should throw an Symfony\Component\Console\Exception\CommandNotFoundException if a command is ambiguous because of a subnamespace, with alternatives');
584584
} catch (\Exception $e) {
585585
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e);
586-
$this->assertRegExp('/foo3:bar/', $e->getMessage());
587-
$this->assertRegExp('/foo3:bar:toh/', $e->getMessage());
586+
$this->assertMatchesRegularExpression('/foo3:bar/', $e->getMessage());
587+
$this->assertMatchesRegularExpression('/foo3:bar:toh/', $e->getMessage());
588588
}
589589
}
590590

@@ -613,10 +613,10 @@ public function testFindAlternativeCommands()
613613
} catch (\Exception $e) {
614614
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command does not exist');
615615
$this->assertSame(['afoobar1', 'foo:bar1'], $e->getAlternatives());
616-
$this->assertRegExp(sprintf('/Command "%s" is not defined./', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives');
617-
$this->assertRegExp('/afoobar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "afoobar1"');
618-
$this->assertRegExp('/foo:bar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "foo:bar1"');
619-
$this->assertNotRegExp('/foo:bar(?!1)/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without "foo:bar" alternative');
616+
$this->assertMatchesRegularExpression(sprintf('/Command "%s" is not defined./', $commandName), $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternatives');
617+
$this->assertMatchesRegularExpression('/afoobar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "afoobar1"');
618+
$this->assertMatchesRegularExpression('/foo:bar1/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, with alternative : "foo:bar1"');
619+
$this->assertDoesNotMatchRegularExpression('/foo:bar(?!1)/', $e->getMessage(), '->find() throws a CommandNotFoundException if command does not exist, without "foo:bar" alternative');
620620
}
621621
}
622622

@@ -664,10 +664,10 @@ public function testFindAlternativeNamespace()
664664
$this->assertContains('foo', $e->getAlternatives());
665665
$this->assertContains('foo1', $e->getAlternatives());
666666
$this->assertContains('foo3', $e->getAlternatives());
667-
$this->assertRegExp('/There are no commands defined in the "foo2" namespace./', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative');
668-
$this->assertRegExp('/foo/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo"');
669-
$this->assertRegExp('/foo1/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo1"');
670-
$this->assertRegExp('/foo3/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo3"');
667+
$this->assertMatchesRegularExpression('/There are no commands defined in the "foo2" namespace./', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative');
668+
$this->assertMatchesRegularExpression('/foo/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo"');
669+
$this->assertMatchesRegularExpression('/foo1/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo1"');
670+
$this->assertMatchesRegularExpression('/foo3/', $e->getMessage(), '->find() throws a CommandNotFoundException if namespace does not exist, with alternative : "foo3"');
671671
}
672672
}
673673

@@ -698,7 +698,7 @@ public function testFindAlternativesOutput()
698698
$this->assertInstanceOf('Symfony\Component\Console\Exception\CommandNotFoundException', $e, '->find() throws a CommandNotFoundException if command is not defined');
699699
$this->assertSame($expectedAlternatives, $e->getAlternatives());
700700

701-
$this->assertRegExp('/Command "foo" is not defined\..*Did you mean one of these\?.*/Ums', $e->getMessage());
701+
$this->assertMatchesRegularExpression('/Command "foo" is not defined\..*Did you mean one of these\?.*/Ums', $e->getMessage());
702702
}
703703
}
704704

@@ -813,9 +813,9 @@ public function testRenderException()
813813
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3.txt', $tester->getErrorOutput(true), '->renderException() renders a pretty exceptions with previous exceptions');
814814

815815
$tester->run(['command' => 'foo3:bar'], ['decorated' => false, 'verbosity' => Output::VERBOSITY_VERBOSE]);
816-
$this->assertRegExp('/\[Exception\]\s*First exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is default and verbosity is verbose');
817-
$this->assertRegExp('/\[Exception\]\s*Second exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is 0 and verbosity is verbose');
818-
$this->assertRegExp('/\[Exception \(404\)\]\s*Third exception/', $tester->getDisplay(), '->renderException() renders a pretty exception with code exception when code exception is 404 and verbosity is verbose');
816+
$this->assertMatchesRegularExpression('/\[Exception\]\s*First exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is default and verbosity is verbose');
817+
$this->assertMatchesRegularExpression('/\[Exception\]\s*Second exception/', $tester->getDisplay(), '->renderException() renders a pretty exception without code exception when code exception is 0 and verbosity is verbose');
818+
$this->assertMatchesRegularExpression('/\[Exception \(404\)\]\s*Third exception/', $tester->getDisplay(), '->renderException() renders a pretty exception with code exception when code exception is 404 and verbosity is verbose');
819819

820820
$tester->run(['command' => 'foo3:bar'], ['decorated' => true]);
821821
$this->assertStringEqualsFile(self::$fixturesPath.'/application_renderexception3decorated.txt', $tester->getDisplay(true), '->renderException() renders a pretty exceptions with previous exceptions');
@@ -1462,8 +1462,8 @@ public function testErrorIsRethrownIfNotHandledByConsoleErrorEvent()
14621462
$application->setCatchExceptions(false);
14631463
$application->setDispatcher(new EventDispatcher());
14641464

1465-
$application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
1466-
new \UnknownClass();
1465+
$application->register('dym')->setCode(function () {
1466+
throw new \Error('Something went wrong.');
14671467
});
14681468

14691469
$tester = new ApplicationTester($application);
@@ -1472,7 +1472,7 @@ public function testErrorIsRethrownIfNotHandledByConsoleErrorEvent()
14721472
$tester->run(['command' => 'dym']);
14731473
$this->fail('->run() should rethrow PHP errors if not handled via ConsoleErrorEvent.');
14741474
} catch (\Error $e) {
1475-
$this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found');
1475+
$this->assertSame('Something went wrong.', $e->getMessage());
14761476
}
14771477
}
14781478

@@ -1767,8 +1767,8 @@ public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEn
17671767
$application->setAutoExit(false);
17681768
$application->setDispatcher(new EventDispatcher());
17691769

1770-
$application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
1771-
new \UnknownClass();
1770+
$application->register('dym')->setCode(function () {
1771+
throw new \Error('Something went wrong.');
17721772
});
17731773

17741774
$tester = new ApplicationTester($application);
@@ -1777,7 +1777,7 @@ public function testErrorIsRethrownIfNotHandledByConsoleErrorEventWithCatchingEn
17771777
$tester->run(['command' => 'dym']);
17781778
$this->fail('->run() should rethrow PHP errors if not handled via ConsoleErrorEvent.');
17791779
} catch (\Error $e) {
1780-
$this->assertSame($e->getMessage(), 'Class \'UnknownClass\' not found');
1780+
$this->assertSame('Something went wrong.', $e->getMessage());
17811781
}
17821782
}
17831783

Tests/Command/ListCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public function testExecuteListsCommands()
2323
$commandTester = new CommandTester($command = $application->get('list'));
2424
$commandTester->execute(['command' => $command->getName()], ['decorated' => false]);
2525

26-
$this->assertRegExp('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
26+
$this->assertMatchesRegularExpression('/help\s{2,}Displays help for a command/', $commandTester->getDisplay(), '->execute() returns a list of available commands');
2727
}
2828

2929
public function testExecuteListsCommandsWithXmlOption()
3030
{
3131
$application = new Application();
3232
$commandTester = new CommandTester($command = $application->get('list'));
3333
$commandTester->execute(['command' => $command->getName(), '--format' => 'xml']);
34-
$this->assertRegExp('/<command id="list" name="list" hidden="0">/', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed');
34+
$this->assertMatchesRegularExpression('/<command id="list" name="list" hidden="0">/', $commandTester->getDisplay(), '->execute() returns a list of available commands in XML if --xml is passed');
3535
}
3636

3737
public function testExecuteListsCommandsWithRawOption()

0 commit comments

Comments
 (0)