Merge branch '4.3' into 4.4

* 4.3:
  Fix inconsistent return points.
  pass translation parameters to the trans filter
  [Mime] fixed wrong mimetype
  [ProxyManagerBridge] Polyfill for unmaintained version
  [HttpClient] Declare `$active` first to prevent weird issue
  Remove deprecated assertContains
  [HttpClient] fix tests
  SCA: dropped unused mocks, duplicate import and a function alias usage
  Added correct plural for box -> boxes
  [Config] fix test
  Fix remaining tests
  Improve fa (persian) translation
This commit is contained in:
Nicolas Grekas 2019-08-07 14:00:28 +02:00
commit a0c2aa8302
85 changed files with 433 additions and 182 deletions

View File

@ -139,7 +139,8 @@
"Symfony\\Component\\": "src/Symfony/Component/"
},
"classmap": [
"src/Symfony/Component/Intl/Resources/stubs"
"src/Symfony/Component/Intl/Resources/stubs",
"src/Symfony/Bridge/ProxyManager/Legacy/ProxiedMethodReturnExpression.php"
],
"exclude-from-classmap": [
"**/Tests/"

View File

@ -113,5 +113,7 @@ class Logger extends BaseLogger implements DebugLoggerInterface, ResetInterface
return $handler;
}
}
return null;
}
}

View File

@ -46,8 +46,8 @@ class DeprecationTest extends TestCase
public function testItCanBeConvertedToAString()
{
$deprecation = new Deprecation('💩', $this->debugBacktrace(), __FILE__);
$this->assertContains('💩', $deprecation->toString());
$this->assertContains(__FUNCTION__, $deprecation->toString());
$this->assertStringContainsString('💩', $deprecation->toString());
$this->assertStringContainsString(__FUNCTION__, $deprecation->toString());
}
public function testItRulesOutFilesOutsideVendorsAsIndirect()

View File

@ -94,6 +94,10 @@ EOF;
);
}
if (version_compare(self::getProxyManagerVersion(), '2.5', '<')) {
$code = str_replace(' \Closure::bind(function ', ' \Closure::bind(static function ', $code);
}
return $code;
}

View File

@ -0,0 +1,73 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ProxyManager\Generator\Util;
use Composer\Autoload\ClassLoader;
use ProxyManager\Version;
if (class_exists(Version::class) && version_compare(\defined(Version::class.'::VERSION') ? Version::VERSION : Version::getVersion(), '2.5', '<')) {
/**
* Utility class to generate return expressions in method, given a method signature.
*
* This is required since return expressions may be forbidden by the method signature (void).
*
* @author Marco Pivetta <ocramius@gmail.com>
* @license MIT
*
* @see https://github.com/Ocramius/ProxyManager
*/
final class ProxiedMethodReturnExpression
{
public static function generate(string $returnedValueExpression, ?\ReflectionMethod $originalMethod): string
{
$originalReturnType = null === $originalMethod ? null : $originalMethod->getReturnType();
$originalReturnTypeName = null === $originalReturnType ? null : $originalReturnType->getName();
if ('void' === $originalReturnTypeName) {
return $returnedValueExpression.";\nreturn;";
}
return 'return '.$returnedValueExpression.';';
}
}
} else {
// Fallback to the original class by unregistering this file from composer class loader
$getComposerClassLoader = static function ($functionLoader) use (&$getComposerClassLoader) {
if (\is_array($functionLoader)) {
$functionLoader = $functionLoader[0];
}
if (!\is_object($functionLoader)) {
return;
}
if ($functionLoader instanceof ClassLoader) {
return $functionLoader;
}
if ($functionLoader instanceof \Symfony\Component\Debug\DebugClassLoader) {
return $getComposerClassLoader($functionLoader->getClassLoader());
}
if ($functionLoader instanceof \Symfony\Component\ErrorHandler\DebugClassLoader) {
return $getComposerClassLoader($functionLoader->getClassLoader());
}
};
$classLoader = null;
$functions = spl_autoload_functions();
while (null === $classLoader && $functions) {
$classLoader = $getComposerClassLoader(array_shift($functions));
}
$getComposerClassLoader = null;
if (null !== $classLoader) {
$classLoader->addClassMap([ProxiedMethodReturnExpression::class => null]);
$classLoader->loadClass(ProxiedMethodReturnExpression::class);
}
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy\PhpDumper;
use PHPUnit\Framework\TestCase;
use ProxyManager\Version;
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\LazyProxy\PhpDumper\DumperInterface;
@ -59,6 +60,20 @@ class ProxyDumperTest extends TestCase
);
}
public function testStaticBinding()
{
if (!class_exists(Version::class) || version_compare(\defined(Version::class.'::VERSION') ? Version::VERSION : Version::getVersion(), '2.1', '<')) {
$this->markTestSkipped('ProxyManager prior to version 2.1 does not support static binding');
}
$definition = new Definition(__CLASS__);
$definition->setLazy(true);
$code = $this->dumper->getProxyCode($definition);
$this->assertStringContainsString('\Closure::bind(static function (\PHPUnit\Framework\TestCase $instance) {', $code);
}
public function testDeterministicProxyCode()
{
$definition = new Definition(__CLASS__);

View File

@ -28,6 +28,7 @@
},
"autoload": {
"psr-4": { "Symfony\\Bridge\\ProxyManager\\": "" },
"classmap": [ "Legacy/ProxiedMethodReturnExpression.php" ],
"exclude-from-classmap": [
"/Tests/"
]

View File

@ -99,7 +99,7 @@
{%- endif -%}
{%- endif -%}
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
{{- widget|raw }} {{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain)) -}}
</label>
{%- endif -%}
{%- endblock checkbox_radio_label %}

View File

@ -266,7 +266,7 @@
{{ widget|raw }}
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain)) -}}
{{- form_errors(form) -}}
</label>
{%- endif -%}

View File

@ -266,7 +266,7 @@
{% endif %}
<label{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}>
{{ widget|raw }}
{{ translation_domain is same as(false) ? label : label|trans({}, translation_domain) }}
{{ translation_domain is same as(false) ? label : label|trans(label_translation_parameters, translation_domain) }}
</label>
{%- endblock checkbox_radio_label %}

View File

@ -225,7 +225,7 @@ class Configuration implements ConfigurationInterface
->canBeEnabled()
->beforeNormalization()
->always(function ($v) {
if (true === $v['enabled']) {
if (\is_array($v) && true === $v['enabled']) {
$workflows = $v;
unset($workflows['enabled']);

View File

@ -45,7 +45,7 @@ class CachePoolDeleteCommandTest extends TestCase
$tester = $this->getCommandTester($this->getKernel());
$tester->execute(['pool' => 'foo', 'key' => 'bar']);
$this->assertContains('[OK] Cache item "bar" was successfully deleted.', $tester->getDisplay());
$this->assertStringContainsString('[OK] Cache item "bar" was successfully deleted.', $tester->getDisplay());
}
public function testCommandWithInValidKey()
@ -62,7 +62,7 @@ class CachePoolDeleteCommandTest extends TestCase
$tester = $this->getCommandTester($this->getKernel());
$tester->execute(['pool' => 'foo', 'key' => 'bar']);
$this->assertContains('[NOTE] Cache item "bar" does not exist in cache pool "foo".', $tester->getDisplay());
$this->assertStringContainsString('[NOTE] Cache item "bar" does not exist in cache pool "foo".', $tester->getDisplay());
}
public function testCommandDeleteFailed()

View File

@ -69,7 +69,7 @@ EOF;
);
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('[OK] All 0 XLIFF files contain valid syntax', trim($tester->getDisplay()));
$this->assertStringContainsString('[OK] All 0 XLIFF files contain valid syntax', trim($tester->getDisplay()));
}
/**

View File

@ -226,7 +226,7 @@ class ApplicationTest extends TestCase
$this->assertSame(0, $tester->getStatusCode());
$display = explode('Lists commands', $tester->getDisplay());
$this->assertContains(trim('[WARNING] Some commands could not be registered:'), trim($display[1]));
$this->assertStringContainsString(trim('[WARNING] Some commands could not be registered:'), trim($display[1]));
}
public function testSuggestingPackagesWithExactMatch()

View File

@ -31,8 +31,8 @@ class CachePoolListCommandTest extends AbstractWebTestCase
$tester->execute([]);
$this->assertSame(0, $tester->getStatusCode(), 'cache:pool:list exits with 0 in case of success');
$this->assertContains('cache.app', $tester->getDisplay());
$this->assertContains('cache.system', $tester->getDisplay());
$this->assertStringContainsString('cache.app', $tester->getDisplay());
$this->assertStringContainsString('cache.system', $tester->getDisplay());
}
public function testEmptyList()

View File

@ -71,7 +71,7 @@ class ConfigDebugCommandTest extends AbstractWebTestCase
$tester = $this->createCommandTester();
$tester->execute(['name' => 'FrameworkBundle']);
$this->assertContains("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
$this->assertStringContainsString("cookie_httponly: '%env(bool:COOKIE_HTTPONLY)%'", $tester->getDisplay());
}
/**

View File

@ -57,15 +57,15 @@ class ContainerDebugCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:container', '--show-hidden' => true]);
$this->assertNotContains('public', $tester->getDisplay());
$this->assertNotContains('private_alias', $tester->getDisplay());
$this->assertStringNotContainsString('public', $tester->getDisplay());
$this->assertStringNotContainsString('private_alias', $tester->getDisplay());
$tester->run(['command' => 'debug:container']);
$this->assertContains('public', $tester->getDisplay());
$this->assertContains('private_alias', $tester->getDisplay());
$this->assertStringContainsString('public', $tester->getDisplay());
$this->assertStringContainsString('private_alias', $tester->getDisplay());
$tester->run(['command' => 'debug:container', 'name' => 'private_alias']);
$this->assertContains('The "private_alias" service or alias has been removed', $tester->getDisplay());
$this->assertStringContainsString('The "private_alias" service or alias has been removed', $tester->getDisplay());
}
/**
@ -133,7 +133,7 @@ TXT
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:container', '--env-var' => 'js'], ['decorated' => false]);
$this->assertContains(file_get_contents(__DIR__.'/Fixtures/describe_env_vars.txt'), $tester->getDisplay(true));
$this->assertStringContainsString(file_get_contents(__DIR__.'/Fixtures/describe_env_vars.txt'), $tester->getDisplay(true));
}
public function provideIgnoreBackslashWhenFindingService()

View File

@ -56,7 +56,7 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'HttpKernelHttpKernelInterface']);
$this->assertContains('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
$this->assertStringContainsString('Symfony\Component\HttpKernel\HttpKernelInterface', $tester->getDisplay());
}
public function testSearchNoResults()
@ -83,7 +83,7 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect']);
$this->assertContains(' more concrete service would be displayed when adding the "--all" option.', $tester->getDisplay());
$this->assertStringContainsString(' more concrete service would be displayed when adding the "--all" option.', $tester->getDisplay());
}
public function testSearchNotAliasedServiceWithAll()
@ -95,6 +95,6 @@ class DebugAutowiringCommandTest extends AbstractWebTestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'debug:autowiring', 'search' => 'redirect', '--all' => true]);
$this->assertContains('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
$this->assertStringContainsString('Pro-tip: use interfaces in your type-hints instead of classes to benefit from the dependency inversion principle.', $tester->getDisplay());
}
}

View File

@ -34,9 +34,9 @@ class RouterDebugCommandTest extends AbstractWebTestCase
$display = $tester->getDisplay();
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('routerdebug_test', $display);
$this->assertContains('/test', $display);
$this->assertContains('/session', $display);
$this->assertStringContainsString('routerdebug_test', $display);
$this->assertStringContainsString('/test', $display);
$this->assertStringContainsString('/session', $display);
}
public function testDumpOneRoute()
@ -45,8 +45,8 @@ class RouterDebugCommandTest extends AbstractWebTestCase
$ret = $tester->execute(['name' => 'routerdebug_session_welcome']);
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('routerdebug_session_welcome', $tester->getDisplay());
$this->assertContains('/session', $tester->getDisplay());
$this->assertStringContainsString('routerdebug_session_welcome', $tester->getDisplay());
$this->assertStringContainsString('/session', $tester->getDisplay());
}
public function testSearchMultipleRoutes()
@ -56,9 +56,9 @@ class RouterDebugCommandTest extends AbstractWebTestCase
$ret = $tester->execute(['name' => 'routerdebug'], ['interactive' => true]);
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('Select one of the matching routes:', $tester->getDisplay());
$this->assertContains('routerdebug_test', $tester->getDisplay());
$this->assertContains('/test', $tester->getDisplay());
$this->assertStringContainsString('Select one of the matching routes:', $tester->getDisplay());
$this->assertStringContainsString('routerdebug_test', $tester->getDisplay());
$this->assertStringContainsString('/test', $tester->getDisplay());
}
public function testSearchWithThrow()

View File

@ -33,13 +33,13 @@ class TranslationDebugCommandTest extends AbstractWebTestCase
$ret = $tester->execute(['locale' => 'en']);
$this->assertSame(0, $ret, 'Returns 0 in case of success');
$this->assertContains('missing messages hello_from_construct_arg_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_subscriber_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_property_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_method_calls_service', $tester->getDisplay());
$this->assertContains('missing messages hello_from_controller', $tester->getDisplay());
$this->assertContains('unused validators This value should be blank.', $tester->getDisplay());
$this->assertContains('unused security Invalid CSRF token.', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_construct_arg_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_subscriber_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_property_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_method_calls_service', $tester->getDisplay());
$this->assertStringContainsString('missing messages hello_from_controller', $tester->getDisplay());
$this->assertStringContainsString('unused validators This value should be blank.', $tester->getDisplay());
$this->assertStringContainsString('unused security Invalid CSRF token.', $tester->getDisplay());
}
private function createCommandTester(): CommandTester

View File

@ -54,14 +54,14 @@ class FirewallMap implements FirewallMapInterface
$context = $this->getFirewallContext($request);
if (null === $context) {
return;
return null;
}
return $context->getConfig();
}
/**
* @return FirewallContext
* @return FirewallContext|null
*/
private function getFirewallContext(Request $request)
{
@ -83,5 +83,7 @@ class FirewallMap implements FirewallMapInterface
return $this->container->get($contextId);
}
}
return null;
}
}

View File

@ -109,7 +109,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
], ['interactive' => false]);
$output = $this->passwordEncoderCommandTester->getDisplay();
$this->assertContains('Password encoding succeeded', $output);
$this->assertStringContainsString('Password encoding succeeded', $output);
$encoder = new NativePasswordEncoder();
preg_match('# Encoded password\s{1,}([\w+\/$.,=]+={0,2})\s+#', $output, $matches);
@ -130,7 +130,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
], ['interactive' => false]);
$output = $this->passwordEncoderCommandTester->getDisplay();
$this->assertContains('Password encoding succeeded', $output);
$this->assertStringContainsString('Password encoding succeeded', $output);
preg_match('# Encoded password\s+(\$?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches);
$hash = $matches[1];

View File

@ -159,9 +159,9 @@ class HttpBrowserTest extends AbstractBrowserTest
->expects($this->once())
->method('request')
->with('POST', 'http://example.com/', $this->callback(function ($options) {
$this->assertContains('Content-Type: multipart/form-data', implode('', $options['headers']));
$this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
$this->assertInstanceOf('\Generator', $options['body']);
$this->assertContains('my_file', implode('', iterator_to_array($options['body'])));
$this->assertStringContainsString('my_file', implode('', iterator_to_array($options['body'])));
return true;
}))

View File

@ -14,7 +14,6 @@ namespace Symfony\Component\Config\Tests\Definition\Builder;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Definition\Builder\FloatNodeDefinition;
use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition;
use Symfony\Component\Config\Definition\Builder\IntegerNodeDefinition as NumericNodeDefinition;
class NumericNodeDefinitionTest extends TestCase
{
@ -22,7 +21,7 @@ class NumericNodeDefinitionTest extends TestCase
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('You cannot define a min(4) as you already have a max(3)');
$def = new NumericNodeDefinition('foo');
$def = new IntegerNodeDefinition('foo');
$def->max(3)->min(4);
}
@ -30,7 +29,7 @@ class NumericNodeDefinitionTest extends TestCase
{
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('You cannot define a max(2) as you already have a min(3)');
$node = new NumericNodeDefinition('foo');
$node = new IntegerNodeDefinition('foo');
$node->min(3)->max(2);
}
@ -84,7 +83,7 @@ class NumericNodeDefinitionTest extends TestCase
{
$this->expectException('Symfony\Component\Config\Definition\Exception\InvalidDefinitionException');
$this->expectExceptionMessage('->cannotBeEmpty() is not applicable to NumericNodeDefinition.');
$def = new NumericNodeDefinition('foo');
$def = new IntegerNodeDefinition('foo');
$def->cannotBeEmpty();
}
}

View File

@ -234,7 +234,7 @@ class XmlUtils
return true;
case 'false' === $lowercaseValue:
return false;
case isset($value[1]) && '0b' == $value[0].$value[1]:
case isset($value[1]) && '0b' == $value[0].$value[1] && preg_match('/^0b[01]*$/', $value):
return bindec($value);
case is_numeric($value):
return '0x' === $value[0].$value[1] ? hexdec($value) : (float) $value;

View File

@ -87,25 +87,13 @@ class Terminal
*/
private static function getConsoleMode()
{
if (!\function_exists('proc_open')) {
return;
$info = self::readFromProcess('mode CON');
if (null === $info || !preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
return null;
}
$descriptorspec = [
1 => ['pipe', 'w'],
2 => ['pipe', 'w'],
];
$process = proc_open('mode CON', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
if (\is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $info, $matches)) {
return [(int) $matches[2], (int) $matches[1]];
}
}
return [(int) $matches[2], (int) $matches[1]];
}
/**
@ -114,9 +102,19 @@ class Terminal
* @return string|null
*/
private static function getSttyColumns()
{
return self::readFromProcess('stty -a | grep columns');
}
/**
* @param string $command
*
* @return string|null
*/
private static function readFromProcess($command)
{
if (!\function_exists('proc_open')) {
return;
return null;
}
$descriptorspec = [
@ -124,14 +122,16 @@ class Terminal
2 => ['pipe', 'w'],
];
$process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
if (\is_resource($process)) {
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
return $info;
$process = proc_open($command, $descriptorspec, $pipes, null, null, ['suppress_errors' => true]);
if (!\is_resource($process)) {
return null;
}
$info = stream_get_contents($pipes[1]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
return $info;
}
}

View File

@ -506,9 +506,9 @@ class ApplicationTest extends TestCase
$tester->setInputs(['y']);
$tester->run(['command' => 'foos'], ['decorated' => false]);
$display = trim($tester->getDisplay(true));
$this->assertContains('Command "foos" is not defined', $display);
$this->assertContains('Do you want to run "foo" instead? (yes/no) [no]:', $display);
$this->assertContains('called', $display);
$this->assertStringContainsString('Command "foos" is not defined', $display);
$this->assertStringContainsString('Do you want to run "foo" instead? (yes/no) [no]:', $display);
$this->assertStringContainsString('called', $display);
}
public function testDontRunAlternativeCommandName()
@ -521,8 +521,8 @@ class ApplicationTest extends TestCase
$exitCode = $tester->run(['command' => 'foos'], ['decorated' => false]);
$this->assertSame(1, $exitCode);
$display = trim($tester->getDisplay(true));
$this->assertContains('Command "foos" is not defined', $display);
$this->assertContains('Do you want to run "foo" instead? (yes/no) [no]:', $display);
$this->assertStringContainsString('Command "foos" is not defined', $display);
$this->assertStringContainsString('Do you want to run "foo" instead? (yes/no) [no]:', $display);
}
public function provideInvalidCommandNamesSingle()
@ -854,7 +854,7 @@ class ApplicationTest extends TestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'foo'], ['decorated' => false]);
$this->assertContains('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
$this->assertStringContainsString('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
$application = new Application();
$application->setAutoExit(false);
@ -865,7 +865,7 @@ class ApplicationTest extends TestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'foo'], ['decorated' => false]);
$this->assertContains('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true));
$this->assertStringContainsString('Dummy type "@anonymous" is invalid.', $tester->getDisplay(true));
}
public function testRenderExceptionStackTraceContainsRootException()
@ -879,7 +879,7 @@ class ApplicationTest extends TestCase
$tester = new ApplicationTester($application);
$tester->run(['command' => 'foo'], ['decorated' => false]);
$this->assertContains('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
$this->assertStringContainsString('[InvalidArgumentException@anonymous]', $tester->getDisplay(true));
$application = new Application();
$application->setAutoExit(false);

View File

@ -463,7 +463,7 @@ class ErrorHandler
}
if ($throw) {
if (E_USER_ERROR & $type) {
if (\PHP_VERSION_ID < 70400 && E_USER_ERROR & $type) {
for ($i = 1; isset($backtrace[$i]); ++$i) {
if (isset($backtrace[$i]['function'], $backtrace[$i]['type'], $backtrace[$i - 1]['function'])
&& '__toString' === $backtrace[$i]['function']

View File

@ -285,6 +285,10 @@ class ErrorHandlerTest extends TestCase
public function testHandleUserError()
{
if (\PHP_VERSION_ID >= 70400) {
$this->markTestSkipped('PHP 7.4 allows __toString to throw exceptions');
}
try {
$handler = ErrorHandler::register();
$handler->throwAt(0, true);

View File

@ -64,7 +64,7 @@ content="0;url=data:text/html;base64,PHNjcmlwdD5hbGVydCgndGVzdDMnKTwvc2NyaXB0Pg"
$handler->sendPhpResponse(new \RuntimeException($htmlWithXss));
$response = ob_get_clean();
$this->assertContains(sprintf('<h1 class="break-long-words exception-message">%s</h1>', htmlspecialchars($htmlWithXss, ENT_COMPAT | ENT_SUBSTITUTE, 'UTF-8')), $response);
$this->assertStringContainsString(sprintf('<h1 class="break-long-words exception-message">%s</h1>', htmlspecialchars($htmlWithXss, ENT_COMPAT | ENT_SUBSTITUTE, 'UTF-8')), $response);
}
public function testStatusCode()

View File

@ -309,6 +309,8 @@ class AutowirePass extends AbstractRecursivePass
if ($this->container->has($type) && !$this->container->findDefinition($type)->isAbstract()) {
return new TypedReference($type, $type, $reference->getInvalidBehavior());
}
return null;
}
/**
@ -441,7 +443,7 @@ class AutowirePass extends AbstractRecursivePass
} elseif (isset($this->types[$type])) {
$message = sprintf('the existing "%s" service', $this->types[$type]);
} else {
return;
return '';
}
return sprintf(' You should maybe alias this %s to %s.', class_exists($type, false) ? 'class' : 'interface', $message);
@ -469,5 +471,7 @@ class AutowirePass extends AbstractRecursivePass
if ($aliases) {
return sprintf('Try changing the type-hint to "%s" instead.', $aliases[0]);
}
return null;
}
}

View File

@ -208,7 +208,7 @@ class XmlFileLoader extends FileLoader
$alias->setDeprecated(true, $deprecated[0]->nodeValue ?: null);
}
return;
return null;
}
if ($this->isLoadingInstanceof) {

View File

@ -31,6 +31,6 @@ class CustomExpressionLanguageFunctionTest extends TestCase
$dump = new PhpDumper($container);
$dumped = $dump->dump();
$this->assertContains('strtolower("foobar")', $dumped);
$this->assertStringContainsString('strtolower("foobar")', $dumped);
}
}

View File

@ -57,7 +57,7 @@ class FormFieldRegistry
$target = &$this->fields;
while (\count($segments) > 1) {
$path = array_shift($segments);
if (!\array_key_exists($path, $target)) {
if (!\is_array($target) || !\array_key_exists($path, $target)) {
return;
}
$target = &$target[$path];
@ -80,7 +80,7 @@ class FormFieldRegistry
$target = &$this->fields;
while ($segments) {
$path = array_shift($segments);
if (!\array_key_exists($path, $target)) {
if (!\is_array($target) || !\array_key_exists($path, $target)) {
throw new \InvalidArgumentException(sprintf('Unreachable field "%s"', $path));
}
$target = &$target[$path];

View File

@ -33,11 +33,7 @@ class SortableIteratorTest extends RealIteratorTestCase
if (!\is_callable($mode)) {
switch ($mode) {
case SortableIterator::SORT_BY_ACCESSED_TIME:
if ('\\' === \DIRECTORY_SEPARATOR) {
touch(self::toAbsolute('.git'));
} else {
file_get_contents(self::toAbsolute('.git'));
}
touch(self::toAbsolute('.git'));
sleep(1);
file_get_contents(self::toAbsolute('.bar'));
break;

View File

@ -73,7 +73,7 @@ TXT
$tester->execute(['class' => 'DateTime'], ['decorated' => false, 'interactive' => false]);
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('Symfony\Component\Form\Extension\Core\Type\DateTimeType (Block prefix: "datetime")', $tester->getDisplay());
$this->assertStringContainsString('Symfony\Component\Form\Extension\Core\Type\DateTimeType (Block prefix: "datetime")', $tester->getDisplay());
}
public function testDebugFormTypeOption()

View File

@ -507,6 +507,7 @@ class DateTypeTest extends BaseTypeTest
public function testMonthsOption()
{
\Locale::setDefault('en');
$form = $this->factory->create(static::TESTED_TYPE, null, [
'months' => [6, 7],
'format' => \IntlDateFormatter::SHORT,
@ -515,8 +516,8 @@ class DateTypeTest extends BaseTypeTest
$view = $form->createView();
$this->assertEquals([
new ChoiceView(6, '6', '06'),
new ChoiceView(7, '7', '07'),
new ChoiceView(6, '6', '6'),
new ChoiceView(7, '7', '7'),
], $view['month']->vars['choices']);
}
@ -580,14 +581,15 @@ class DateTypeTest extends BaseTypeTest
public function testIsDayWithinRangeReturnsTrueIfWithin()
{
\Locale::setDefault('en');
$view = $this->factory->create(static::TESTED_TYPE, null, [
'days' => [6, 7],
])
->createView();
$this->assertEquals([
new ChoiceView(6, '6', '06'),
new ChoiceView(7, '7', '07'),
new ChoiceView(6, '6', '6'),
new ChoiceView(7, '7', '7'),
], $view['day']->vars['choices']);
}

View File

@ -314,6 +314,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface
throw new \TypeError(sprintf('%s() expects parameter 1 to be an iterable of CurlResponse objects, %s given.', __METHOD__, \is_object($responses) ? \get_class($responses) : \gettype($responses)));
}
$active = 0;
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
return new ResponseStream(CurlResponse::stream($responses, $timeout));
@ -326,6 +327,7 @@ final class CurlHttpClient implements HttpClientInterface, LoggerAwareInterface
curl_multi_setopt($this->multi->handle, CURLMOPT_PUSHFUNCTION, null);
}
$active = 0;
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($this->multi->handle, $active));
foreach ($this->multi->openHandles as $ch) {

View File

@ -255,6 +255,7 @@ final class CurlResponse implements ResponseInterface
try {
self::$performing = true;
$active = 0;
while (CURLM_CALL_MULTI_PERFORM === curl_multi_exec($multi->handle, $active));
while ($info = curl_multi_info_read($multi->handle)) {

View File

@ -15,6 +15,11 @@ use Symfony\Contracts\HttpClient\Test\HttpClientTestCase as BaseHttpClientTestCa
abstract class HttpClientTestCase extends BaseHttpClientTestCase
{
public function testMaxDuration()
{
$this->markTestSkipped('Implemented as of version 4.4');
}
public function testToStream()
{
$client = $this->getHttpClient(__FUNCTION__);

View File

@ -29,7 +29,7 @@ class ResponseIsRedirectedTest extends TestCase
try {
$constraint->evaluate(new Response());
} catch (ExpectationFailedException $e) {
$this->assertContains("Failed asserting that the Response is redirected.\nHTTP/1.0 200 OK", TestFailure::exceptionToString($e));
$this->assertStringContainsString("Failed asserting that the Response is redirected.\nHTTP/1.0 200 OK", TestFailure::exceptionToString($e));
return;
}

View File

@ -29,7 +29,7 @@ class ResponseIsSuccessfulTest extends TestCase
try {
$constraint->evaluate(new Response('', 404));
} catch (ExpectationFailedException $e) {
$this->assertContains("Failed asserting that the Response is successful.\nHTTP/1.0 404 Not Found", TestFailure::exceptionToString($e));
$this->assertStringContainsString("Failed asserting that the Response is successful.\nHTTP/1.0 404 Not Found", TestFailure::exceptionToString($e));
return;
}

View File

@ -31,7 +31,7 @@ class ResponseStatusCodeSameTest extends TestCase
try {
$constraint->evaluate(new Response('', 404));
} catch (ExpectationFailedException $e) {
$this->assertContains("Failed asserting that the Response status code is 200.\nHTTP/1.0 404 Not Found", TestFailure::exceptionToString($e));
$this->assertStringContainsString("Failed asserting that the Response status code is 200.\nHTTP/1.0 404 Not Found", TestFailure::exceptionToString($e));
return;
}

View File

@ -132,7 +132,7 @@ class Store implements StoreInterface
$key = $this->getCacheKey($request);
if (!$entries = $this->getMetadata($key)) {
return;
return null;
}
// find a cached entry that matches the request.
@ -146,7 +146,7 @@ class Store implements StoreInterface
}
if (null === $match) {
return;
return null;
}
$headers = $match[1];
@ -157,6 +157,7 @@ class Store implements StoreInterface
// TODO the metaStore referenced an entity that doesn't exist in
// the entityStore. We definitely want to return nil but we should
// also purge the entry from the meta-store when this is detected.
return null;
}
/**
@ -178,7 +179,7 @@ class Store implements StoreInterface
if (!$response->headers->has('X-Content-Digest')) {
$digest = $this->generateContentDigest($response);
if (false === $this->save($digest, $response->getContent())) {
if (!$this->save($digest, $response->getContent())) {
throw new \RuntimeException('Unable to store the entity.');
}
@ -207,7 +208,7 @@ class Store implements StoreInterface
array_unshift($entries, [$storedEnv, $headers]);
if (false === $this->save($key, serialize($entries))) {
if (!$this->save($key, serialize($entries))) {
throw new \RuntimeException('Unable to store the metadata.');
}
@ -246,7 +247,7 @@ class Store implements StoreInterface
}
}
if ($modified && false === $this->save($key, serialize($entries))) {
if ($modified && !$this->save($key, serialize($entries))) {
throw new \RuntimeException('Unable to store the metadata.');
}
}
@ -397,6 +398,8 @@ class Store implements StoreInterface
}
@chmod($path, 0666 & ~umask());
return true;
}
public function getPath($key)

View File

@ -218,7 +218,7 @@ class HttpKernelTest extends TestCase
// `file` index the array starting at 0, and __FILE__ starts at 1
$line = file($first['file'])[$first['line'] - 2];
$this->assertContains('// call controller', $line);
$this->assertStringContainsString('// call controller', $line);
}
}

View File

@ -284,6 +284,9 @@ final class Inflector
// indices (index)
['xedni', 5, false, true, ['indicies', 'indexes']],
// boxes (box)
['xo', 2, false, true, 'oxes'],
// indexes (index), matrixes (matrix)
['x', 1, true, false, ['cies', 'xes']],

View File

@ -180,7 +180,7 @@ class InflectorTest extends TestCase
['batch', 'batches'],
['beau', ['beaus', 'beaux']],
['bee', 'bees'],
['box', ['bocies', 'boxes']],
['box', 'boxes'],
['boy', 'boys'],
['bureau', ['bureaus', 'bureaux']],
['bus', 'buses'],

View File

@ -591,6 +591,7 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest
* @var CurrencyDataProvider
*/
protected $dataProvider;
private $defaultLocale;
protected function setUp()
{
@ -600,6 +601,15 @@ abstract class AbstractCurrencyDataProviderTest extends AbstractDataProviderTest
$this->getDataDirectory().'/'.Intl::CURRENCY_DIR,
$this->createEntryReader()
);
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
abstract protected function getDataDirectory();

View File

@ -829,6 +829,7 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
* @var LanguageDataProvider
*/
protected $dataProvider;
private $defaultLocale;
protected function setUp()
{
@ -838,6 +839,15 @@ abstract class AbstractLanguageDataProviderTest extends AbstractDataProviderTest
$this->getDataDirectory().'/'.Intl::LANGUAGE_DIR,
$this->createEntryReader()
);
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
abstract protected function getDataDirectory();

View File

@ -25,6 +25,7 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest
* @var LocaleDataProvider
*/
protected $dataProvider;
private $defaultLocale;
protected function setUp()
{
@ -34,6 +35,13 @@ abstract class AbstractLocaleDataProviderTest extends AbstractDataProviderTest
$this->getDataDirectory().'/'.Intl::LOCALE_DIR,
$this->createEntryReader()
);
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
{
\Locale::setDefault($this->defaultLocale);
}
abstract protected function getDataDirectory();

View File

@ -279,6 +279,7 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest
* @var RegionDataProvider
*/
protected $dataProvider;
private $defaultLocale;
protected function setUp()
{
@ -288,6 +289,15 @@ abstract class AbstractRegionDataProviderTest extends AbstractDataProviderTest
$this->getDataDirectory().'/'.Intl::REGION_DIR,
$this->createEntryReader()
);
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
abstract protected function getDataDirectory();

View File

@ -219,6 +219,7 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest
* @var ScriptDataProvider
*/
protected $dataProvider;
private $defaultLocale;
protected function setUp()
{
@ -228,6 +229,15 @@ abstract class AbstractScriptDataProviderTest extends AbstractDataProviderTest
$this->getDataDirectory().'/'.Intl::SCRIPT_DIR,
$this->createEntryReader()
);
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
abstract protected function getDataDirectory();

View File

@ -24,11 +24,23 @@ use Symfony\Component\Intl\Util\IcuVersion;
*/
abstract class AbstractIntlDateFormatterTest extends TestCase
{
private $defaultLocale;
protected function setUp()
{
parent::setUp();
$this->defaultLocale = \Locale::getDefault();
\Locale::setDefault('en');
}
protected function tearDown()
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
/**
* When a time zone is not specified, it uses the system default however it returns null in the getter method.
*

View File

@ -16,6 +16,22 @@ use Symfony\Component\Intl\Intl;
class IntlTest extends TestCase
{
private $defaultLocale;
protected function setUp()
{
parent::setUp();
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
/**
* @requires extension intl
*/

View File

@ -36,7 +36,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
{
return [
[100, 'ALL', '100'],
[100, 'BRL', '100.00'],
[100, 'BRL', '100'],
[100, 'CRC', '100'],
[100, 'JPY', '100'],
[100, 'CHF', '100'],

View File

@ -209,7 +209,7 @@ class LdapManagerTest extends LdapTestCase
$newEntry = $result[0];
$originalCN = $entry->getAttribute('cn')[0];
$this->assertContains($originalCN, $newEntry->getAttribute('cn'));
$this->assertStringContainsString($originalCN, $newEntry->getAttribute('cn'));
$entryManager->rename($newEntry, 'cn='.$originalCN);
@ -378,6 +378,6 @@ class LdapManagerTest extends LdapTestCase
$result = $this->executeSearchQuery(1);
$movedEntry = $result[0];
$this->assertContains('ou=Ldap', $movedEntry->getDn());
$this->assertStringContainsString('ou=Ldap', $movedEntry->getDn());
}
}

View File

@ -14,7 +14,7 @@ class LdapTestCase extends TestCase
$this->markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT');
}
ldap_close($h);
ldap_unbind($h);
return [
'host' => getenv('LDAP_HOST'),

View File

@ -62,7 +62,7 @@ class ConsumeMessagesCommandTest extends TestCase
]);
$this->assertSame(0, $tester->getStatusCode());
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
$this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
}
public function testRunWithBusOption()
@ -95,7 +95,7 @@ class ConsumeMessagesCommandTest extends TestCase
]);
$this->assertSame(0, $tester->getStatusCode());
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
$this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
}
/**
@ -131,7 +131,7 @@ class ConsumeMessagesCommandTest extends TestCase
]);
$this->assertSame(0, $tester->getStatusCode());
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
$this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
}
/**
@ -168,6 +168,6 @@ class ConsumeMessagesCommandTest extends TestCase
]);
$this->assertSame(0, $tester->getStatusCode());
$this->assertContains('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
$this->assertStringContainsString('[OK] Consuming messages from transports "dummy-receiver"', $tester->getDisplay());
}
}

View File

@ -32,6 +32,6 @@ class FailedMessagesRemoveCommandTest extends TestCase
$tester = new CommandTester($command);
$tester->execute(['id' => 20, '--force' => true]);
$this->assertContains('Message removed.', $tester->getDisplay());
$this->assertStringContainsString('Message removed.', $tester->getDisplay());
}
}

View File

@ -44,6 +44,6 @@ class FailedMessagesRetryCommandTest extends TestCase
$tester = new CommandTester($command);
$tester->execute(['id' => [10, 12]]);
$this->assertContains('[OK]', $tester->getDisplay());
$this->assertStringContainsString('[OK]', $tester->getDisplay());
}
}

View File

@ -45,7 +45,7 @@ class FailedMessagesShowCommandTest extends TestCase
$tester = new CommandTester($command);
$tester->execute(['id' => 15]);
$this->assertContains(sprintf(<<<EOF
$this->assertStringContainsString(sprintf(<<<EOF
------------- ---------------------
Class stdClass
Message Id 15

View File

@ -42,8 +42,8 @@ class SetupTransportsCommandTest extends TestCase
$tester->execute([]);
$display = $tester->getDisplay();
$this->assertContains('The "amqp" transport was setup successfully.', $display);
$this->assertContains('The "other_transport" transport does not support setup.', $display);
$this->assertStringContainsString('The "amqp" transport was setup successfully.', $display);
$this->assertStringContainsString('The "other_transport" transport does not support setup.', $display);
}
public function testReceiverNameArgument()
@ -66,7 +66,7 @@ class SetupTransportsCommandTest extends TestCase
$tester->execute(['transport' => 'amqp']);
$display = $tester->getDisplay();
$this->assertContains('The "amqp" transport was setup successfully.', $display);
$this->assertStringContainsString('The "amqp" transport was setup successfully.', $display);
}
public function testReceiverNameArgumentNotFound()

View File

@ -2431,12 +2431,12 @@ final class MimeTypes implements MimeTypesInterface
'odc' => ['application/vnd.oasis.opendocument.chart'],
'odf' => ['application/vnd.oasis.opendocument.formula'],
'odft' => ['application/vnd.oasis.opendocument.formula-template'],
'odg' => ['vnd.oasis.opendocument.graphics', 'application/vnd.oasis.opendocument.graphics'],
'odg' => ['application/vnd.oasis.opendocument.graphics'],
'odi' => ['application/vnd.oasis.opendocument.image'],
'odm' => ['application/vnd.oasis.opendocument.text-master'],
'odp' => ['vnd.oasis.opendocument.presentation', 'application/vnd.oasis.opendocument.presentation'],
'ods' => ['vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.spreadsheet'],
'odt' => ['vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.text'],
'odp' => ['application/vnd.oasis.opendocument.presentation'],
'ods' => ['application/vnd.oasis.opendocument.spreadsheet'],
'odt' => ['application/vnd.oasis.opendocument.text'],
'oga' => ['audio/ogg', 'audio/vorbis', 'audio/x-flac+ogg', 'audio/x-ogg', 'audio/x-oggflac', 'audio/x-speex+ogg', 'audio/x-vorbis', 'audio/x-vorbis+ogg'],
'ogg' => ['audio/ogg', 'audio/vorbis', 'audio/x-flac+ogg', 'audio/x-ogg', 'audio/x-oggflac', 'audio/x-speex+ogg', 'audio/x-vorbis', 'audio/x-vorbis+ogg', 'video/ogg', 'video/x-ogg', 'video/x-theora', 'video/x-theora+ogg'],
'ogm' => ['video/x-ogm', 'video/x-ogm+ogg'],

View File

@ -108,10 +108,6 @@ $exts = [
'mp4' => ['video/mp4'],
'mpeg' => ['video/mpeg'],
'mpg' => ['video/mpeg'],
'odg' => ['vnd.oasis.opendocument.graphics'],
'odp' => ['vnd.oasis.opendocument.presentation'],
'ods' => ['vnd.oasis.opendocument.spreadsheet'],
'odt' => ['vnd.oasis.opendocument.text'],
'ogg' => ['audio/ogg'],
'pdf' => ['application/pdf'],
'php' => ['application/x-php'],

View File

@ -330,7 +330,7 @@ class EmailTest extends TestCase
$this->assertCount(2, $parts = $related[0]->getParts());
$this->assertInstanceOf(AlternativePart::class, $parts[0]);
$generatedHtml = $parts[0]->getParts()[1];
$this->assertContains('cid:'.$parts[1]->getContentId(), $generatedHtml->getBody());
$this->assertStringContainsString('cid:'.$parts[1]->getContentId(), $generatedHtml->getBody());
$content = 'html content <img src="cid:test.gif">';
$r = fopen('php://memory', 'r+', false);

View File

@ -23,9 +23,9 @@ class MessagePartTest extends TestCase
public function testConstructor()
{
$p = new MessagePart((new Email())->from('fabien@symfony.com')->text('content'));
$this->assertContains('content', $p->getBody());
$this->assertContains('content', $p->bodyToString());
$this->assertContains('content', implode('', iterator_to_array($p->bodyToIterable())));
$this->assertStringContainsString('content', $p->getBody());
$this->assertStringContainsString('content', $p->bodyToString());
$this->assertStringContainsString('content', implode('', iterator_to_array($p->bodyToIterable())));
$this->assertEquals('message', $p->getMediaType());
$this->assertEquals('rfc822', $p->getMediaSubType());
}

View File

@ -797,6 +797,8 @@ class PropertyAccessor implements PropertyAccessorInterface
yield $result;
}
return null;
}
/**

View File

@ -331,7 +331,7 @@ class XmlFileLoader extends FileLoader
private function parseDefaultsConfig(\DOMElement $element, string $path)
{
if ($this->isElementValueNull($element)) {
return;
return null;
}
// Check for existing element nodes in the default element. There can
@ -365,7 +365,7 @@ class XmlFileLoader extends FileLoader
private function parseDefaultNode(\DOMElement $node, string $path)
{
if ($this->isElementValueNull($node)) {
return;
return null;
}
switch ($node->localName) {

View File

@ -4,39 +4,43 @@
<body>
<trans-unit id="1">
<source>An authentication exception occurred.</source>
<target>خطایی هنگام تعیین اعتبار اتفاق افتاد.</target>
<target>خطایی هنگام احراز هویت رخ داده است.</target>
</trans-unit>
<trans-unit id="2">
<source>Authentication credentials could not be found.</source>
<target>شرایط تعیین اعتبار پیدا نشد.</target>
<target>شرایط احراز هویت یافت نشد.</target>
</trans-unit>
<trans-unit id="3">
<source>Authentication request could not be processed due to a system problem.</source>
<target>درخواست تعیین اعتبار به دلیل مشکل سیستم قابل بررسی نیست.</target>
<target>درخواست احراز هویت به دلیل وجود مشکل در سیستم قابل پردازش نمی باشد.</target>
</trans-unit>
<trans-unit id="4">
<source>Invalid credentials.</source>
<target>شرایط نامعتبر.</target>
<target>احراز هویت نامعتبر می باشد.</target>
</trans-unit>
<trans-unit id="5">
<source>Cookie has already been used by someone else.</source>
<target>کوکی قبلا برای شخص دیگری استفاده شده است.</target>
<target>Cookie قبلا توسط شخص دیگری استفاده گردیده است.</target>
</trans-unit>
<trans-unit id="6">
<source>Not privileged to request the resource.</source>
<target>دسترسی لازم برای درخواست این منبع را ندارید.</target>
<target>دسترسی لازم برای درخواست از این منبع را دارا نمی باشید.</target>
</trans-unit>
<trans-unit id="7">
<source>Invalid CSRF token.</source>
<target>توکن CSRF معتبر نیست.</target>
<target>توکن CSRF معتبر نمی باشد.</target>
</trans-unit>
<trans-unit id="8">
<source>Digest nonce has expired.</source>
<target>Digest nonce منقضی گردیده است.</target>
</trans-unit>
<trans-unit id="9">
<source>No authentication provider found to support the authentication token.</source>
<target>هیچ ارایه کننده تعیین اعتباری برای ساپورت توکن تعیین اعتبار پیدا نشد.</target>
<target>هیچ ارایه دهنده احراز هویتی برای پشتیبانی از توکن احراز هویت پیدا نشد.</target>
</trans-unit>
<trans-unit id="10">
<source>No session available, it either timed out or cookies are not enabled.</source>
<target>جلسه‌ای در دسترس نیست. این میتواند یا به دلیل پایان یافتن زمان باشد یا اینکه کوکی ها فعال نیستند.</target>
<target>هیچ جلسه‌ای در دسترس نمی باشد. این میتواند به دلیل پایان یافتن زمان و یا فعال نبودن کوکی ها باشد.</target>
</trans-unit>
<trans-unit id="11">
<source>No token could be found.</source>
@ -48,19 +52,19 @@
</trans-unit>
<trans-unit id="13">
<source>Account has expired.</source>
<target>حساب کاربری منقضی شده است.</target>
<target>حساب کاربری منقضی گردیده است.</target>
</trans-unit>
<trans-unit id="14">
<source>Credentials have expired.</source>
<target>پارامترهای تعیین اعتبار منقضی شده‌اند.</target>
<target>مجوزهای احراز هویت منقضی گردیده‌اند.</target>
</trans-unit>
<trans-unit id="15">
<source>Account is disabled.</source>
<target>حساب کاربری غیرفعال است.</target>
<target>حساب کاربری غیرفعال می باشد.</target>
</trans-unit>
<trans-unit id="16">
<source>Account is locked.</source>
<target>حساب کاربری قفل شده است.</target>
<target>حساب کاربری قفل گردیده است.</target>
</trans-unit>
</body>
</file>

View File

@ -89,13 +89,6 @@ class GuardAuthenticatorHandlerTest extends TestCase
*/
public function testHandleAuthenticationClearsToken($tokenClass, $tokenProviderKey, $actualProviderKey)
{
$token = $this->getMockBuilder($tokenClass)
->disableOriginalConstructor()
->getMock();
$token->expects($this->any())
->method('getProviderKey')
->willReturn($tokenProviderKey);
$this->tokenStorage->expects($this->never())
->method('setToken')
->with(null);

View File

@ -75,8 +75,6 @@ class BasicAuthenticationListenerTest extends TestCase
'PHP_AUTH_PW' => 'ThePassword',
]);
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$tokenStorage = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface')->getMock();
$tokenStorage
->expects($this->any())

View File

@ -124,7 +124,6 @@ class AbstractRememberMeServicesTest extends TestCase
$service = $this->getService(null, ['name' => 'foo', 'always_remember_me' => true, 'path' => null, 'domain' => null]);
$request = new Request();
$response = new Response();
$account = $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
$token = $this->getMockBuilder('Symfony\Component\Security\Core\Authentication\Token\TokenInterface')->getMock();
$token
->expects($this->once())

View File

@ -250,6 +250,8 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface
return $normalizer;
}
}
return null;
}
/**
@ -291,6 +293,8 @@ class Serializer implements SerializerInterface, ContextAwareNormalizerInterface
return $normalizer;
}
}
return null;
}
/**

View File

@ -87,7 +87,7 @@ class StopwatchTest extends TestCase
$event = $stopwatch->stop('foo');
$this->assertInstanceOf('Symfony\Component\Stopwatch\StopwatchEvent', $event);
$this->assertEquals(200, $event->getDuration(), '', self::DELTA);
$this->assertEqualsWithDelta(200, $event->getDuration(), self::DELTA);
}
public function testUnknownEvent()

View File

@ -41,6 +41,10 @@ class CsvFileLoader extends FileLoader
$file->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
foreach ($file as $data) {
if (false === $data) {
continue;
}
if ('#' !== substr($data[0], 0, 1) && isset($data[1]) && 2 === \count($data)) {
$messages[$data[0]] = $data[1];
}

View File

@ -37,7 +37,7 @@ class XliffLintCommandTest extends TestCase
);
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('OK', trim($tester->getDisplay()));
$this->assertStringContainsString('OK', trim($tester->getDisplay()));
}
public function testLintCorrectFiles()
@ -52,7 +52,7 @@ class XliffLintCommandTest extends TestCase
);
$this->assertEquals(0, $tester->getStatusCode(), 'Returns 0 in case of success');
$this->assertContains('OK', trim($tester->getDisplay()));
$this->assertStringContainsString('OK', trim($tester->getDisplay()));
}
/**
@ -69,7 +69,7 @@ class XliffLintCommandTest extends TestCase
);
$this->assertEquals($mustFail ? 1 : 0, $tester->getStatusCode());
$this->assertContains($mustFail ? '[WARNING] 0 XLIFF files have valid syntax and 1 contain errors.' : '[OK] All 1 XLIFF files contain valid syntax.', $tester->getDisplay());
$this->assertStringContainsString($mustFail ? '[WARNING] 0 XLIFF files have valid syntax and 1 contain errors.' : '[OK] All 1 XLIFF files contain valid syntax.', $tester->getDisplay());
}
public function testLintIncorrectXmlSyntax()
@ -80,7 +80,7 @@ class XliffLintCommandTest extends TestCase
$tester->execute(['filename' => $filename], ['decorated' => false]);
$this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error');
$this->assertContains('Opening and ending tag mismatch: target line 6 and source', trim($tester->getDisplay()));
$this->assertStringContainsString('Opening and ending tag mismatch: target line 6 and source', trim($tester->getDisplay()));
}
public function testLintIncorrectTargetLanguage()
@ -91,7 +91,7 @@ class XliffLintCommandTest extends TestCase
$tester->execute(['filename' => $filename], ['decorated' => false]);
$this->assertEquals(1, $tester->getStatusCode(), 'Returns 1 in case of error');
$this->assertContains('There is a mismatch between the language included in the file name ("messages.en.xlf") and the "es" value used in the "target-language" attribute of the file.', trim($tester->getDisplay()));
$this->assertStringContainsString('There is a mismatch between the language included in the file name ("messages.en.xlf") and the "es" value used in the "target-language" attribute of the file.', trim($tester->getDisplay()));
}
public function testLintTargetLanguageIsCaseInsensitive()
@ -102,7 +102,7 @@ class XliffLintCommandTest extends TestCase
$tester->execute(['filename' => $filename], ['decorated' => false]);
$this->assertEquals(0, $tester->getStatusCode());
$this->assertContains('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay()));
$this->assertStringContainsString('[OK] All 1 XLIFF files contain valid syntax.', trim($tester->getDisplay()));
}
public function testLintFileNotReadable()

View File

@ -50,14 +50,11 @@ class TranslationExtractorPassTest extends TestCase
{
$this->expectException('Symfony\Component\DependencyInjection\Exception\RuntimeException');
$this->expectExceptionMessage('The alias for the tag "translation.extractor" of service "foo.id" must be set.');
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->disableOriginalConstructor()->getMock();
$container = new ContainerBuilder();
$container->register('translation.extractor');
$container->register('foo.id')
->addTag('translation.extractor', []);
$definition->expects($this->never())->method('addMethodCall');
$translationDumperPass = new TranslationExtractorPass();
$translationDumperPass->process($container);
}

View File

@ -16,6 +16,22 @@ use Symfony\Contracts\Translation\Test\TranslatorTest;
class IdentityTranslatorTest extends TranslatorTest
{
private $defaultLocale;
protected function setUp()
{
parent::setUp();
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
public function getTranslator()
{
return new IdentityTranslator();

View File

@ -18,6 +18,22 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class CountryValidatorTest extends ConstraintValidatorTestCase
{
private $defaultLocale;
protected function setUp()
{
parent::setUp();
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
protected function createValidator()
{
return new CountryValidator();

View File

@ -18,6 +18,22 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class CurrencyValidatorTest extends ConstraintValidatorTestCase
{
private $defaultLocale;
protected function setUp()
{
parent::setUp();
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
protected function createValidator()
{
return new CurrencyValidator();

View File

@ -18,6 +18,22 @@ use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
class LanguageValidatorTest extends ConstraintValidatorTestCase
{
private $defaultLocale;
protected function setUp()
{
parent::setUp();
$this->defaultLocale = \Locale::getDefault();
}
protected function tearDown()
{
parent::tearDown();
\Locale::setDefault($this->defaultLocale);
}
protected function createValidator()
{
return new LanguageValidator();

View File

@ -50,7 +50,7 @@ class RangeValidatorTest extends ConstraintValidatorTestCase
[9.99999, '9.99999'],
['9.99999', '"9.99999"'],
[5, '5'],
[1.0, '1.0'],
[1.0, '1'],
];
}
@ -60,7 +60,7 @@ class RangeValidatorTest extends ConstraintValidatorTestCase
[20.000001, '20.000001'],
['20.000001', '"20.000001"'],
[21, '21'],
[30.0, '30.0'],
[30.0, '30'],
];
}

View File

@ -52,7 +52,6 @@ Exception {
}
}
%s%eTests%eCaster%eExceptionCasterTest.php:40 { }
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testDefaultSettings() {}
%A
EODUMP;
@ -71,8 +70,7 @@ EODUMP;
return new \Exception(''.$msg);
}
}
%s%eTests%eCaster%eExceptionCasterTest.php:65 { }
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testSeek() {}
%s%eTests%eCaster%eExceptionCasterTest.php:64 { }
%A
EODUMP;
@ -96,8 +94,7 @@ Exception {
return new \Exception(''.$msg);
}
}
%s%eTests%eCaster%eExceptionCasterTest.php:84 { }
Symfony\Component\VarDumper\Tests\Caster\ExceptionCasterTest->testNoArgs() {}
%s%eTests%eCaster%eExceptionCasterTest.php:82 { }
%A
EODUMP;

View File

@ -446,7 +446,7 @@ abstract class HttpClientTestCase extends TestCase
$body = $response->toArray();
$this->assertContains('json', $body['content-type']);
$this->assertStringContainsString('json', $body['content-type']);
unset($body['content-type']);
$this->assertSame(['foo' => 'bar', 'REQUEST_METHOD' => 'POST'], $body);
}
@ -705,11 +705,11 @@ abstract class HttpClientTestCase extends TestCase
$headers = $response->getHeaders();
$this->assertSame(['Accept-Encoding'], $headers['vary']);
$this->assertContains('gzip', $headers['content-encoding'][0]);
$this->assertStringContainsString('gzip', $headers['content-encoding'][0]);
$body = $response->toArray();
$this->assertContains('gzip', $body['HTTP_ACCEPT_ENCODING']);
$this->assertStringContainsString('gzip', $body['HTTP_ACCEPT_ENCODING']);
}
public function testBaseUri()
@ -757,7 +757,7 @@ abstract class HttpClientTestCase extends TestCase
$headers = $response->getHeaders();
$this->assertSame(['Accept-Encoding'], $headers['vary']);
$this->assertContains('gzip', $headers['content-encoding'][0]);
$this->assertStringContainsString('gzip', $headers['content-encoding'][0]);
$body = $response->getContent();
$this->assertSame("\x1F", $body[0]);