Merge branch '4.4'
* 4.4: Minor fixes [Mailer] fixed dispatcher not available in Mailer [HttpClient] Minor fixes Use namespaced Phpunit classes Add polyfill for PhpUnit namespace [Messenger] Fixed ConsumeMessagesCommand configuration [Form] remove leftover int child phpdoc Support DateTimeInterface in IntlDateFormatter::format [PhpUnitBridge] fixed PHPUnit 8.3 compatibility: method handleError was renamed to __invoke [Yaml] Removed unused $nullAsTilde property [Security] add support for opportunistic password migrations [Lock] Legacy test should implement legacy interface fixed phpdocs Use PHPunit assertion [Intl] Order alpha2 to alpha3 mapping + phpdoc fixes
This commit is contained in:
commit
f4ca628fb3
@ -9,7 +9,7 @@ return PhpCsFixer\Config::create()
|
|||||||
'@Symfony' => true,
|
'@Symfony' => true,
|
||||||
'@Symfony:risky' => true,
|
'@Symfony:risky' => true,
|
||||||
'@PHPUnit75Migration:risky' => true,
|
'@PHPUnit75Migration:risky' => true,
|
||||||
'php_unit_dedicate_assert' => ['target' => '3.5'],
|
'php_unit_dedicate_assert' => ['target' => '5.6'],
|
||||||
'phpdoc_no_empty_return' => false, // triggers almost always false positive
|
'phpdoc_no_empty_return' => false, // triggers almost always false positive
|
||||||
'array_syntax' => ['syntax' => 'short'],
|
'array_syntax' => ['syntax' => 'short'],
|
||||||
'fopen_flags' => false,
|
'fopen_flags' => false,
|
||||||
|
@ -196,6 +196,7 @@ install:
|
|||||||
git checkout -q FETCH_HEAD -- src/Symfony/Bridge/PhpUnit
|
git checkout -q FETCH_HEAD -- src/Symfony/Bridge/PhpUnit
|
||||||
SYMFONY_VERSION=$(cat src/Symfony/Bridge/PhpUnit/composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
|
SYMFONY_VERSION=$(cat src/Symfony/Bridge/PhpUnit/composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*')
|
||||||
sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_VERSION'.x@dev"/' composer.json
|
sed -i 's/"symfony\/phpunit-bridge": ".*"/"symfony\/phpunit-bridge": "'$SYMFONY_VERSION'.x@dev"/' composer.json
|
||||||
|
rm -rf .phpunit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- |
|
- |
|
||||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Doctrine\Security\User;
|
|||||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
use Doctrine\Common\Persistence\ManagerRegistry;
|
||||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
|
|||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||||
*/
|
*/
|
||||||
class EntityUserProvider implements UserProviderInterface
|
class EntityUserProvider implements UserProviderInterface, PasswordUpgraderInterface
|
||||||
{
|
{
|
||||||
private $registry;
|
private $registry;
|
||||||
private $managerName;
|
private $managerName;
|
||||||
@ -107,6 +108,22 @@ class EntityUserProvider implements UserProviderInterface
|
|||||||
return $class === $this->getClass() || is_subclass_of($class, $this->getClass());
|
return $class === $this->getClass() || is_subclass_of($class, $this->getClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
|
||||||
|
{
|
||||||
|
$class = $this->getClass();
|
||||||
|
if (!$user instanceof $class) {
|
||||||
|
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$repository = $this->getRepository();
|
||||||
|
if ($repository instanceof PasswordUpgraderInterface) {
|
||||||
|
$repository->upgradePassword($user, $newEncodedPassword);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function getObjectManager()
|
private function getObjectManager()
|
||||||
{
|
{
|
||||||
return $this->registry->getManager($this->managerName);
|
return $this->registry->getManager($this->managerName);
|
||||||
|
@ -17,6 +17,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
|
use Symfony\Bridge\Doctrine\Security\User\EntityUserProvider;
|
||||||
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
|
||||||
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
|
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
|
|
||||||
class EntityUserProviderTest extends TestCase
|
class EntityUserProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -176,6 +177,23 @@ class EntityUserProviderTest extends TestCase
|
|||||||
$provider->loadUserByUsername('name');
|
$provider->loadUserByUsername('name');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPasswordUpgrades()
|
||||||
|
{
|
||||||
|
$user = new User(1, 1, 'user1');
|
||||||
|
|
||||||
|
$repository = $this->getMockBuilder(PasswordUpgraderInterface::class)->getMock();
|
||||||
|
$repository->expects($this->once())
|
||||||
|
->method('upgradePassword')
|
||||||
|
->with($user, 'foobar');
|
||||||
|
|
||||||
|
$provider = new EntityUserProvider(
|
||||||
|
$this->getManager($this->getObjectManager($repository)),
|
||||||
|
'Symfony\Bridge\Doctrine\Tests\Fixtures\User'
|
||||||
|
);
|
||||||
|
|
||||||
|
$provider->upgradePassword($user, 'foobar');
|
||||||
|
}
|
||||||
|
|
||||||
private function getManager($em, $name = null)
|
private function getManager($em, $name = null)
|
||||||
{
|
{
|
||||||
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
$manager = $this->getMockBuilder('Doctrine\Common\Persistence\ManagerRegistry')->getMock();
|
||||||
|
@ -11,6 +11,7 @@ CHANGELOG
|
|||||||
|
|
||||||
* made the bridge act as a polyfill for newest PHPUnit features
|
* made the bridge act as a polyfill for newest PHPUnit features
|
||||||
* added `SetUpTearDownTrait` to allow working around the `void` return-type added by PHPUnit 8
|
* added `SetUpTearDownTrait` to allow working around the `void` return-type added by PHPUnit 8
|
||||||
|
* added namespace aliases for PHPUnit < 6
|
||||||
|
|
||||||
4.3.0
|
4.3.0
|
||||||
-----
|
-----
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit;
|
namespace Symfony\Bridge\PhpUnit;
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
|
if (version_compare(\PHPUnit\Runner\Version::id(), '6.0.0', '<')) {
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV5', 'Symfony\Bridge\PhpUnit\CoverageListener');
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV5', 'Symfony\Bridge\PhpUnit\CoverageListener');
|
||||||
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
|
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV6', 'Symfony\Bridge\PhpUnit\CoverageListener');
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\CoverageListenerForV6', 'Symfony\Bridge\PhpUnit\CoverageListener');
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit;
|
namespace Symfony\Bridge\PhpUnit;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestResult;
|
||||||
|
use PHPUnit\Util\ErrorHandler;
|
||||||
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration;
|
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Configuration;
|
||||||
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
|
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler\Deprecation;
|
||||||
|
|
||||||
@ -43,7 +45,7 @@ class DeprecationErrorHandler
|
|||||||
];
|
];
|
||||||
|
|
||||||
private static $isRegistered = false;
|
private static $isRegistered = false;
|
||||||
private static $utilPrefix;
|
private static $isAtLeastPhpUnit83;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers and configures the deprecation handler.
|
* Registers and configures the deprecation handler.
|
||||||
@ -67,7 +69,7 @@ class DeprecationErrorHandler
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$utilPrefix = class_exists('PHPUnit_Util_ErrorHandler') ? 'PHPUnit_Util_' : 'PHPUnit\Util\\';
|
self::$isAtLeastPhpUnit83 = !class_exists('PHPUnit_Util_ErrorHandler') && method_exists(ErrorHandler::class, '__invoke');
|
||||||
|
|
||||||
$handler = new self();
|
$handler = new self();
|
||||||
$oldErrorHandler = set_error_handler([$handler, 'handleError']);
|
$oldErrorHandler = set_error_handler([$handler, 'handleError']);
|
||||||
@ -75,7 +77,7 @@ class DeprecationErrorHandler
|
|||||||
if (null !== $oldErrorHandler) {
|
if (null !== $oldErrorHandler) {
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
|
|
||||||
if ([self::$utilPrefix.'ErrorHandler', 'handleError'] === $oldErrorHandler) {
|
if ($oldErrorHandler instanceof ErrorHandler || [ErrorHandler::class, 'handleError'] === $oldErrorHandler) {
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
self::register($mode);
|
self::register($mode);
|
||||||
}
|
}
|
||||||
@ -95,12 +97,7 @@ class DeprecationErrorHandler
|
|||||||
return $previousErrorHandler($type, $msg, $file, $line, $context);
|
return $previousErrorHandler($type, $msg, $file, $line, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static $autoload = true;
|
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
|
||||||
|
|
||||||
$ErrorHandler = class_exists('PHPUnit_Util_ErrorHandler', $autoload) ? 'PHPUnit_Util_ErrorHandler' : 'PHPUnit\Util\ErrorHandler';
|
|
||||||
$autoload = false;
|
|
||||||
|
|
||||||
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$deprecations[] = [error_reporting(), $msg, $file];
|
$deprecations[] = [error_reporting(), $msg, $file];
|
||||||
@ -117,9 +114,7 @@ class DeprecationErrorHandler
|
|||||||
public function handleError($type, $msg, $file, $line, $context = [])
|
public function handleError($type, $msg, $file, $line, $context = [])
|
||||||
{
|
{
|
||||||
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || !$this->getConfiguration()->isEnabled()) {
|
if ((E_USER_DEPRECATED !== $type && E_DEPRECATED !== $type) || !$this->getConfiguration()->isEnabled()) {
|
||||||
$ErrorHandler = self::$utilPrefix.'ErrorHandler';
|
return \call_user_func(self::getPhpUnitErrorHandler(), $type, $msg, $file, $line, $context);
|
||||||
|
|
||||||
return $ErrorHandler::handleError($type, $msg, $file, $line, $context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$deprecation = new Deprecation($msg, debug_backtrace(), $file);
|
$deprecation = new Deprecation($msg, debug_backtrace(), $file);
|
||||||
@ -135,7 +130,7 @@ class DeprecationErrorHandler
|
|||||||
|
|
||||||
if (0 !== error_reporting()) {
|
if (0 !== error_reporting()) {
|
||||||
$group = 'unsilenced';
|
$group = 'unsilenced';
|
||||||
} elseif ($deprecation->isLegacy(self::$utilPrefix)) {
|
} elseif ($deprecation->isLegacy()) {
|
||||||
$group = 'legacy';
|
$group = 'legacy';
|
||||||
} else {
|
} else {
|
||||||
$group = [
|
$group = [
|
||||||
@ -307,6 +302,26 @@ class DeprecationErrorHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function getPhpUnitErrorHandler()
|
||||||
|
{
|
||||||
|
if (!self::$isAtLeastPhpUnit83) {
|
||||||
|
return 'PHPUnit\Util\ErrorHandler::handleError';
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT | DEBUG_BACKTRACE_IGNORE_ARGS) as $frame) {
|
||||||
|
if (isset($frame['object']) && $frame['object'] instanceof TestResult) {
|
||||||
|
return new ErrorHandler(
|
||||||
|
$frame['object']->getConvertDeprecationsToExceptions(),
|
||||||
|
$frame['object']->getConvertErrorsToExceptions(),
|
||||||
|
$frame['object']->getConvertNoticesToExceptions(),
|
||||||
|
$frame['object']->getConvertWarningsToExceptions()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return function () { return false; };
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if STDOUT is defined and supports colorization.
|
* Returns true if STDOUT is defined and supports colorization.
|
||||||
*
|
*
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
|
namespace Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
|
||||||
|
|
||||||
|
use PHPUnit\Util\Test;
|
||||||
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor;
|
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -156,9 +157,8 @@ class Deprecation
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isLegacy($utilPrefix)
|
public function isLegacy()
|
||||||
{
|
{
|
||||||
$test = $utilPrefix.'Test';
|
|
||||||
$class = $this->originatingClass();
|
$class = $this->originatingClass();
|
||||||
$method = $this->originatingMethod();
|
$method = $this->originatingMethod();
|
||||||
|
|
||||||
@ -166,7 +166,7 @@ class Deprecation
|
|||||||
|| 0 === strpos($method, 'provideLegacy')
|
|| 0 === strpos($method, 'provideLegacy')
|
||||||
|| 0 === strpos($method, 'getLegacy')
|
|| 0 === strpos($method, 'getLegacy')
|
||||||
|| strpos($class, '\Legacy')
|
|| strpos($class, '\Legacy')
|
||||||
|| \in_array('legacy', $test::getGroups($class, $method), true);
|
|| \in_array('legacy', Test::getGroups($class, $method), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -13,6 +13,7 @@ namespace Symfony\Bridge\PhpUnit\Legacy;
|
|||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use PHPUnit\Framework\Warning;
|
use PHPUnit\Framework\Warning;
|
||||||
|
use PHPUnit\Util\Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP 5.3 compatible trait-like shared implementation.
|
* PHP 5.3 compatible trait-like shared implementation.
|
||||||
@ -65,12 +66,7 @@ class CoverageListenerTrait
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$testClass = \PHPUnit\Util\Test::class;
|
$r = new \ReflectionProperty(Test::class, 'annotationCache');
|
||||||
if (!class_exists($testClass, false)) {
|
|
||||||
$testClass = \PHPUnit_Util_Test::class;
|
|
||||||
}
|
|
||||||
|
|
||||||
$r = new \ReflectionProperty($testClass, 'annotationCache');
|
|
||||||
$r->setAccessible(true);
|
$r->setAccessible(true);
|
||||||
|
|
||||||
$cache = $r->getValue();
|
$cache = $r->getValue();
|
||||||
@ -79,7 +75,7 @@ class CoverageListenerTrait
|
|||||||
'covers' => \is_array($sutFqcn) ? $sutFqcn : array($sutFqcn),
|
'covers' => \is_array($sutFqcn) ? $sutFqcn : array($sutFqcn),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
$r->setValue($testClass, $cache);
|
$r->setValue(Test::class, $cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findSutFqcn($test)
|
private function findSutFqcn($test)
|
||||||
|
@ -15,7 +15,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This trait is @internal
|
* This trait is @internal.
|
||||||
*/
|
*/
|
||||||
trait PolyfillTestCaseTrait
|
trait PolyfillTestCaseTrait
|
||||||
{
|
{
|
||||||
@ -66,7 +66,7 @@ trait PolyfillTestCaseTrait
|
|||||||
*/
|
*/
|
||||||
public function expectException($exception)
|
public function expectException($exception)
|
||||||
{
|
{
|
||||||
$property = new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ? 'PHPUnit_Framework_TestCase' : TestCase::class, 'expectedException');
|
$property = new \ReflectionProperty(TestCase::class, 'expectedException');
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
$property->setValue($this, $exception);
|
$property->setValue($this, $exception);
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ trait PolyfillTestCaseTrait
|
|||||||
*/
|
*/
|
||||||
public function expectExceptionCode($code)
|
public function expectExceptionCode($code)
|
||||||
{
|
{
|
||||||
$property = new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ? 'PHPUnit_Framework_TestCase' : TestCase::class, 'expectedExceptionCode');
|
$property = new \ReflectionProperty(TestCase::class, 'expectedExceptionCode');
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
$property->setValue($this, $code);
|
$property->setValue($this, $code);
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ trait PolyfillTestCaseTrait
|
|||||||
*/
|
*/
|
||||||
public function expectExceptionMessage($message)
|
public function expectExceptionMessage($message)
|
||||||
{
|
{
|
||||||
$property = new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ? 'PHPUnit_Framework_TestCase' : TestCase::class, 'expectedExceptionMessage');
|
$property = new \ReflectionProperty(TestCase::class, 'expectedExceptionMessage');
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
$property->setValue($this, $message);
|
$property->setValue($this, $message);
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ trait PolyfillTestCaseTrait
|
|||||||
*/
|
*/
|
||||||
public function expectExceptionMessageRegExp($messageRegExp)
|
public function expectExceptionMessageRegExp($messageRegExp)
|
||||||
{
|
{
|
||||||
$property = new \ReflectionProperty(class_exists('PHPUnit_Framework_TestCase') ? 'PHPUnit_Framework_TestCase' : TestCase::class, 'expectedExceptionMessageRegExp');
|
$property = new \ReflectionProperty(TestCase::class, 'expectedExceptionMessageRegExp');
|
||||||
$property->setAccessible(true);
|
$property->setAccessible(true);
|
||||||
$property->setValue($this, $messageRegExp);
|
$property->setValue($this, $messageRegExp);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,9 @@ use Doctrine\Common\Annotations\AnnotationRegistry;
|
|||||||
use PHPUnit\Framework\AssertionFailedError;
|
use PHPUnit\Framework\AssertionFailedError;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use PHPUnit\Framework\TestSuite;
|
use PHPUnit\Framework\TestSuite;
|
||||||
|
use PHPUnit\Runner\BaseTestRunner;
|
||||||
use PHPUnit\Util\Blacklist;
|
use PHPUnit\Util\Blacklist;
|
||||||
|
use PHPUnit\Util\Test;
|
||||||
use Symfony\Bridge\PhpUnit\ClockMock;
|
use Symfony\Bridge\PhpUnit\ClockMock;
|
||||||
use Symfony\Bridge\PhpUnit\DnsMock;
|
use Symfony\Bridge\PhpUnit\DnsMock;
|
||||||
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
|
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
|
||||||
@ -48,11 +50,7 @@ class SymfonyTestsListenerTrait
|
|||||||
*/
|
*/
|
||||||
public function __construct(array $mockedNamespaces = array())
|
public function __construct(array $mockedNamespaces = array())
|
||||||
{
|
{
|
||||||
if (class_exists('PHPUnit_Util_Blacklist')) {
|
|
||||||
\PHPUnit_Util_Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
|
|
||||||
} else {
|
|
||||||
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
|
Blacklist::$blacklistedClassNames['\Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait'] = 2;
|
||||||
}
|
|
||||||
|
|
||||||
$enableDebugClassLoader = class_exists(DebugClassLoader::class) || class_exists(LegacyDebugClassLoader::class);
|
$enableDebugClassLoader = class_exists(DebugClassLoader::class) || class_exists(LegacyDebugClassLoader::class);
|
||||||
|
|
||||||
@ -113,11 +111,6 @@ class SymfonyTestsListenerTrait
|
|||||||
|
|
||||||
public function startTestSuite($suite)
|
public function startTestSuite($suite)
|
||||||
{
|
{
|
||||||
if (class_exists('PHPUnit_Util_Blacklist', false)) {
|
|
||||||
$Test = 'PHPUnit_Util_Test';
|
|
||||||
} else {
|
|
||||||
$Test = 'PHPUnit\Util\Test';
|
|
||||||
}
|
|
||||||
$suiteName = $suite->getName();
|
$suiteName = $suite->getName();
|
||||||
$this->testsWithWarnings = array();
|
$this->testsWithWarnings = array();
|
||||||
|
|
||||||
@ -125,7 +118,7 @@ class SymfonyTestsListenerTrait
|
|||||||
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
|
if (!($test instanceof \PHPUnit\Framework\TestCase || $test instanceof TestCase)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (null === $Test::getPreserveGlobalStateSettings(\get_class($test), $test->getName(false))) {
|
if (null === Test::getPreserveGlobalStateSettings(\get_class($test), $test->getName(false))) {
|
||||||
$test->setPreserveGlobalState(false);
|
$test->setPreserveGlobalState(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,12 +150,12 @@ class SymfonyTestsListenerTrait
|
|||||||
$testSuites = array($suite);
|
$testSuites = array($suite);
|
||||||
for ($i = 0; isset($testSuites[$i]); ++$i) {
|
for ($i = 0; isset($testSuites[$i]); ++$i) {
|
||||||
foreach ($testSuites[$i]->tests() as $test) {
|
foreach ($testSuites[$i]->tests() as $test) {
|
||||||
if ($test instanceof \PHPUnit_Framework_TestSuite || $test instanceof TestSuite) {
|
if ($test instanceof TestSuite) {
|
||||||
if (!class_exists($test->getName(), false)) {
|
if (!class_exists($test->getName(), false)) {
|
||||||
$testSuites[] = $test;
|
$testSuites[] = $test;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$groups = $Test::getGroups($test->getName());
|
$groups = Test::getGroups($test->getName());
|
||||||
if (\in_array('time-sensitive', $groups, true)) {
|
if (\in_array('time-sensitive', $groups, true)) {
|
||||||
ClockMock::register($test->getName());
|
ClockMock::register($test->getName());
|
||||||
}
|
}
|
||||||
@ -213,14 +206,7 @@ class SymfonyTestsListenerTrait
|
|||||||
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$this->runsInSeparateProcess);
|
putenv('SYMFONY_DEPRECATIONS_SERIALIZE='.$this->runsInSeparateProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Util_Blacklist', false)) {
|
$groups = Test::getGroups(\get_class($test), $test->getName(false));
|
||||||
$Test = 'PHPUnit_Util_Test';
|
|
||||||
$AssertionFailedError = 'PHPUnit_Framework_AssertionFailedError';
|
|
||||||
} else {
|
|
||||||
$Test = 'PHPUnit\Util\Test';
|
|
||||||
$AssertionFailedError = 'PHPUnit\Framework\AssertionFailedError';
|
|
||||||
}
|
|
||||||
$groups = $Test::getGroups(\get_class($test), $test->getName(false));
|
|
||||||
|
|
||||||
if (!$this->runsInSeparateProcess) {
|
if (!$this->runsInSeparateProcess) {
|
||||||
if (\in_array('time-sensitive', $groups, true)) {
|
if (\in_array('time-sensitive', $groups, true)) {
|
||||||
@ -232,14 +218,14 @@ class SymfonyTestsListenerTrait
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$annotations = $Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false));
|
$annotations = Test::parseTestMethodAnnotations(\get_class($test), $test->getName(false));
|
||||||
|
|
||||||
if (isset($annotations['class']['expectedDeprecation'])) {
|
if (isset($annotations['class']['expectedDeprecation'])) {
|
||||||
$test->getTestResultObject()->addError($test, new $AssertionFailedError('`@expectedDeprecation` annotations are not allowed at the class level.'), 0);
|
$test->getTestResultObject()->addError($test, new AssertionFailedError('`@expectedDeprecation` annotations are not allowed at the class level.'), 0);
|
||||||
}
|
}
|
||||||
if (isset($annotations['method']['expectedDeprecation'])) {
|
if (isset($annotations['method']['expectedDeprecation'])) {
|
||||||
if (!\in_array('legacy', $groups, true)) {
|
if (!\in_array('legacy', $groups, true)) {
|
||||||
$this->error = new $AssertionFailedError('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`.');
|
$this->error = new AssertionFailedError('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
|
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything(false);
|
||||||
@ -259,18 +245,8 @@ class SymfonyTestsListenerTrait
|
|||||||
|
|
||||||
public function endTest($test, $time)
|
public function endTest($test, $time)
|
||||||
{
|
{
|
||||||
if (class_exists('PHPUnit_Util_Blacklist', false)) {
|
|
||||||
$Test = 'PHPUnit_Util_Test';
|
|
||||||
$BaseTestRunner = 'PHPUnit_Runner_BaseTestRunner';
|
|
||||||
$Warning = 'PHPUnit_Framework_Warning';
|
|
||||||
} else {
|
|
||||||
$Test = 'PHPUnit\Util\Test';
|
|
||||||
$BaseTestRunner = 'PHPUnit\Runner\BaseTestRunner';
|
|
||||||
$Warning = 'PHPUnit\Framework\Warning';
|
|
||||||
}
|
|
||||||
$className = \get_class($test);
|
$className = \get_class($test);
|
||||||
$classGroups = $Test::getGroups($className);
|
$groups = Test::getGroups($className, $test->getName(false));
|
||||||
$groups = $Test::getGroups($className, $test->getName(false));
|
|
||||||
|
|
||||||
if (null !== $this->reportUselessTests) {
|
if (null !== $this->reportUselessTests) {
|
||||||
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything($this->reportUselessTests);
|
$test->getTestResultObject()->beStrictAboutTestsThatDoNotTestAnything($this->reportUselessTests);
|
||||||
@ -299,20 +275,18 @@ class SymfonyTestsListenerTrait
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->expectedDeprecations) {
|
if ($this->expectedDeprecations) {
|
||||||
if (!\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE), true)) {
|
if (!\in_array($test->getStatus(), array(BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE), true)) {
|
||||||
$test->addToAssertionCount(\count($this->expectedDeprecations));
|
$test->addToAssertionCount(\count($this->expectedDeprecations));
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_error_handler();
|
restore_error_handler();
|
||||||
|
|
||||||
if (!$errored && !\in_array($test->getStatus(), array($BaseTestRunner::STATUS_SKIPPED, $BaseTestRunner::STATUS_INCOMPLETE, $BaseTestRunner::STATUS_FAILURE, $BaseTestRunner::STATUS_ERROR), true)) {
|
if (!$errored && !\in_array($test->getStatus(), array(BaseTestRunner::STATUS_SKIPPED, BaseTestRunner::STATUS_INCOMPLETE, BaseTestRunner::STATUS_FAILURE, BaseTestRunner::STATUS_ERROR), true)) {
|
||||||
try {
|
try {
|
||||||
$prefix = "@expectedDeprecation:\n";
|
$prefix = "@expectedDeprecation:\n";
|
||||||
$test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n");
|
$test->assertStringMatchesFormat($prefix.'%A '.implode("\n%A ", $this->expectedDeprecations)."\n%A", $prefix.' '.implode("\n ", $this->gatheredDeprecations)."\n");
|
||||||
} catch (AssertionFailedError $e) {
|
} catch (AssertionFailedError $e) {
|
||||||
$test->getTestResultObject()->addFailure($test, $e, $time);
|
$test->getTestResultObject()->addFailure($test, $e, $time);
|
||||||
} catch (\PHPUnit_Framework_AssertionFailedError $e) {
|
|
||||||
$test->getTestResultObject()->addFailure($test, $e, $time);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit;
|
namespace Symfony\Bridge\PhpUnit;
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
|
if (version_compare(\PHPUnit\Runner\Version::id(), '6.0.0', '<')) {
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV5', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
|
||||||
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
|
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV6', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerForV6', 'Symfony\Bridge\PhpUnit\SymfonyTestsListener');
|
||||||
|
@ -14,7 +14,7 @@ require __DIR__.'/../src/FooCov.php';
|
|||||||
|
|
||||||
require __DIR__.'/../../../../Legacy/CoverageListenerTrait.php';
|
require __DIR__.'/../../../../Legacy/CoverageListenerTrait.php';
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
|
if (version_compare(\PHPUnit\Runner\Version::id(), '6.0.0', '<')) {
|
||||||
require_once __DIR__.'/../../../../Legacy/CoverageListenerForV5.php';
|
require_once __DIR__.'/../../../../Legacy/CoverageListenerForV5.php';
|
||||||
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
|
} elseif (version_compare(\PHPUnit\Runner\Version::id(), '7.0.0', '<')) {
|
||||||
require_once __DIR__.'/../../../../Legacy/CoverageListenerForV6.php';
|
require_once __DIR__.'/../../../../Legacy/CoverageListenerForV6.php';
|
||||||
|
@ -24,8 +24,7 @@ class ProcessIsolationTest extends TestCase
|
|||||||
|
|
||||||
public function testCallingOtherErrorHandler()
|
public function testCallingOtherErrorHandler()
|
||||||
{
|
{
|
||||||
$class = class_exists('PHPUnit\Framework\Exception') ? 'PHPUnit\Framework\Exception' : 'PHPUnit_Framework_Exception';
|
$this->expectException('PHPUnit\Framework\Exception');
|
||||||
$this->expectException($class);
|
|
||||||
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
|
$this->expectExceptionMessage('Test that PHPUnit\'s error handler fires.');
|
||||||
|
|
||||||
trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING);
|
trigger_error('Test that PHPUnit\'s error handler fires.', E_USER_WARNING);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Bridge\PhpUnit\TextUI;
|
namespace Symfony\Bridge\PhpUnit\TextUI;
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
|
if (version_compare(\PHPUnit\Runner\Version::id(), '6.0.0', '<')) {
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV5', 'Symfony\Bridge\PhpUnit\TextUI\Command');
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV5', 'Symfony\Bridge\PhpUnit\TextUI\Command');
|
||||||
} else {
|
} else {
|
||||||
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV6', 'Symfony\Bridge\PhpUnit\TextUI\Command');
|
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV6', 'Symfony\Bridge\PhpUnit\TextUI\Command');
|
||||||
|
@ -12,6 +12,95 @@
|
|||||||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||||
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
|
use Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
|
||||||
|
|
||||||
|
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
|
||||||
|
$classes = [
|
||||||
|
'PHPUnit_Framework_Assert', // override PhpUnit's ForwardCompat child class
|
||||||
|
'PHPUnit_Framework_AssertionFailedError', // override PhpUnit's ForwardCompat child class
|
||||||
|
'PHPUnit_Framework_BaseTestListener', // override PhpUnit's ForwardCompat child class
|
||||||
|
|
||||||
|
'PHPUnit_Framework_Constraint',
|
||||||
|
'PHPUnit_Framework_Constraint_And',
|
||||||
|
'PHPUnit_Framework_Constraint_ArrayHasKey',
|
||||||
|
'PHPUnit_Framework_Constraint_ArraySubset',
|
||||||
|
'PHPUnit_Framework_Constraint_Attribute',
|
||||||
|
'PHPUnit_Framework_Constraint_Callback',
|
||||||
|
'PHPUnit_Framework_Constraint_ClassHasAttribute',
|
||||||
|
'PHPUnit_Framework_Constraint_ClassHasStaticAttribute',
|
||||||
|
'PHPUnit_Framework_Constraint_Composite',
|
||||||
|
'PHPUnit_Framework_Constraint_Count',
|
||||||
|
'PHPUnit_Framework_Constraint_Exception',
|
||||||
|
'PHPUnit_Framework_Constraint_ExceptionCode',
|
||||||
|
'PHPUnit_Framework_Constraint_ExceptionMessage',
|
||||||
|
'PHPUnit_Framework_Constraint_ExceptionMessageRegExp',
|
||||||
|
'PHPUnit_Framework_Constraint_FileExists',
|
||||||
|
'PHPUnit_Framework_Constraint_GreaterThan',
|
||||||
|
'PHPUnit_Framework_Constraint_IsAnything',
|
||||||
|
'PHPUnit_Framework_Constraint_IsEmpty',
|
||||||
|
'PHPUnit_Framework_Constraint_IsEqual',
|
||||||
|
'PHPUnit_Framework_Constraint_IsFalse',
|
||||||
|
'PHPUnit_Framework_Constraint_IsIdentical',
|
||||||
|
'PHPUnit_Framework_Constraint_IsInstanceOf',
|
||||||
|
'PHPUnit_Framework_Constraint_IsJson',
|
||||||
|
'PHPUnit_Framework_Constraint_IsNull',
|
||||||
|
'PHPUnit_Framework_Constraint_IsTrue',
|
||||||
|
'PHPUnit_Framework_Constraint_IsType',
|
||||||
|
'PHPUnit_Framework_Constraint_JsonMatches',
|
||||||
|
'PHPUnit_Framework_Constraint_JsonMatches_ErrorMessageProvider',
|
||||||
|
'PHPUnit_Framework_Constraint_LessThan',
|
||||||
|
'PHPUnit_Framework_Constraint_Not',
|
||||||
|
'PHPUnit_Framework_Constraint_ObjectHasAttribute',
|
||||||
|
'PHPUnit_Framework_Constraint_Or',
|
||||||
|
'PHPUnit_Framework_Constraint_PCREMatch',
|
||||||
|
'PHPUnit_Framework_Constraint_SameSize',
|
||||||
|
'PHPUnit_Framework_Constraint_StringContains',
|
||||||
|
'PHPUnit_Framework_Constraint_StringEndsWith',
|
||||||
|
'PHPUnit_Framework_Constraint_StringMatches',
|
||||||
|
'PHPUnit_Framework_Constraint_StringStartsWith',
|
||||||
|
'PHPUnit_Framework_Constraint_TraversableContains',
|
||||||
|
'PHPUnit_Framework_Constraint_TraversableContainsOnly',
|
||||||
|
'PHPUnit_Framework_Constraint_Xor',
|
||||||
|
|
||||||
|
'PHPUnit_Framework_Error',
|
||||||
|
'PHPUnit_Framework_Error_Deprecated',
|
||||||
|
'PHPUnit_Framework_Error_Notice',
|
||||||
|
'PHPUnit_Framework_Error_Warning',
|
||||||
|
'PHPUnit_Framework_Exception',
|
||||||
|
'PHPUnit_Framework_ExpectationFailedException',
|
||||||
|
|
||||||
|
'PHPUnit_Framework_MockObject_MockObject',
|
||||||
|
|
||||||
|
'PHPUnit_Framework_IncompleteTest',
|
||||||
|
'PHPUnit_Framework_IncompleteTestCase',
|
||||||
|
'PHPUnit_Framework_IncompleteTestError',
|
||||||
|
'PHPUnit_Framework_RiskyTest',
|
||||||
|
'PHPUnit_Framework_RiskyTestError',
|
||||||
|
'PHPUnit_Framework_SkippedTest',
|
||||||
|
'PHPUnit_Framework_SkippedTestCase',
|
||||||
|
'PHPUnit_Framework_SkippedTestError',
|
||||||
|
'PHPUnit_Framework_SkippedTestSuiteError',
|
||||||
|
|
||||||
|
'PHPUnit_Framework_SyntheticError',
|
||||||
|
|
||||||
|
'PHPUnit_Framework_Test',
|
||||||
|
'PHPUnit_Framework_TestCase', // override PhpUnit's ForwardCompat child class
|
||||||
|
'PHPUnit_Framework_TestFailure',
|
||||||
|
'PHPUnit_Framework_TestListener',
|
||||||
|
'PHPUnit_Framework_TestResult',
|
||||||
|
'PHPUnit_Framework_TestSuite', // override PhpUnit's ForwardCompat child class
|
||||||
|
|
||||||
|
'PHPUnit_Runner_BaseTestRunner',
|
||||||
|
'PHPUnit_Runner_Version',
|
||||||
|
|
||||||
|
'PHPUnit_Util_Blacklist',
|
||||||
|
'PHPUnit_Util_ErrorHandler',
|
||||||
|
'PHPUnit_Util_Test',
|
||||||
|
'PHPUnit_Util_XML',
|
||||||
|
];
|
||||||
|
foreach ($classes as $class) {
|
||||||
|
class_alias($class, '\\'.strtr($class, '_', '\\'), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Detect if we need to serialize deprecations to a file.
|
// Detect if we need to serialize deprecations to a file.
|
||||||
if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
|
if ($file = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
|
||||||
DeprecationErrorHandler::collectDeprecations($file);
|
DeprecationErrorHandler::collectDeprecations($file);
|
||||||
|
@ -1369,7 +1369,7 @@ class Configuration implements ConfigurationInterface
|
|||||||
->info('A comma separated list of hosts that do not require a proxy to be reached.')
|
->info('A comma separated list of hosts that do not require a proxy to be reached.')
|
||||||
->end()
|
->end()
|
||||||
->floatNode('timeout')
|
->floatNode('timeout')
|
||||||
->info('Defaults to "default_socket_timeout" ini parameter.')
|
->info('The idle timeout, defaults to the "default_socket_timeout" ini parameter.')
|
||||||
->end()
|
->end()
|
||||||
->scalarNode('bindto')
|
->scalarNode('bindto')
|
||||||
->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
|
->info('A network interface name, IP address, a host name or a UNIX socket to bind to.')
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<service id="mailer.mailer" class="Symfony\Component\Mailer\Mailer">
|
<service id="mailer.mailer" class="Symfony\Component\Mailer\Mailer">
|
||||||
<argument type="service" id="mailer.default_transport" />
|
<argument type="service" id="mailer.default_transport" />
|
||||||
<argument type="service" id="messenger.default_bus" on-invalid="ignore" />
|
<argument type="service" id="messenger.default_bus" on-invalid="ignore" />
|
||||||
|
<argument type="service" id="event_dispatcher" on-invalid="ignore" />
|
||||||
</service>
|
</service>
|
||||||
<service id="mailer" alias="mailer.mailer" />
|
<service id="mailer" alias="mailer.mailer" />
|
||||||
<service id="Symfony\Component\Mailer\MailerInterface" alias="mailer.mailer" />
|
<service id="Symfony\Component\Mailer\MailerInterface" alias="mailer.mailer" />
|
||||||
|
@ -54,7 +54,6 @@ use Symfony\Component\Translation\DependencyInjection\TranslatorPass;
|
|||||||
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
|
use Symfony\Component\Validator\DependencyInjection\AddConstraintValidatorsPass;
|
||||||
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
|
use Symfony\Component\Validator\Mapping\Loader\PropertyInfoLoader;
|
||||||
use Symfony\Component\Workflow;
|
use Symfony\Component\Workflow;
|
||||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
|
||||||
|
|
||||||
abstract class FrameworkExtensionTest extends TestCase
|
abstract class FrameworkExtensionTest extends TestCase
|
||||||
{
|
{
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
<argument /> <!-- User Provider -->
|
<argument /> <!-- User Provider -->
|
||||||
<argument /> <!-- Provider-shared Key -->
|
<argument /> <!-- Provider-shared Key -->
|
||||||
<argument /> <!-- User Checker -->
|
<argument /> <!-- User Checker -->
|
||||||
|
<argument type="service" id="security.password_encoder" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="security.authentication.listener.guard"
|
<service id="security.authentication.listener.guard"
|
||||||
|
@ -233,7 +233,7 @@ class ResolveInstanceofConditionalsPassTest extends TestCase
|
|||||||
public function testProcessThrowsExceptionForArguments()
|
public function testProcessThrowsExceptionForArguments()
|
||||||
{
|
{
|
||||||
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
|
$this->expectException('Symfony\Component\DependencyInjection\Exception\InvalidArgumentException');
|
||||||
$this->expectExceptionMessage('Autoconfigured instanceof for type "PHPUnit\Framework\TestCase" defines arguments but these are not supported and should be removed.');
|
$this->expectExceptionMessageRegExp('/Autoconfigured instanceof for type "PHPUnit[\\\\_]Framework[\\\\_]TestCase" defines arguments but these are not supported and should be removed\./');
|
||||||
$container = new ContainerBuilder();
|
$container = new ContainerBuilder();
|
||||||
$container->registerForAutoconfiguration(parent::class)
|
$container->registerForAutoconfiguration(parent::class)
|
||||||
->addArgument('bar');
|
->addArgument('bar');
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\DependencyInjection\Tests\Config;
|
namespace Symfony\Component\DependencyInjection\Tests\Config;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Config\ResourceCheckerInterface;
|
use Symfony\Component\Config\ResourceCheckerInterface;
|
||||||
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
|
use Symfony\Component\DependencyInjection\Config\ContainerParametersResource;
|
||||||
@ -52,15 +53,15 @@ class ContainerParametersResourceCheckerTest extends TestCase
|
|||||||
|
|
||||||
public function isFreshProvider()
|
public function isFreshProvider()
|
||||||
{
|
{
|
||||||
yield 'not fresh on missing parameter' => [function (\PHPUnit\Framework\MockObject\MockObject $container) {
|
yield 'not fresh on missing parameter' => [function (MockObject $container) {
|
||||||
$container->method('hasParameter')->with('locales')->willReturn(false);
|
$container->method('hasParameter')->with('locales')->willReturn(false);
|
||||||
}, false];
|
}, false];
|
||||||
|
|
||||||
yield 'not fresh on different value' => [function (\PHPUnit\Framework\MockObject\MockObject $container) {
|
yield 'not fresh on different value' => [function (MockObject $container) {
|
||||||
$container->method('getParameter')->with('locales')->willReturn(['nl', 'es']);
|
$container->method('getParameter')->with('locales')->willReturn(['nl', 'es']);
|
||||||
}, false];
|
}, false];
|
||||||
|
|
||||||
yield 'fresh on every identical parameters' => [function (\PHPUnit\Framework\MockObject\MockObject $container) {
|
yield 'fresh on every identical parameters' => [function (MockObject $container) {
|
||||||
$container->expects($this->exactly(2))->method('hasParameter')->willReturn(true);
|
$container->expects($this->exactly(2))->method('hasParameter')->willReturn(true);
|
||||||
$container->expects($this->exactly(2))->method('getParameter')
|
$container->expects($this->exactly(2))->method('getParameter')
|
||||||
->withConsecutive(
|
->withConsecutive(
|
||||||
|
@ -294,7 +294,7 @@ class FlattenExceptionTest extends TestCase
|
|||||||
|
|
||||||
// assertEquals() does not like NAN values.
|
// assertEquals() does not like NAN values.
|
||||||
$this->assertEquals($array[$i][0], 'float');
|
$this->assertEquals($array[$i][0], 'float');
|
||||||
$this->assertTrue(is_nan($array[$i++][1]));
|
$this->assertNan($array[$i++][1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRecursionInArguments()
|
public function testRecursionInArguments()
|
||||||
|
@ -153,7 +153,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
$this->filesystem->copy($sourceFilePath, $targetFilePath);
|
$this->filesystem->copy($sourceFilePath, $targetFilePath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetFileDirectory));
|
$this->assertDirectoryExists($targetFileDirectory);
|
||||||
$this->assertFileExists($targetFilePath);
|
$this->assertFileExists($targetFilePath);
|
||||||
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
|
$this->assertStringEqualsFile($targetFilePath, 'SOURCE FILE');
|
||||||
}
|
}
|
||||||
@ -185,7 +185,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
$this->filesystem->mkdir($directory);
|
$this->filesystem->mkdir($directory);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($directory));
|
$this->assertDirectoryExists($directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMkdirCreatesDirectoriesFromArray()
|
public function testMkdirCreatesDirectoriesFromArray()
|
||||||
@ -197,9 +197,9 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
$this->filesystem->mkdir($directories);
|
$this->filesystem->mkdir($directories);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($basePath.'1'));
|
$this->assertDirectoryExists($basePath.'1');
|
||||||
$this->assertTrue(is_dir($basePath.'2'));
|
$this->assertDirectoryExists($basePath.'2');
|
||||||
$this->assertTrue(is_dir($basePath.'3'));
|
$this->assertDirectoryExists($basePath.'3');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMkdirCreatesDirectoriesFromTraversableObject()
|
public function testMkdirCreatesDirectoriesFromTraversableObject()
|
||||||
@ -211,9 +211,9 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
$this->filesystem->mkdir($directories);
|
$this->filesystem->mkdir($directories);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($basePath.'1'));
|
$this->assertDirectoryExists($basePath.'1');
|
||||||
$this->assertTrue(is_dir($basePath.'2'));
|
$this->assertDirectoryExists($basePath.'2');
|
||||||
$this->assertTrue(is_dir($basePath.'3'));
|
$this->assertDirectoryExists($basePath.'3');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMkdirCreatesDirectoriesFails()
|
public function testMkdirCreatesDirectoriesFails()
|
||||||
@ -347,7 +347,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
// create symlink to dir using trailing forward slash
|
// create symlink to dir using trailing forward slash
|
||||||
$this->filesystem->symlink($basePath.'dir/', $basePath.'dir-link');
|
$this->filesystem->symlink($basePath.'dir/', $basePath.'dir-link');
|
||||||
$this->assertTrue(is_dir($basePath.'dir-link'));
|
$this->assertDirectoryExists($basePath.'dir-link');
|
||||||
|
|
||||||
// create symlink to nonexistent dir
|
// create symlink to nonexistent dir
|
||||||
rmdir($basePath.'dir');
|
rmdir($basePath.'dir');
|
||||||
@ -807,7 +807,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
$this->assertFalse(is_link($link));
|
$this->assertFalse(is_link($link));
|
||||||
$this->assertFalse(is_file($link));
|
$this->assertFalse(is_file($link));
|
||||||
$this->assertFalse(is_dir($link));
|
$this->assertDirectoryNotExists($link);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
|
public function testSymlinkIsOverwrittenIfPointsToDifferentTarget()
|
||||||
@ -1136,8 +1136,8 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
$this->filesystem->mirror($sourcePath, $targetPath);
|
$this->filesystem->mirror($sourcePath, $targetPath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetPath));
|
$this->assertDirectoryExists($targetPath);
|
||||||
$this->assertTrue(is_dir($targetPath.'directory'));
|
$this->assertDirectoryExists($targetPath.'directory');
|
||||||
$this->assertFileEquals($file1, $targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1');
|
$this->assertFileEquals($file1, $targetPath.'directory'.\DIRECTORY_SEPARATOR.'file1');
|
||||||
$this->assertFileEquals($file2, $targetPath.'file2');
|
$this->assertFileEquals($file2, $targetPath.'file2');
|
||||||
|
|
||||||
@ -1170,7 +1170,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
$this->filesystem->mirror($sourcePath, $targetPath);
|
$this->filesystem->mirror($sourcePath, $targetPath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetPath));
|
$this->assertDirectoryExists($targetPath);
|
||||||
|
|
||||||
$this->filesystem->remove($sourcePath);
|
$this->filesystem->remove($sourcePath);
|
||||||
}
|
}
|
||||||
@ -1189,7 +1189,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
$this->filesystem->mirror($sourcePath, $targetPath);
|
$this->filesystem->mirror($sourcePath, $targetPath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetPath));
|
$this->assertDirectoryExists($targetPath);
|
||||||
$this->assertFileEquals($sourcePath.'file1', $targetPath.'link1');
|
$this->assertFileEquals($sourcePath.'file1', $targetPath.'link1');
|
||||||
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
|
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
|
||||||
}
|
}
|
||||||
@ -1209,7 +1209,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
$this->filesystem->mirror($sourcePath, $targetPath);
|
$this->filesystem->mirror($sourcePath, $targetPath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetPath));
|
$this->assertDirectoryExists($targetPath);
|
||||||
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
|
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
|
||||||
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
|
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
|
||||||
}
|
}
|
||||||
@ -1233,7 +1233,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
$this->filesystem->mirror($sourcePath, $targetPath);
|
$this->filesystem->mirror($sourcePath, $targetPath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetPath));
|
$this->assertDirectoryExists($targetPath);
|
||||||
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
|
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.'link1/file1.txt');
|
||||||
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
|
$this->assertTrue(is_link($targetPath.\DIRECTORY_SEPARATOR.'link1'));
|
||||||
$this->assertEquals('\\' === \DIRECTORY_SEPARATOR ? realpath($sourcePath.'\nested') : 'nested', readlink($targetPath.\DIRECTORY_SEPARATOR.'link1'));
|
$this->assertEquals('\\' === \DIRECTORY_SEPARATOR ? realpath($sourcePath.'\nested') : 'nested', readlink($targetPath.\DIRECTORY_SEPARATOR.'link1'));
|
||||||
@ -1256,7 +1256,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
chdir($oldPath);
|
chdir($oldPath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetPath));
|
$this->assertDirectoryExists($targetPath);
|
||||||
$this->assertFileExists($targetPath.'source');
|
$this->assertFileExists($targetPath.'source');
|
||||||
$this->assertFileExists($targetPath.'target');
|
$this->assertFileExists($targetPath.'target');
|
||||||
}
|
}
|
||||||
@ -1281,7 +1281,7 @@ class FilesystemTest extends FilesystemTestCase
|
|||||||
|
|
||||||
chdir($oldPath);
|
chdir($oldPath);
|
||||||
|
|
||||||
$this->assertTrue(is_dir($targetPath));
|
$this->assertDirectoryExists($targetPath);
|
||||||
$this->assertFileExists($targetPath.'source');
|
$this->assertFileExists($targetPath.'source');
|
||||||
$this->assertFileNotExists($targetPath.'target');
|
$this->assertFileNotExists($targetPath.'target');
|
||||||
}
|
}
|
||||||
|
@ -1365,11 +1365,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
|
|||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$expectedExceptionClass = 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException';
|
$expectedExceptionClass = 'Symfony\\Component\\Finder\\Exception\\AccessDeniedException';
|
||||||
if ($e instanceof \PHPUnit\Framework\ExpectationFailedException) {
|
if ($e instanceof \PHPUnit\Framework\ExpectationFailedException) {
|
||||||
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit_Framework_ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
|
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, 'PHPUnit\Framework\ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
|
||||||
}
|
|
||||||
|
|
||||||
if ($e instanceof \PHPUnit\Framework\ExpectationFailedException) {
|
|
||||||
$this->fail(sprintf("Expected exception:\n%s\nGot:\n%s\nWith comparison failure:\n%s", $expectedExceptionClass, '\PHPUnit\Framework\ExpectationFailedException', $e->getComparisonFailure()->getExpectedAsString()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertInstanceOf($expectedExceptionClass, $e);
|
$this->assertInstanceOf($expectedExceptionClass, $e);
|
||||||
|
@ -38,8 +38,6 @@ class Button implements \IteratorAggregate, FormInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new button from a form configuration.
|
* Creates a new button from a form configuration.
|
||||||
*
|
|
||||||
* @param FormConfigInterface $config The button's configuration
|
|
||||||
*/
|
*/
|
||||||
public function __construct(FormConfigInterface $config)
|
public function __construct(FormConfigInterface $config)
|
||||||
{
|
{
|
||||||
@ -128,10 +126,6 @@ class Button implements \IteratorAggregate, FormInterface
|
|||||||
*
|
*
|
||||||
* This method should not be invoked.
|
* This method should not be invoked.
|
||||||
*
|
*
|
||||||
* @param int|string|FormInterface $child
|
|
||||||
* @param null $type
|
|
||||||
* @param array $options
|
|
||||||
*
|
|
||||||
* @throws BadMethodCallException
|
* @throws BadMethodCallException
|
||||||
*/
|
*/
|
||||||
public function add($child, $type = null, array $options = [])
|
public function add($child, $type = null, array $options = [])
|
||||||
|
@ -37,7 +37,7 @@ class MockResponse implements ResponseInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|string[]|iterable $body The response body as a string or an iterable of strings,
|
* @param string|string[]|iterable $body The response body as a string or an iterable of strings,
|
||||||
* yielding an empty string simulates a timeout,
|
* yielding an empty string simulates an idle timeout,
|
||||||
* exceptions are turned to TransportException
|
* exceptions are turned to TransportException
|
||||||
*
|
*
|
||||||
* @see ResponseInterface::getInfo() for possible info, e.g. "response_headers"
|
* @see ResponseInterface::getInfo() for possible info, e.g. "response_headers"
|
||||||
@ -277,7 +277,7 @@ class MockResponse implements ResponseInterface
|
|||||||
if (!\is_string($body)) {
|
if (!\is_string($body)) {
|
||||||
foreach ($body as $chunk) {
|
foreach ($body as $chunk) {
|
||||||
if ('' === $chunk = (string) $chunk) {
|
if ('' === $chunk = (string) $chunk) {
|
||||||
// simulate a timeout
|
// simulate an idle timeout
|
||||||
$response->body[] = new ErrorChunk($offset);
|
$response->body[] = new ErrorChunk($offset);
|
||||||
} else {
|
} else {
|
||||||
$response->body[] = $chunk;
|
$response->body[] = $chunk;
|
||||||
|
@ -42,7 +42,7 @@ class NativeFileSessionHandlerTest extends TestCase
|
|||||||
{
|
{
|
||||||
$handler = new NativeFileSessionHandler($savePath);
|
$handler = new NativeFileSessionHandler($savePath);
|
||||||
$this->assertEquals($expectedSavePath, ini_get('session.save_path'));
|
$this->assertEquals($expectedSavePath, ini_get('session.save_path'));
|
||||||
$this->assertTrue(is_dir(realpath($path)));
|
$this->assertDirectoryExists(realpath($path));
|
||||||
|
|
||||||
rmdir($path);
|
rmdir($path);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ class RemoveEmptyControllerArgumentLocatorsPassTest extends TestCase
|
|||||||
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
$resolver = $container->register('argument_resolver.service')->addArgument([]);
|
||||||
|
|
||||||
$container->register('stdClass', 'stdClass');
|
$container->register('stdClass', 'stdClass');
|
||||||
$container->register(parent::class, 'stdClass');
|
$container->register(TestCase::class, 'stdClass');
|
||||||
$container->register('c1', RemoveTestController1::class)->addTag('controller.service_arguments');
|
$container->register('c1', RemoveTestController1::class)->addTag('controller.service_arguments');
|
||||||
$container->register('c2', RemoveTestController2::class)->addTag('controller.service_arguments')
|
$container->register('c2', RemoveTestController2::class)->addTag('controller.service_arguments')
|
||||||
->addMethodCall('setTestCase', [new Reference('c1')]);
|
->addMethodCall('setTestCase', [new Reference('c1')]);
|
||||||
|
@ -31,13 +31,16 @@ final class Countries extends ResourceBundle
|
|||||||
*
|
*
|
||||||
* This list only contains "officially assigned ISO 3166-1 alpha-2" country codes.
|
* This list only contains "officially assigned ISO 3166-1 alpha-2" country codes.
|
||||||
*
|
*
|
||||||
* @return string[] an array of canonical ISO 3166 country codes
|
* @return string[] an array of canonical ISO 3166 alpha-2 country codes
|
||||||
*/
|
*/
|
||||||
public static function getCountryCodes(): array
|
public static function getCountryCodes(): array
|
||||||
{
|
{
|
||||||
return self::readEntry(['Regions'], 'meta');
|
return self::readEntry(['Regions'], 'meta');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $country Alpha2 country code
|
||||||
|
*/
|
||||||
public static function exists(string $country): bool
|
public static function exists(string $country): bool
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -50,6 +53,8 @@ final class Countries extends ResourceBundle
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the country name from alpha2 code.
|
||||||
|
*
|
||||||
* @throws MissingResourceException if the country code does not exists
|
* @throws MissingResourceException if the country code does not exists
|
||||||
*/
|
*/
|
||||||
public static function getName(string $country, string $displayLocale = null): string
|
public static function getName(string $country, string $displayLocale = null): string
|
||||||
@ -58,6 +63,8 @@ final class Countries extends ResourceBundle
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the list of country names indexed with alpha2 codes as keys.
|
||||||
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public static function getNames($displayLocale = null): array
|
public static function getNames($displayLocale = null): array
|
||||||
|
@ -176,7 +176,7 @@ class IntlDateFormatter
|
|||||||
/**
|
/**
|
||||||
* Format the date/time value (timestamp) as a string.
|
* Format the date/time value (timestamp) as a string.
|
||||||
*
|
*
|
||||||
* @param int|\DateTime $timestamp The timestamp to format
|
* @param int|\DateTimeInterface $timestamp The timestamp to format
|
||||||
*
|
*
|
||||||
* @return string|bool The formatted value or false if formatting failed
|
* @return string|bool The formatted value or false if formatting failed
|
||||||
*
|
*
|
||||||
@ -195,7 +195,7 @@ class IntlDateFormatter
|
|||||||
|
|
||||||
// behave like the intl extension
|
// behave like the intl extension
|
||||||
$argumentError = null;
|
$argumentError = null;
|
||||||
if (!\is_int($timestamp) && !$timestamp instanceof \DateTime) {
|
if (!\is_int($timestamp) && !$timestamp instanceof \DateTimeInterface) {
|
||||||
$argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp);
|
$argumentError = sprintf('datefmt_format: string \'%s\' is not numeric, which would be required for it to be a valid date', $timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ class IntlDateFormatter
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($timestamp instanceof \DateTime) {
|
if ($timestamp instanceof \DateTimeInterface) {
|
||||||
$timestamp = $timestamp->getTimestamp();
|
$timestamp = $timestamp->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ use Symfony\Component\Intl\Exception\MissingResourceException;
|
|||||||
final class Languages extends ResourceBundle
|
final class Languages extends ResourceBundle
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns all available languages.
|
* Returns all available languages as two-letter codes.
|
||||||
*
|
*
|
||||||
* Languages are returned as lowercase ISO 639-1 two-letter language codes.
|
* Languages are returned as lowercase ISO 639-1 two-letter language codes.
|
||||||
* For languages that don't have a two-letter code, the ISO 639-2
|
* For languages that don't have a two-letter code, the ISO 639-2
|
||||||
@ -31,7 +31,7 @@ final class Languages extends ResourceBundle
|
|||||||
* A full table of ISO 639 language codes can be found here:
|
* A full table of ISO 639 language codes can be found here:
|
||||||
* http://www-01.sil.org/iso639-3/codes.asp
|
* http://www-01.sil.org/iso639-3/codes.asp
|
||||||
*
|
*
|
||||||
* @return string[] an array of canonical ISO 639 language codes
|
* @return string[] an array of canonical ISO 639-1 language codes
|
||||||
*/
|
*/
|
||||||
public static function getLanguageCodes(): array
|
public static function getLanguageCodes(): array
|
||||||
{
|
{
|
||||||
@ -50,6 +50,8 @@ final class Languages extends ResourceBundle
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the language name from alpha2 code.
|
||||||
|
*
|
||||||
* @throws MissingResourceException if the language code does not exists
|
* @throws MissingResourceException if the language code does not exists
|
||||||
*/
|
*/
|
||||||
public static function getName(string $language, string $displayLocale = null): string
|
public static function getName(string $language, string $displayLocale = null): string
|
||||||
@ -58,6 +60,8 @@ final class Languages extends ResourceBundle
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Gets the list of language names indexed with alpha2 codes as keys.
|
||||||
|
*
|
||||||
* @return string[]
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public static function getNames(string $displayLocale = null): array
|
public static function getNames(string $displayLocale = null): array
|
||||||
@ -66,7 +70,7 @@ final class Languages extends ResourceBundle
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the ISO 639-2 three-letter code of a language.
|
* Returns the ISO 639-2 three-letter code of a language, given a two-letter code.
|
||||||
*
|
*
|
||||||
* @throws MissingResourceException if the language has no corresponding three-letter code
|
* @throws MissingResourceException if the language has no corresponding three-letter code
|
||||||
*/
|
*/
|
||||||
|
@ -76,6 +76,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
|
|||||||
public function formatProvider()
|
public function formatProvider()
|
||||||
{
|
{
|
||||||
$dateTime = new \DateTime('@0');
|
$dateTime = new \DateTime('@0');
|
||||||
|
$dateTimeImmutable = new \DateTimeImmutable('@0');
|
||||||
|
|
||||||
$formatData = [
|
$formatData = [
|
||||||
/* general */
|
/* general */
|
||||||
@ -250,6 +251,12 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
|
|||||||
$formatData[] = ['h:mm a', $dateTime, '12:00 AM'];
|
$formatData[] = ['h:mm a', $dateTime, '12:00 AM'];
|
||||||
$formatData[] = ['yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM'];
|
$formatData[] = ['yyyyy.MMMM.dd hh:mm aaa', $dateTime, '01970.January.01 12:00 AM'];
|
||||||
|
|
||||||
|
/* general, DateTimeImmutable */
|
||||||
|
$formatData[] = ['y-M-d', $dateTimeImmutable, '1970-1-1'];
|
||||||
|
$formatData[] = ["EEE, MMM d, ''yy", $dateTimeImmutable, "Thu, Jan 1, '70"];
|
||||||
|
$formatData[] = ['h:mm a', $dateTimeImmutable, '12:00 AM'];
|
||||||
|
$formatData[] = ['yyyyy.MMMM.dd hh:mm aaa', $dateTimeImmutable, '01970.January.01 12:00 AM'];
|
||||||
|
|
||||||
if (IcuVersion::compare(Intl::getIcuVersion(), '59.1', '>=', 1)) {
|
if (IcuVersion::compare(Intl::getIcuVersion(), '59.1', '>=', 1)) {
|
||||||
// Before ICU 59.1 GMT was used instead of UTC
|
// Before ICU 59.1 GMT was used instead of UTC
|
||||||
$formatData[] = ["yyyy.MM.dd 'at' HH:mm:ss zzz", 0, '1970.01.01 at 00:00:00 UTC'];
|
$formatData[] = ["yyyy.MM.dd 'at' HH:mm:ss zzz", 0, '1970.01.01 at 00:00:00 UTC'];
|
||||||
@ -269,6 +276,8 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
|
|||||||
|
|
||||||
$this->assertSame('1970.01.01 at 00:00:00 GMT', $gmtFormatter->format(new \DateTime('@0')));
|
$this->assertSame('1970.01.01 at 00:00:00 GMT', $gmtFormatter->format(new \DateTime('@0')));
|
||||||
$this->assertSame('1970.01.01 at 00:00:00 UTC', $utcFormatter->format(new \DateTime('@0')));
|
$this->assertSame('1970.01.01 at 00:00:00 UTC', $utcFormatter->format(new \DateTime('@0')));
|
||||||
|
$this->assertSame('1970.01.01 at 00:00:00 GMT', $gmtFormatter->format(new \DateTimeImmutable('@0')));
|
||||||
|
$this->assertSame('1970.01.01 at 00:00:00 UTC', $utcFormatter->format(new \DateTimeImmutable('@0')));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,6 +41,6 @@ class IntlTest extends TestCase
|
|||||||
|
|
||||||
public function testGetDataDirectoryReturnsThePathToIcuData()
|
public function testGetDataDirectoryReturnsThePathToIcuData()
|
||||||
{
|
{
|
||||||
$this->assertTrue(is_dir(Intl::getDataDirectory()));
|
$this->assertDirectoryExists(Intl::getDataDirectory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -644,11 +644,9 @@ class LanguagesTest extends ResourceBundleTestCase
|
|||||||
'ab' => 'abk',
|
'ab' => 'abk',
|
||||||
'af' => 'afr',
|
'af' => 'afr',
|
||||||
'ak' => 'aka',
|
'ak' => 'aka',
|
||||||
'sq' => 'sqi',
|
|
||||||
'am' => 'amh',
|
'am' => 'amh',
|
||||||
'ar' => 'ara',
|
'ar' => 'ara',
|
||||||
'an' => 'arg',
|
'an' => 'arg',
|
||||||
'hy' => 'hye',
|
|
||||||
'as' => 'asm',
|
'as' => 'asm',
|
||||||
'av' => 'ava',
|
'av' => 'ava',
|
||||||
'ae' => 'ave',
|
'ae' => 'ave',
|
||||||
@ -656,7 +654,6 @@ class LanguagesTest extends ResourceBundleTestCase
|
|||||||
'az' => 'aze',
|
'az' => 'aze',
|
||||||
'ba' => 'bak',
|
'ba' => 'bak',
|
||||||
'bm' => 'bam',
|
'bm' => 'bam',
|
||||||
'eu' => 'eus',
|
|
||||||
'be' => 'bel',
|
'be' => 'bel',
|
||||||
'bn' => 'ben',
|
'bn' => 'ben',
|
||||||
'bi' => 'bis',
|
'bi' => 'bis',
|
||||||
@ -664,12 +661,10 @@ class LanguagesTest extends ResourceBundleTestCase
|
|||||||
'bs' => 'bos',
|
'bs' => 'bos',
|
||||||
'br' => 'bre',
|
'br' => 'bre',
|
||||||
'bg' => 'bul',
|
'bg' => 'bul',
|
||||||
'my' => 'mya',
|
|
||||||
'ca' => 'cat',
|
'ca' => 'cat',
|
||||||
'cs' => 'ces',
|
'cs' => 'ces',
|
||||||
'ch' => 'cha',
|
'ch' => 'cha',
|
||||||
'ce' => 'che',
|
'ce' => 'che',
|
||||||
'zh' => 'zho',
|
|
||||||
'cu' => 'chu',
|
'cu' => 'chu',
|
||||||
'cv' => 'chv',
|
'cv' => 'chv',
|
||||||
'kw' => 'cor',
|
'kw' => 'cor',
|
||||||
@ -679,13 +674,12 @@ class LanguagesTest extends ResourceBundleTestCase
|
|||||||
'da' => 'dan',
|
'da' => 'dan',
|
||||||
'de' => 'deu',
|
'de' => 'deu',
|
||||||
'dv' => 'div',
|
'dv' => 'div',
|
||||||
'nl' => 'nld',
|
|
||||||
'dz' => 'dzo',
|
'dz' => 'dzo',
|
||||||
'et' => 'est',
|
|
||||||
'el' => 'ell',
|
'el' => 'ell',
|
||||||
'en' => 'eng',
|
'en' => 'eng',
|
||||||
'eo' => 'epo',
|
'eo' => 'epo',
|
||||||
'ik' => 'ipk',
|
'et' => 'est',
|
||||||
|
'eu' => 'eus',
|
||||||
'ee' => 'ewe',
|
'ee' => 'ewe',
|
||||||
'fo' => 'fao',
|
'fo' => 'fao',
|
||||||
'fa' => 'fas',
|
'fa' => 'fas',
|
||||||
@ -694,8 +688,6 @@ class LanguagesTest extends ResourceBundleTestCase
|
|||||||
'fr' => 'fra',
|
'fr' => 'fra',
|
||||||
'fy' => 'fry',
|
'fy' => 'fry',
|
||||||
'ff' => 'ful',
|
'ff' => 'ful',
|
||||||
'om' => 'orm',
|
|
||||||
'ka' => 'kat',
|
|
||||||
'gd' => 'gla',
|
'gd' => 'gla',
|
||||||
'ga' => 'gle',
|
'ga' => 'gle',
|
||||||
'gl' => 'glg',
|
'gl' => 'glg',
|
||||||
@ -710,32 +702,34 @@ class LanguagesTest extends ResourceBundleTestCase
|
|||||||
'ho' => 'hmo',
|
'ho' => 'hmo',
|
||||||
'hr' => 'hrv',
|
'hr' => 'hrv',
|
||||||
'hu' => 'hun',
|
'hu' => 'hun',
|
||||||
|
'hy' => 'hye',
|
||||||
'ig' => 'ibo',
|
'ig' => 'ibo',
|
||||||
'is' => 'isl',
|
|
||||||
'io' => 'ido',
|
'io' => 'ido',
|
||||||
'ii' => 'iii',
|
'ii' => 'iii',
|
||||||
'iu' => 'iku',
|
'iu' => 'iku',
|
||||||
'ie' => 'ile',
|
'ie' => 'ile',
|
||||||
'ia' => 'ina',
|
'ia' => 'ina',
|
||||||
'id' => 'ind',
|
'id' => 'ind',
|
||||||
|
'ik' => 'ipk',
|
||||||
|
'is' => 'isl',
|
||||||
'it' => 'ita',
|
'it' => 'ita',
|
||||||
'jv' => 'jav',
|
'jv' => 'jav',
|
||||||
'ja' => 'jpn',
|
'ja' => 'jpn',
|
||||||
'kl' => 'kal',
|
'kl' => 'kal',
|
||||||
'kn' => 'kan',
|
'kn' => 'kan',
|
||||||
'ks' => 'kas',
|
'ks' => 'kas',
|
||||||
|
'ka' => 'kat',
|
||||||
'kr' => 'kau',
|
'kr' => 'kau',
|
||||||
'kk' => 'kaz',
|
'kk' => 'kaz',
|
||||||
'mn' => 'mon',
|
|
||||||
'km' => 'khm',
|
'km' => 'khm',
|
||||||
'ki' => 'kik',
|
'ki' => 'kik',
|
||||||
'rw' => 'kin',
|
'rw' => 'kin',
|
||||||
'ky' => 'kir',
|
'ky' => 'kir',
|
||||||
'ku' => 'kur',
|
|
||||||
'kg' => 'kon',
|
|
||||||
'kv' => 'kom',
|
'kv' => 'kom',
|
||||||
|
'kg' => 'kon',
|
||||||
'ko' => 'kor',
|
'ko' => 'kor',
|
||||||
'kj' => 'kua',
|
'kj' => 'kua',
|
||||||
|
'ku' => 'kur',
|
||||||
'lo' => 'lao',
|
'lo' => 'lao',
|
||||||
'la' => 'lat',
|
'la' => 'lat',
|
||||||
'lv' => 'lav',
|
'lv' => 'lav',
|
||||||
@ -745,32 +739,36 @@ class LanguagesTest extends ResourceBundleTestCase
|
|||||||
'lb' => 'ltz',
|
'lb' => 'ltz',
|
||||||
'lu' => 'lub',
|
'lu' => 'lub',
|
||||||
'lg' => 'lug',
|
'lg' => 'lug',
|
||||||
'mk' => 'mkd',
|
|
||||||
'mh' => 'mah',
|
'mh' => 'mah',
|
||||||
'ml' => 'mal',
|
'ml' => 'mal',
|
||||||
'mi' => 'mri',
|
|
||||||
'mr' => 'mar',
|
'mr' => 'mar',
|
||||||
'ms' => 'msa',
|
'mk' => 'mkd',
|
||||||
'mg' => 'mlg',
|
'mg' => 'mlg',
|
||||||
'mt' => 'mlt',
|
'mt' => 'mlt',
|
||||||
|
'mn' => 'mon',
|
||||||
|
'mi' => 'mri',
|
||||||
|
'ms' => 'msa',
|
||||||
|
'my' => 'mya',
|
||||||
'na' => 'nau',
|
'na' => 'nau',
|
||||||
'nv' => 'nav',
|
'nv' => 'nav',
|
||||||
'nr' => 'nbl',
|
'nr' => 'nbl',
|
||||||
'nd' => 'nde',
|
'nd' => 'nde',
|
||||||
'ng' => 'ndo',
|
'ng' => 'ndo',
|
||||||
'ne' => 'nep',
|
'ne' => 'nep',
|
||||||
|
'nl' => 'nld',
|
||||||
'nn' => 'nno',
|
'nn' => 'nno',
|
||||||
'nb' => 'nob',
|
'nb' => 'nob',
|
||||||
'ny' => 'nya',
|
'ny' => 'nya',
|
||||||
'oc' => 'oci',
|
'oc' => 'oci',
|
||||||
'oj' => 'oji',
|
'oj' => 'oji',
|
||||||
'or' => 'ori',
|
'or' => 'ori',
|
||||||
|
'om' => 'orm',
|
||||||
'os' => 'oss',
|
'os' => 'oss',
|
||||||
'pa' => 'pan',
|
'pa' => 'pan',
|
||||||
'ps' => 'pus',
|
|
||||||
'pi' => 'pli',
|
'pi' => 'pli',
|
||||||
'pl' => 'pol',
|
'pl' => 'pol',
|
||||||
'pt' => 'por',
|
'pt' => 'por',
|
||||||
|
'ps' => 'pus',
|
||||||
'qu' => 'que',
|
'qu' => 'que',
|
||||||
'rm' => 'roh',
|
'rm' => 'roh',
|
||||||
'ro' => 'ron',
|
'ro' => 'ron',
|
||||||
@ -778,7 +776,6 @@ class LanguagesTest extends ResourceBundleTestCase
|
|||||||
'ru' => 'rus',
|
'ru' => 'rus',
|
||||||
'sg' => 'sag',
|
'sg' => 'sag',
|
||||||
'sa' => 'san',
|
'sa' => 'san',
|
||||||
'sr' => 'srp',
|
|
||||||
'si' => 'sin',
|
'si' => 'sin',
|
||||||
'sk' => 'slk',
|
'sk' => 'slk',
|
||||||
'sl' => 'slv',
|
'sl' => 'slv',
|
||||||
@ -789,7 +786,9 @@ class LanguagesTest extends ResourceBundleTestCase
|
|||||||
'so' => 'som',
|
'so' => 'som',
|
||||||
'st' => 'sot',
|
'st' => 'sot',
|
||||||
'es' => 'spa',
|
'es' => 'spa',
|
||||||
|
'sq' => 'sqi',
|
||||||
'sc' => 'srd',
|
'sc' => 'srd',
|
||||||
|
'sr' => 'srp',
|
||||||
'ss' => 'ssw',
|
'ss' => 'ssw',
|
||||||
'su' => 'sun',
|
'su' => 'sun',
|
||||||
'sw' => 'swa',
|
'sw' => 'swa',
|
||||||
@ -819,6 +818,7 @@ class LanguagesTest extends ResourceBundleTestCase
|
|||||||
'yi' => 'yid',
|
'yi' => 'yid',
|
||||||
'yo' => 'yor',
|
'yo' => 'yor',
|
||||||
'za' => 'zha',
|
'za' => 'zha',
|
||||||
|
'zh' => 'zho',
|
||||||
'zu' => 'zul',
|
'zu' => 'zul',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Intl\Tests\NumberFormatter;
|
namespace Symfony\Component\Intl\Tests\NumberFormatter;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\Error\Warning;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Intl\Globals\IntlGlobals;
|
use Symfony\Component\Intl\Globals\IntlGlobals;
|
||||||
use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
|
use Symfony\Component\Intl\NumberFormatter\NumberFormatter;
|
||||||
@ -323,13 +324,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatTypeCurrency($formatter, $value)
|
public function testFormatTypeCurrency($formatter, $value)
|
||||||
{
|
{
|
||||||
$exceptionCode = 'PHPUnit\Framework\Error\Warning';
|
$this->expectException(Warning::class);
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Framework_Error_Warning')) {
|
|
||||||
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->expectException($exceptionCode);
|
|
||||||
|
|
||||||
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
|
$formatter->format($value, NumberFormatter::TYPE_CURRENCY);
|
||||||
}
|
}
|
||||||
@ -706,13 +701,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
|
|
||||||
public function testParseTypeDefault()
|
public function testParseTypeDefault()
|
||||||
{
|
{
|
||||||
$exceptionCode = 'PHPUnit\Framework\Error\Warning';
|
$this->expectException(Warning::class);
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Framework_Error_Warning')) {
|
|
||||||
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->expectException($exceptionCode);
|
|
||||||
|
|
||||||
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
|
$formatter->parse('1', NumberFormatter::TYPE_DEFAULT);
|
||||||
@ -832,13 +821,7 @@ abstract class AbstractNumberFormatterTest extends TestCase
|
|||||||
|
|
||||||
public function testParseTypeCurrency()
|
public function testParseTypeCurrency()
|
||||||
{
|
{
|
||||||
$exceptionCode = 'PHPUnit\Framework\Error\Warning';
|
$this->expectException(Warning::class);
|
||||||
|
|
||||||
if (class_exists('PHPUnit_Framework_Error_Warning')) {
|
|
||||||
$exceptionCode = 'PHPUnit_Framework_Error_Warning';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->expectException($exceptionCode);
|
|
||||||
|
|
||||||
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
$formatter = $this->getNumberFormatter('en', NumberFormatter::DECIMAL);
|
||||||
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
|
$formatter->parse('1', NumberFormatter::TYPE_CURRENCY);
|
||||||
|
@ -51,7 +51,7 @@ class GitRepositoryTest extends TestCase
|
|||||||
$git = GitRepository::download(self::REPO_URL, $this->targetDir);
|
$git = GitRepository::download(self::REPO_URL, $this->targetDir);
|
||||||
|
|
||||||
$this->assertInstanceOf(GitRepository::class, $git);
|
$this->assertInstanceOf(GitRepository::class, $git);
|
||||||
$this->assertTrue(is_dir($this->targetDir.'/.git'));
|
$this->assertDirectoryExists($this->targetDir.'/.git');
|
||||||
$this->assertSame($this->targetDir, $git->getPath());
|
$this->assertSame($this->targetDir, $git->getPath());
|
||||||
$this->assertSame(self::REPO_URL, $git->getUrl());
|
$this->assertSame(self::REPO_URL, $git->getUrl());
|
||||||
$this->assertRegExp('#^[0-9a-z]{40}$#', $git->getLastCommitHash());
|
$this->assertRegExp('#^[0-9a-z]{40}$#', $git->getLastCommitHash());
|
||||||
|
@ -13,10 +13,12 @@ namespace Symfony\Component\Ldap\Security;
|
|||||||
|
|
||||||
use Symfony\Component\Ldap\Entry;
|
use Symfony\Component\Ldap\Entry;
|
||||||
use Symfony\Component\Ldap\Exception\ConnectionException;
|
use Symfony\Component\Ldap\Exception\ConnectionException;
|
||||||
|
use Symfony\Component\Ldap\Exception\ExceptionInterface;
|
||||||
use Symfony\Component\Ldap\LdapInterface;
|
use Symfony\Component\Ldap\LdapInterface;
|
||||||
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
|
use Symfony\Component\Security\Core\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
|
|
||||||
@ -27,7 +29,7 @@ use Symfony\Component\Security\Core\User\UserProviderInterface;
|
|||||||
* @author Charles Sarrazin <charles@sarraz.in>
|
* @author Charles Sarrazin <charles@sarraz.in>
|
||||||
* @author Robin Chalas <robin.chalas@gmail.com>
|
* @author Robin Chalas <robin.chalas@gmail.com>
|
||||||
*/
|
*/
|
||||||
class LdapUserProvider implements UserProviderInterface
|
class LdapUserProvider implements UserProviderInterface, PasswordUpgraderInterface
|
||||||
{
|
{
|
||||||
private $ldap;
|
private $ldap;
|
||||||
private $baseDn;
|
private $baseDn;
|
||||||
@ -109,6 +111,30 @@ class LdapUserProvider implements UserProviderInterface
|
|||||||
return new LdapUser($user->getEntry(), $user->getUsername(), $user->getPassword(), $user->getRoles());
|
return new LdapUser($user->getEntry(), $user->getUsername(), $user->getPassword(), $user->getRoles());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
|
||||||
|
{
|
||||||
|
if (!$user instanceof LdapUser) {
|
||||||
|
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', \get_class($user)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null === $this->passwordAttribute) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if ($user->isEqualTo($this->loadUserByUsername($user->getUsername()))) {
|
||||||
|
$user->getEntry()->setAttribute($this->passwordAttribute, [$newEncodedPassword]);
|
||||||
|
$this->ldap->getEntryManager()->update($user->getEntry());
|
||||||
|
$user->setPassword($newEncodedPassword);
|
||||||
|
}
|
||||||
|
} catch (ExceptionInterface $e) {
|
||||||
|
// ignore failed password upgrades
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
|
@ -26,11 +26,10 @@ use Symfony\Component\Ldap\Security\LdapUserProvider;
|
|||||||
*/
|
*/
|
||||||
class LdapUserProviderTest extends TestCase
|
class LdapUserProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
|
|
||||||
*/
|
|
||||||
public function testLoadUserByUsernameFailsIfCantConnectToLdap()
|
public function testLoadUserByUsernameFailsIfCantConnectToLdap()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class);
|
||||||
|
|
||||||
$ldap = $this->createMock(LdapInterface::class);
|
$ldap = $this->createMock(LdapInterface::class);
|
||||||
$ldap
|
$ldap
|
||||||
->expects($this->once())
|
->expects($this->once())
|
||||||
@ -42,11 +41,10 @@ class LdapUserProviderTest extends TestCase
|
|||||||
$provider->loadUserByUsername('foo');
|
$provider->loadUserByUsername('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
|
|
||||||
*/
|
|
||||||
public function testLoadUserByUsernameFailsIfNoLdapEntries()
|
public function testLoadUserByUsernameFailsIfNoLdapEntries()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class);
|
||||||
|
|
||||||
$result = $this->createMock(CollectionInterface::class);
|
$result = $this->createMock(CollectionInterface::class);
|
||||||
$query = $this->createMock(QueryInterface::class);
|
$query = $this->createMock(QueryInterface::class);
|
||||||
$query
|
$query
|
||||||
@ -75,11 +73,10 @@ class LdapUserProviderTest extends TestCase
|
|||||||
$provider->loadUserByUsername('foo');
|
$provider->loadUserByUsername('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Symfony\Component\Security\Core\Exception\UsernameNotFoundException
|
|
||||||
*/
|
|
||||||
public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry()
|
public function testLoadUserByUsernameFailsIfMoreThanOneLdapEntry()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Symfony\Component\Security\Core\Exception\UsernameNotFoundException::class);
|
||||||
|
|
||||||
$result = $this->createMock(CollectionInterface::class);
|
$result = $this->createMock(CollectionInterface::class);
|
||||||
$query = $this->createMock(QueryInterface::class);
|
$query = $this->createMock(QueryInterface::class);
|
||||||
$query
|
$query
|
||||||
@ -108,11 +105,10 @@ class LdapUserProviderTest extends TestCase
|
|||||||
$provider->loadUserByUsername('foo');
|
$provider->loadUserByUsername('foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Symfony\Component\Security\Core\Exception\InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
|
public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Symfony\Component\Security\Core\Exception\InvalidArgumentException::class);
|
||||||
|
|
||||||
$result = $this->createMock(CollectionInterface::class);
|
$result = $this->createMock(CollectionInterface::class);
|
||||||
$query = $this->createMock(QueryInterface::class);
|
$query = $this->createMock(QueryInterface::class);
|
||||||
$query
|
$query
|
||||||
@ -186,11 +182,10 @@ class LdapUserProviderTest extends TestCase
|
|||||||
$this->assertInstanceOf(LdapUser::class, $provider->loadUserByUsername('foo'));
|
$this->assertInstanceOf(LdapUser::class, $provider->loadUserByUsername('foo'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Symfony\Component\Security\Core\Exception\InvalidArgumentException
|
|
||||||
*/
|
|
||||||
public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute()
|
public function testLoadUserByUsernameFailsIfEntryHasNoPasswordAttribute()
|
||||||
{
|
{
|
||||||
|
$this->expectException(\Symfony\Component\Security\Core\Exception\InvalidArgumentException::class);
|
||||||
|
|
||||||
$result = $this->createMock(CollectionInterface::class);
|
$result = $this->createMock(CollectionInterface::class);
|
||||||
$query = $this->createMock(QueryInterface::class);
|
$query = $this->createMock(QueryInterface::class);
|
||||||
$query
|
$query
|
||||||
|
@ -18,6 +18,7 @@ use Symfony\Component\Lock\Exception\LockConflictedException;
|
|||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\Lock;
|
use Symfony\Component\Lock\Lock;
|
||||||
use Symfony\Component\Lock\PersistingStoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
|
use Symfony\Component\Lock\StoreInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
@ -56,7 +57,7 @@ class LockTest extends TestCase
|
|||||||
public function testPassingOldStoreInterface()
|
public function testPassingOldStoreInterface()
|
||||||
{
|
{
|
||||||
$key = new Key(uniqid(__METHOD__, true));
|
$key = new Key(uniqid(__METHOD__, true));
|
||||||
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
|
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
|
||||||
$lock = new Lock($key, $store);
|
$lock = new Lock($key, $store);
|
||||||
|
|
||||||
$store
|
$store
|
||||||
|
@ -17,6 +17,7 @@ use Symfony\Component\Mailer\Messenger\SendEmailMessage;
|
|||||||
use Symfony\Component\Mailer\Transport\TransportInterface;
|
use Symfony\Component\Mailer\Transport\TransportInterface;
|
||||||
use Symfony\Component\Messenger\MessageBusInterface;
|
use Symfony\Component\Messenger\MessageBusInterface;
|
||||||
use Symfony\Component\Mime\RawMessage;
|
use Symfony\Component\Mime\RawMessage;
|
||||||
|
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
@ -25,8 +26,9 @@ class Mailer implements MailerInterface
|
|||||||
{
|
{
|
||||||
private $transport;
|
private $transport;
|
||||||
private $bus;
|
private $bus;
|
||||||
|
private $dispatcher;
|
||||||
|
|
||||||
public function __construct(TransportInterface $transport, MessageBusInterface $bus = null)
|
public function __construct(TransportInterface $transport, MessageBusInterface $bus = null, EventDispatcherInterface $dispatcher = null)
|
||||||
{
|
{
|
||||||
$this->transport = $transport;
|
$this->transport = $transport;
|
||||||
$this->bus = $bus;
|
$this->bus = $bus;
|
||||||
@ -40,6 +42,7 @@ class Mailer implements MailerInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (null !== $this->dispatcher) {
|
||||||
$message = clone $message;
|
$message = clone $message;
|
||||||
if (null !== $envelope) {
|
if (null !== $envelope) {
|
||||||
$envelope = clone $envelope;
|
$envelope = clone $envelope;
|
||||||
@ -52,6 +55,7 @@ class Mailer implements MailerInterface
|
|||||||
}
|
}
|
||||||
$event = new MessageEvent($message, $envelope, $this->transport->getName());
|
$event = new MessageEvent($message, $envelope, $this->transport->getName());
|
||||||
$this->dispatcher->dispatch($event);
|
$this->dispatcher->dispatch($event);
|
||||||
|
}
|
||||||
|
|
||||||
$this->bus->dispatch(new SendEmailMessage($message, $envelope));
|
$this->bus->dispatch(new SendEmailMessage($message, $envelope));
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ class ConsumeMessagesCommand extends Command
|
|||||||
new InputOption('memory-limit', 'm', InputOption::VALUE_REQUIRED, 'The memory limit the worker can consume'),
|
new InputOption('memory-limit', 'm', InputOption::VALUE_REQUIRED, 'The memory limit the worker can consume'),
|
||||||
new InputOption('time-limit', 't', InputOption::VALUE_REQUIRED, 'The time limit in seconds the worker can run'),
|
new InputOption('time-limit', 't', InputOption::VALUE_REQUIRED, 'The time limit in seconds the worker can run'),
|
||||||
new InputOption('sleep', null, InputOption::VALUE_REQUIRED, 'Seconds to sleep before asking for new messages after no messages were found', 1),
|
new InputOption('sleep', null, InputOption::VALUE_REQUIRED, 'Seconds to sleep before asking for new messages after no messages were found', 1),
|
||||||
new InputOption('bus', 'b', InputOption::VALUE_REQUIRED, 'Name of the bus to which received messages should be dispatched (if not passed, bus is determined automatically.'),
|
new InputOption('bus', 'b', InputOption::VALUE_REQUIRED, 'Name of the bus to which received messages should be dispatched (if not passed, bus is determined automatically)'),
|
||||||
])
|
])
|
||||||
->setDescription('Consumes messages')
|
->setDescription('Consumes messages')
|
||||||
->setHelp(<<<'EOF'
|
->setHelp(<<<'EOF'
|
||||||
|
@ -36,6 +36,9 @@ CHANGELOG
|
|||||||
* Deprecated class `LdapUserProvider`, use `Symfony\Component\Ldap\Security\LdapUserProvider` instead
|
* Deprecated class `LdapUserProvider`, use `Symfony\Component\Ldap\Security\LdapUserProvider` instead
|
||||||
* Added method `needsRehash()` to `PasswordEncoderInterface` and `UserPasswordEncoderInterface`
|
* Added method `needsRehash()` to `PasswordEncoderInterface` and `UserPasswordEncoderInterface`
|
||||||
* Added `MigratingPasswordEncoder`
|
* Added `MigratingPasswordEncoder`
|
||||||
|
* Added and implemented `PasswordUpgraderInterface`, for opportunistic password migrations
|
||||||
|
* Added `Guard\PasswordAuthenticatedInterface`, an optional interface
|
||||||
|
for "guard" authenticators that deal with user passwords
|
||||||
|
|
||||||
4.3.0
|
4.3.0
|
||||||
-----
|
-----
|
||||||
|
@ -16,6 +16,7 @@ use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
|
|||||||
use Symfony\Component\Security\Core\Exception\AuthenticationServiceException;
|
use Symfony\Component\Security\Core\Exception\AuthenticationServiceException;
|
||||||
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
||||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
@ -54,9 +55,15 @@ class DaoAuthenticationProvider extends UserAuthenticationProvider
|
|||||||
throw new BadCredentialsException('The presented password cannot be empty.');
|
throw new BadCredentialsException('The presented password cannot be empty.');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->encoderFactory->getEncoder($user)->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) {
|
$encoder = $this->encoderFactory->getEncoder($user);
|
||||||
|
|
||||||
|
if (!$encoder->isPasswordValid($user->getPassword(), $presentedPassword, $user->getSalt())) {
|
||||||
throw new BadCredentialsException('The presented password is invalid.');
|
throw new BadCredentialsException('The presented password is invalid.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->userProvider instanceof PasswordUpgraderInterface && method_exists($encoder, 'needsRehash') && $encoder->needsRehash($user->getPassword())) {
|
||||||
|
$this->userProvider->upgradePassword($user, $encoder->encodePassword($presentedPassword, $user->getSalt()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,11 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider;
|
use Symfony\Component\Security\Core\Authentication\Provider\DaoAuthenticationProvider;
|
||||||
use Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder;
|
use Symfony\Component\Security\Core\Encoder\PlaintextPasswordEncoder;
|
||||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||||
|
use Symfony\Component\Security\Core\Tests\Encoder\TestPasswordEncoderInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\User;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
|
|
||||||
class DaoAuthenticationProviderTest extends TestCase
|
class DaoAuthenticationProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -240,6 +244,44 @@ class DaoAuthenticationProviderTest extends TestCase
|
|||||||
$method->invoke($provider, new TestUser(), $token);
|
$method->invoke($provider, new TestUser(), $token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPasswordUpgrades()
|
||||||
|
{
|
||||||
|
$user = new User('user', 'pwd');
|
||||||
|
|
||||||
|
$encoder = $this->getMockBuilder(TestPasswordEncoderInterface::class)->getMock();
|
||||||
|
$encoder->expects($this->once())
|
||||||
|
->method('isPasswordValid')
|
||||||
|
->willReturn(true)
|
||||||
|
;
|
||||||
|
$encoder->expects($this->once())
|
||||||
|
->method('encodePassword')
|
||||||
|
->willReturn('foobar')
|
||||||
|
;
|
||||||
|
$encoder->expects($this->once())
|
||||||
|
->method('needsRehash')
|
||||||
|
->willReturn(true)
|
||||||
|
;
|
||||||
|
|
||||||
|
$provider = $this->getProvider(null, null, $encoder);
|
||||||
|
|
||||||
|
$userProvider = ((array) $provider)[sprintf("\0%s\0userProvider", DaoAuthenticationProvider::class)];
|
||||||
|
$userProvider->expects($this->once())
|
||||||
|
->method('upgradePassword')
|
||||||
|
->with($user, 'foobar')
|
||||||
|
;
|
||||||
|
|
||||||
|
$method = new \ReflectionMethod($provider, 'checkAuthentication');
|
||||||
|
$method->setAccessible(true);
|
||||||
|
|
||||||
|
$token = $this->getSupportedToken();
|
||||||
|
$token->expects($this->once())
|
||||||
|
->method('getCredentials')
|
||||||
|
->willReturn('foo')
|
||||||
|
;
|
||||||
|
|
||||||
|
$method->invoke($provider, $user, $token);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getSupportedToken()
|
protected function getSupportedToken()
|
||||||
{
|
{
|
||||||
$mock = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken')->setMethods(['getCredentials', 'getUser', 'getProviderKey'])->disableOriginalConstructor()->getMock();
|
$mock = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\Authentication\\Token\\UsernamePasswordToken')->setMethods(['getCredentials', 'getUser', 'getProviderKey'])->disableOriginalConstructor()->getMock();
|
||||||
@ -254,7 +296,7 @@ class DaoAuthenticationProviderTest extends TestCase
|
|||||||
|
|
||||||
protected function getProvider($user = null, $userChecker = null, $passwordEncoder = null)
|
protected function getProvider($user = null, $userChecker = null, $passwordEncoder = null)
|
||||||
{
|
{
|
||||||
$userProvider = $this->getMockBuilder('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface')->getMock();
|
$userProvider = $this->getMockBuilder([UserProviderInterface::class, PasswordUpgraderInterface::class])->getMock();
|
||||||
if (null !== $user) {
|
if (null !== $user) {
|
||||||
$userProvider->expects($this->once())
|
$userProvider->expects($this->once())
|
||||||
->method('loadUserByUsername')
|
->method('loadUserByUsername')
|
||||||
|
@ -14,7 +14,6 @@ namespace Symfony\Component\Security\Core\Tests\Encoder;
|
|||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Symfony\Component\Security\Core\Encoder\MigratingPasswordEncoder;
|
use Symfony\Component\Security\Core\Encoder\MigratingPasswordEncoder;
|
||||||
use Symfony\Component\Security\Core\Encoder\NativePasswordEncoder;
|
use Symfony\Component\Security\Core\Encoder\NativePasswordEncoder;
|
||||||
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
|
|
||||||
|
|
||||||
class MigratingPasswordEncoderTest extends TestCase
|
class MigratingPasswordEncoderTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -66,8 +65,3 @@ class MigratingPasswordEncoderTest extends TestCase
|
|||||||
$this->assertTrue($encoder->isPasswordValid('abc', 'foo', 'salt'));
|
$this->assertTrue($encoder->isPasswordValid('abc', 'foo', 'salt'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface TestPasswordEncoderInterface extends PasswordEncoderInterface
|
|
||||||
{
|
|
||||||
public function needsRehash(string $encoded): bool;
|
|
||||||
}
|
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
<?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 Symfony\Component\Security\Core\Tests\Encoder;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface;
|
||||||
|
|
||||||
|
interface TestPasswordEncoderInterface extends PasswordEncoderInterface
|
||||||
|
{
|
||||||
|
public function needsRehash(string $encoded): bool;
|
||||||
|
}
|
@ -15,6 +15,8 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
|
||||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||||
use Symfony\Component\Security\Core\User\ChainUserProvider;
|
use Symfony\Component\Security\Core\User\ChainUserProvider;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\User;
|
||||||
|
|
||||||
class ChainUserProviderTest extends TestCase
|
class ChainUserProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -188,6 +190,28 @@ class ChainUserProviderTest extends TestCase
|
|||||||
$this->assertSame($account, $provider->refreshUser($this->getAccount()));
|
$this->assertSame($account, $provider->refreshUser($this->getAccount()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPasswordUpgrades()
|
||||||
|
{
|
||||||
|
$user = new User('user', 'pwd');
|
||||||
|
|
||||||
|
$provider1 = $this->getMockBuilder(PasswordUpgraderInterface::class)->getMock();
|
||||||
|
$provider1
|
||||||
|
->expects($this->once())
|
||||||
|
->method('upgradePassword')
|
||||||
|
->willThrowException(new UnsupportedUserException('unsupported'))
|
||||||
|
;
|
||||||
|
|
||||||
|
$provider2 = $this->getMockBuilder(PasswordUpgraderInterface::class)->getMock();
|
||||||
|
$provider2
|
||||||
|
->expects($this->once())
|
||||||
|
->method('upgradePassword')
|
||||||
|
->with($user, 'foobar')
|
||||||
|
;
|
||||||
|
|
||||||
|
$provider = new ChainUserProvider([$provider1, $provider2]);
|
||||||
|
$provider->upgradePassword($user, 'foobar');
|
||||||
|
}
|
||||||
|
|
||||||
protected function getAccount()
|
protected function getAccount()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
|
return $this->getMockBuilder('Symfony\Component\Security\Core\User\UserInterface')->getMock();
|
||||||
|
@ -22,7 +22,7 @@ use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
|||||||
*
|
*
|
||||||
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
|
||||||
*/
|
*/
|
||||||
class ChainUserProvider implements UserProviderInterface
|
class ChainUserProvider implements UserProviderInterface, PasswordUpgraderInterface
|
||||||
{
|
{
|
||||||
private $providers;
|
private $providers;
|
||||||
|
|
||||||
@ -104,4 +104,20 @@ class ChainUserProvider implements UserProviderInterface
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void
|
||||||
|
{
|
||||||
|
foreach ($this->providers as $provider) {
|
||||||
|
if ($provider instanceof PasswordUpgraderInterface) {
|
||||||
|
try {
|
||||||
|
$provider->upgradePassword($user, $newEncodedPassword);
|
||||||
|
} catch (UnsupportedUserException $e) {
|
||||||
|
// ignore: password upgrades are opportunistic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
<?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 Symfony\Component\Security\Core\User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nicolas Grekas <p@tchwork.com>
|
||||||
|
*/
|
||||||
|
interface PasswordUpgraderInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Upgrades the encoded password of a user, typically for using a better hash algorithm.
|
||||||
|
*
|
||||||
|
* This method should persist the new password in the user storage and update the $user object accordingly.
|
||||||
|
* Because you don't want your users not being able to log in, this method should be opportunistic:
|
||||||
|
* it's fine if it does nothing or if it fails without throwing any exception.
|
||||||
|
*/
|
||||||
|
public function upgradePassword(UserInterface $user, string $newEncodedPassword): void;
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
<?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 Symfony\Component\Security\Guard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An optional interface for "guard" authenticators that deal with user passwords.
|
||||||
|
*/
|
||||||
|
interface PasswordAuthenticatedInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the clear-text password contained in credentials if any.
|
||||||
|
*
|
||||||
|
* @param mixed The user credentials
|
||||||
|
*/
|
||||||
|
public function getPassword($credentials): ?string;
|
||||||
|
}
|
@ -13,14 +13,17 @@ namespace Symfony\Component\Security\Guard\Provider;
|
|||||||
|
|
||||||
use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface;
|
use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface;
|
||||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||||
|
use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface;
|
||||||
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
use Symfony\Component\Security\Core\Exception\AuthenticationException;
|
||||||
use Symfony\Component\Security\Core\Exception\AuthenticationExpiredException;
|
use Symfony\Component\Security\Core\Exception\AuthenticationExpiredException;
|
||||||
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
use Symfony\Component\Security\Core\Exception\BadCredentialsException;
|
||||||
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||||
|
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserInterface;
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
use Symfony\Component\Security\Guard\AuthenticatorInterface;
|
||||||
|
use Symfony\Component\Security\Guard\PasswordAuthenticatedInterface;
|
||||||
use Symfony\Component\Security\Guard\Token\GuardTokenInterface;
|
use Symfony\Component\Security\Guard\Token\GuardTokenInterface;
|
||||||
use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken;
|
use Symfony\Component\Security\Guard\Token\PreAuthenticationGuardToken;
|
||||||
|
|
||||||
@ -39,19 +42,19 @@ class GuardAuthenticationProvider implements AuthenticationProviderInterface
|
|||||||
private $userProvider;
|
private $userProvider;
|
||||||
private $providerKey;
|
private $providerKey;
|
||||||
private $userChecker;
|
private $userChecker;
|
||||||
|
private $passwordEncoder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param iterable|AuthenticatorInterface[] $guardAuthenticators The authenticators, with keys that match what's passed to GuardAuthenticationListener
|
* @param iterable|AuthenticatorInterface[] $guardAuthenticators The authenticators, with keys that match what's passed to GuardAuthenticationListener
|
||||||
* @param UserProviderInterface $userProvider The user provider
|
|
||||||
* @param string $providerKey The provider (i.e. firewall) key
|
* @param string $providerKey The provider (i.e. firewall) key
|
||||||
* @param UserCheckerInterface $userChecker
|
|
||||||
*/
|
*/
|
||||||
public function __construct($guardAuthenticators, UserProviderInterface $userProvider, string $providerKey, UserCheckerInterface $userChecker)
|
public function __construct($guardAuthenticators, UserProviderInterface $userProvider, string $providerKey, UserCheckerInterface $userChecker, UserPasswordEncoderInterface $passwordEncoder = null)
|
||||||
{
|
{
|
||||||
$this->guardAuthenticators = $guardAuthenticators;
|
$this->guardAuthenticators = $guardAuthenticators;
|
||||||
$this->userProvider = $userProvider;
|
$this->userProvider = $userProvider;
|
||||||
$this->providerKey = $providerKey;
|
$this->providerKey = $providerKey;
|
||||||
$this->userChecker = $userChecker;
|
$this->userChecker = $userChecker;
|
||||||
|
$this->passwordEncoder = $passwordEncoder;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -113,6 +116,9 @@ class GuardAuthenticationProvider implements AuthenticationProviderInterface
|
|||||||
if (true !== $guardAuthenticator->checkCredentials($token->getCredentials(), $user)) {
|
if (true !== $guardAuthenticator->checkCredentials($token->getCredentials(), $user)) {
|
||||||
throw new BadCredentialsException(sprintf('Authentication failed because %s::checkCredentials() did not return true.', \get_class($guardAuthenticator)));
|
throw new BadCredentialsException(sprintf('Authentication failed because %s::checkCredentials() did not return true.', \get_class($guardAuthenticator)));
|
||||||
}
|
}
|
||||||
|
if ($this->userProvider instanceof PasswordUpgraderInterface && $guardAuthenticator instanceof PasswordAuthenticatedInterface && null !== $this->passwordEncoder && (null !== $password = $guardAuthenticator->getPassword($token->getCredentials())) && method_exists($this->passwordEncoder, 'needsRehash') && $this->passwordEncoder->needsRehash($user)) {
|
||||||
|
$this->userProvider->upgradePassword($user, $this->passwordEncoder->encodePassword($user, $password));
|
||||||
|
}
|
||||||
$this->userChecker->checkPostAuth($user);
|
$this->userChecker->checkPostAuth($user);
|
||||||
|
|
||||||
// turn the UserInterface into a TokenInterface
|
// turn the UserInterface into a TokenInterface
|
||||||
|
@ -91,6 +91,8 @@ abstract class AbstractCloner implements ClonerInterface
|
|||||||
|
|
||||||
'ProxyManager\Proxy\ProxyInterface' => ['Symfony\Component\VarDumper\Caster\ProxyManagerCaster', 'castProxy'],
|
'ProxyManager\Proxy\ProxyInterface' => ['Symfony\Component\VarDumper\Caster\ProxyManagerCaster', 'castProxy'],
|
||||||
'PHPUnit_Framework_MockObject_MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
'PHPUnit_Framework_MockObject_MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||||
|
'PHPUnit\Framework\MockObject\MockObject' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||||
|
'PHPUnit\Framework\MockObject\Stub' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||||
'Prophecy\Prophecy\ProphecySubjectInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
'Prophecy\Prophecy\ProphecySubjectInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||||
'Mockery\MockInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
'Mockery\MockInterface' => ['Symfony\Component\VarDumper\Caster\StubCaster', 'cutInternals'],
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@ class Inline
|
|||||||
private static $objectSupport = false;
|
private static $objectSupport = false;
|
||||||
private static $objectForMap = false;
|
private static $objectForMap = false;
|
||||||
private static $constantSupport = false;
|
private static $constantSupport = false;
|
||||||
private static $nullAsTilde = false;
|
|
||||||
|
|
||||||
public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null)
|
public static function initialize(int $flags, int $parsedLineNumber = null, string $parsedFilename = null)
|
||||||
{
|
{
|
||||||
@ -41,7 +40,6 @@ class Inline
|
|||||||
self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
|
self::$objectSupport = (bool) (Yaml::PARSE_OBJECT & $flags);
|
||||||
self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags);
|
self::$objectForMap = (bool) (Yaml::PARSE_OBJECT_FOR_MAP & $flags);
|
||||||
self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags);
|
self::$constantSupport = (bool) (Yaml::PARSE_CONSTANT & $flags);
|
||||||
self::$nullAsTilde = (bool) (Yaml::DUMP_NULL_AS_TILDE & $flags);
|
|
||||||
self::$parsedFilename = $parsedFilename;
|
self::$parsedFilename = $parsedFilename;
|
||||||
|
|
||||||
if (null !== $parsedLineNumber) {
|
if (null !== $parsedLineNumber) {
|
||||||
|
@ -580,7 +580,7 @@ abstract class HttpClientTestCase extends TestCase
|
|||||||
|
|
||||||
$response = null;
|
$response = null;
|
||||||
$this->expectException(TransportExceptionInterface::class);
|
$this->expectException(TransportExceptionInterface::class);
|
||||||
$client->request('GET', 'http://symfony.com:8057/', ['timeout' => 3]);
|
$client->request('GET', 'http://symfony.com:8057/', ['timeout' => 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testTimeoutOnAccess()
|
public function testTimeoutOnAccess()
|
||||||
@ -643,7 +643,6 @@ abstract class HttpClientTestCase extends TestCase
|
|||||||
{
|
{
|
||||||
$client = $this->getHttpClient(__FUNCTION__);
|
$client = $this->getHttpClient(__FUNCTION__);
|
||||||
|
|
||||||
$downloaded = 0;
|
|
||||||
$start = microtime(true);
|
$start = microtime(true);
|
||||||
$client->request('GET', 'http://localhost:8057/timeout-long');
|
$client->request('GET', 'http://localhost:8057/timeout-long');
|
||||||
$client = null;
|
$client = null;
|
||||||
|
Reference in New Issue
Block a user