Merge branch '3.4' into 4.3
* 3.4: Cleanup tests [Finder] Prevent unintentional file locks in Windows [DomCrawler] Fix FileFormField PHPDoc Fix #33395 PHP 5.3 compatibility
This commit is contained in:
commit
d423b0f473
@ -322,7 +322,7 @@ class DeprecationErrorHandler
|
||||
private static function getPhpUnitErrorHandler()
|
||||
{
|
||||
if (!isset(self::$isAtLeastPhpUnit83)) {
|
||||
self::$isAtLeastPhpUnit83 = class_exists(ErrorHandler::class) && method_exists(ErrorHandler::class, '__invoke');
|
||||
self::$isAtLeastPhpUnit83 = class_exists('PHPUnit\Util\ErrorHandler') && method_exists('PHPUnit\Util\ErrorHandler', '__invoke');
|
||||
}
|
||||
if (!self::$isAtLeastPhpUnit83) {
|
||||
return (class_exists('PHPUnit_Util_ErrorHandler', false) ? 'PHPUnit_Util_' : 'PHPUnit\Util\\').'ErrorHandler::handleError';
|
||||
|
@ -113,7 +113,7 @@ class ChoiceFormField extends FormField
|
||||
/**
|
||||
* Sets the value of the field.
|
||||
*
|
||||
* @param string|array $value The value of the field
|
||||
* @param string|array|bool $value The value of the field
|
||||
*
|
||||
* @throws \InvalidArgumentException When value type provided is not correct
|
||||
*/
|
||||
|
@ -48,7 +48,7 @@ class FileFormField extends FormField
|
||||
/**
|
||||
* Sets the value of the field.
|
||||
*
|
||||
* @param string $value The value of the field
|
||||
* @param string|null $value The value of the field
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ abstract class FormField
|
||||
/**
|
||||
* Sets the value of the field.
|
||||
*
|
||||
* @param string $value The value of the field
|
||||
* @param string|array|bool|null $value The value of the field
|
||||
*/
|
||||
public function setValue($value)
|
||||
{
|
||||
|
@ -41,15 +41,15 @@ class SortableIterator implements \IteratorAggregate
|
||||
$order = $reverseOrder ? -1 : 1;
|
||||
|
||||
if (self::SORT_BY_NAME === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_NAME_NATURAL === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
return $order * strnatcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_TYPE === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
if ($a->isDir() && $b->isFile()) {
|
||||
return -$order;
|
||||
} elseif ($a->isFile() && $b->isDir()) {
|
||||
@ -59,15 +59,15 @@ class SortableIterator implements \IteratorAggregate
|
||||
return $order * strcmp($a->getRealPath() ?: $a->getPathname(), $b->getRealPath() ?: $b->getPathname());
|
||||
};
|
||||
} elseif (self::SORT_BY_ACCESSED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
return $order * ($a->getATime() - $b->getATime());
|
||||
};
|
||||
} elseif (self::SORT_BY_CHANGED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
return $order * ($a->getCTime() - $b->getCTime());
|
||||
};
|
||||
} elseif (self::SORT_BY_MODIFIED_TIME === $sort) {
|
||||
$this->sort = function ($a, $b) use ($order) {
|
||||
$this->sort = static function ($a, $b) use ($order) {
|
||||
return $order * ($a->getMTime() - $b->getMTime());
|
||||
};
|
||||
} elseif (self::SORT_BY_NONE === $sort) {
|
||||
|
@ -343,7 +343,12 @@ abstract class Kernel implements KernelInterface, RebootableInterface, Terminabl
|
||||
{
|
||||
if (null === $this->projectDir) {
|
||||
$r = new \ReflectionObject($this);
|
||||
$dir = $rootDir = \dirname($r->getFileName());
|
||||
|
||||
if (!file_exists($dir = $r->getFileName())) {
|
||||
throw new \LogicException(sprintf('Cannot auto-detect project dir for kernel of class "%s".', $r->name));
|
||||
}
|
||||
|
||||
$dir = $rootDir = \dirname($dir);
|
||||
while (!file_exists($dir.'/composer.json')) {
|
||||
if ($dir === \dirname($dir)) {
|
||||
return $this->projectDir = $rootDir;
|
||||
|
@ -35,13 +35,8 @@ class KernelForTest extends Kernel
|
||||
return $this->booted;
|
||||
}
|
||||
|
||||
public function getCacheDir()
|
||||
public function getProjectDir()
|
||||
{
|
||||
return $this->getProjectDir().'/Tests/Fixtures/cache.'.$this->environment;
|
||||
}
|
||||
|
||||
public function getLogDir()
|
||||
{
|
||||
return $this->getProjectDir().'/Tests/Fixtures/logs';
|
||||
return __DIR__;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\ResettableServicePass;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\ServicesResetter;
|
||||
use Symfony\Component\HttpKernel\HttpKernel;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\HttpKernel\Tests\Fixtures\KernelForOverrideName;
|
||||
@ -130,7 +129,7 @@ class KernelTest extends TestCase
|
||||
public function testBootSetsTheBootedFlagToTrue()
|
||||
{
|
||||
// use test kernel to access isBooted()
|
||||
$kernel = $this->getKernelForTest(['initializeBundles', 'initializeContainer']);
|
||||
$kernel = $this->getKernel(['initializeBundles', 'initializeContainer']);
|
||||
$kernel->boot();
|
||||
|
||||
$this->assertTrue($kernel->isBooted());
|
||||
@ -597,7 +596,7 @@ EOF;
|
||||
*/
|
||||
public function testKernelStartTimeIsResetWhileBootingAlreadyBootedKernel()
|
||||
{
|
||||
$kernel = $this->getKernelForTest(['initializeBundles'], true);
|
||||
$kernel = $this->getKernel(['initializeBundles'], [], true);
|
||||
$kernel->boot();
|
||||
$preReBoot = $kernel->getStartTime();
|
||||
|
||||
@ -655,15 +654,15 @@ EOF;
|
||||
*
|
||||
* @return Kernel
|
||||
*/
|
||||
protected function getKernel(array $methods = [], array $bundles = [])
|
||||
protected function getKernel(array $methods = [], array $bundles = [], $debug = false)
|
||||
{
|
||||
$methods[] = 'registerBundles';
|
||||
|
||||
$kernel = $this
|
||||
->getMockBuilder('Symfony\Component\HttpKernel\Kernel')
|
||||
->getMockBuilder(KernelForTest::class)
|
||||
->setMethods($methods)
|
||||
->setConstructorArgs(['test', false])
|
||||
->getMockForAbstractClass()
|
||||
->setConstructorArgs(['test', $debug])
|
||||
->getMock()
|
||||
;
|
||||
$kernel->expects($this->any())
|
||||
->method('registerBundles')
|
||||
@ -675,19 +674,6 @@ EOF;
|
||||
|
||||
return $kernel;
|
||||
}
|
||||
|
||||
protected function getKernelForTest(array $methods = [], $debug = false)
|
||||
{
|
||||
$kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\Tests\Fixtures\KernelForTest')
|
||||
->setConstructorArgs(['test', $debug])
|
||||
->setMethods($methods)
|
||||
->getMock();
|
||||
$p = new \ReflectionProperty($kernel, 'rootDir');
|
||||
$p->setAccessible(true);
|
||||
$p->setValue($kernel, __DIR__.'/Fixtures');
|
||||
|
||||
return $kernel;
|
||||
}
|
||||
}
|
||||
|
||||
class TestKernel implements HttpKernelInterface
|
||||
@ -702,6 +688,11 @@ class TestKernel implements HttpKernelInterface
|
||||
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
|
||||
{
|
||||
}
|
||||
|
||||
public function getProjectDir()
|
||||
{
|
||||
return __DIR__.'/Fixtures';
|
||||
}
|
||||
}
|
||||
|
||||
class CustomProjectDirKernel extends Kernel
|
||||
|
@ -32,6 +32,10 @@ trait BlockingStoreTestTrait
|
||||
*
|
||||
* This test is time sensible: the $clockDelay could be adjust.
|
||||
*
|
||||
* It also fails when run with the global ./phpunit test suite.
|
||||
*
|
||||
* @group transient
|
||||
*
|
||||
* @requires extension pcntl
|
||||
* @requires extension posix
|
||||
* @requires function pcntl_sigwaitinfo
|
||||
|
@ -84,23 +84,6 @@ class ChainEncoderTest extends TestCase
|
||||
$this->assertTrue($this->chainEncoder->needsNormalization(self::FORMAT_2));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider booleanProvider
|
||||
*/
|
||||
public function testNeedsNormalizationChainNormalizationAware($bool)
|
||||
{
|
||||
$chainEncoder = $this
|
||||
->getMockBuilder('Symfony\Component\Serializer\Tests\Encoder\ChainNormalizationAwareEncoder')
|
||||
->getMock();
|
||||
|
||||
$chainEncoder->method('supportsEncoding')->willReturn(true);
|
||||
$chainEncoder->method('needsNormalization')->willReturn($bool);
|
||||
|
||||
$sut = new ChainEncoder([$chainEncoder]);
|
||||
|
||||
$this->assertEquals($bool, $sut->needsNormalization(self::FORMAT_1));
|
||||
}
|
||||
|
||||
public function testNeedsNormalizationNormalizationAware()
|
||||
{
|
||||
$encoder = new NormalizationAwareEncoder();
|
||||
@ -108,18 +91,6 @@ class ChainEncoderTest extends TestCase
|
||||
|
||||
$this->assertFalse($sut->needsNormalization(self::FORMAT_1));
|
||||
}
|
||||
|
||||
public function booleanProvider()
|
||||
{
|
||||
return [
|
||||
[true],
|
||||
[false],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
class ChainNormalizationAwareEncoder extends ChainEncoder implements NormalizationAwareInterface
|
||||
{
|
||||
}
|
||||
|
||||
class NormalizationAwareEncoder implements EncoderInterface, NormalizationAwareInterface
|
||||
|
Reference in New Issue
Block a user