Skip to content

Commit c48eee8

Browse files
Merge branch '3.4' into 4.0
* 3.4: (22 commits) [appveyor] use PHP 7.1 to run composer [HttpKernel] Don't clean legacy containers that are still loaded [VarDumper] Fix HtmlDumper classes match Make the simple auth provider the same as in Symfony 2.7. [PhpUnitBridge] silence wget fix merge [Security] guardAuthenticationProvider::authenticate cannot return null according to interface specification [PhpUnitBridge] Fix #26994 [VarDumper] Remove decoration from actual output in tests [PropertyInfo] Minor cleanup and perf improvement [Bridge/Doctrine] fix count() notice on PHP 7.2 [Security] Skip user checks if not implementing UserInterface [DI] Add check of internal type to ContainerBuilder::getReflectionClass [HttpFoundation] Add HTTP_EARLY_HINTS const [DoctrineBridge] Improve exception message at `IdReader::getIdValue()` Add type hints fixed CS Use new PHP7.2 functions in hasColorSupport [VarDumper] Fix dumping of SplObjectStorage [HttpFoundation] Add functional tests for Response::sendHeaders() ...
2 parents 6d9d329 + e1ca89b commit c48eee8

File tree

50 files changed

+646
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+646
-242
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ install:
4545
- copy /Y .composer\* %APPDATA%\Composer\
4646
- php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
4747
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
48-
- php -dmemory_limit=-1 composer.phar update --no-progress --no-suggest --ansi
48+
- php composer.phar update --no-progress --no-suggest --ansi
4949
- php phpunit install
5050

5151
test_script:

src/Symfony/Bridge/Doctrine/Form/ChoiceList/IdReader.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,7 @@ public function getIdValue($object)
9595
}
9696

9797
if (!$this->om->contains($object)) {
98-
throw new RuntimeException(
99-
'Entities passed to the choice field must be managed. Maybe '.
100-
'persist them in the entity manager?'
101-
);
98+
throw new RuntimeException(sprintf('Entity of type "%s" passed to the choice field must be managed. Maybe you forget to persist it in the entity manager?', get_class($object)));
10299
}
103100

104101
$this->om->initializeObject($object);

src/Symfony/Bridge/Doctrine/Tests/Validator/Constraints/UniqueEntityValidatorTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,34 @@ public function testEntityManagerNullObject()
630630
$this->validator->validate($entity, $constraint);
631631
}
632632

633+
public function testValidateUniquenessOnNullResult()
634+
{
635+
$repository = $this->createRepositoryMock();
636+
$repository
637+
->method('find')
638+
->will($this->returnValue(null))
639+
;
640+
641+
$this->em = $this->createEntityManagerMock($repository);
642+
$this->registry = $this->createRegistryMock($this->em);
643+
$this->validator = $this->createValidator();
644+
$this->validator->initialize($this->context);
645+
646+
$constraint = new UniqueEntity(array(
647+
'message' => 'myMessage',
648+
'fields' => array('name'),
649+
'em' => self::EM_NAME,
650+
));
651+
652+
$entity = new SingleIntIdEntity(1, null);
653+
654+
$this->em->persist($entity);
655+
$this->em->flush();
656+
657+
$this->validator->validate($entity, $constraint);
658+
$this->assertNoViolation();
659+
}
660+
633661
public function testValidateInheritanceUniqueness()
634662
{
635663
$constraint = new UniqueEntity(array(

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,15 +148,23 @@ public function validate($entity, Constraint $constraint)
148148
*/
149149
if ($result instanceof \Iterator) {
150150
$result->rewind();
151-
} elseif (is_array($result)) {
151+
if ($result instanceof \Countable && 1 < \count($result)) {
152+
$result = array($result->current(), $result->current());
153+
} else {
154+
$result = $result->current();
155+
$result = null === $result ? array() : array($result);
156+
}
157+
} elseif (\is_array($result)) {
152158
reset($result);
159+
} else {
160+
$result = null === $result ? array() : array($result);
153161
}
154162

155163
/* If no entity matched the query criteria or a single entity matched,
156164
* which is the same as the entity being validated, the criteria is
157165
* unique.
158166
*/
159-
if (0 === count($result) || (1 === count($result) && $entity === ($result instanceof \Iterator ? $result->current() : current($result)))) {
167+
if (!$result || (1 === \count($result) && current($result) === $entity)) {
160168
return;
161169
}
162170

src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,38 @@ public static function collectDeprecations($outputFile)
297297
});
298298
}
299299

300+
/**
301+
* Returns true if STDOUT is defined and supports colorization.
302+
*
303+
* Reference: Composer\XdebugHandler\Process::supportsColor
304+
* https://github.com/composer/xdebug-handler
305+
*
306+
* @return bool
307+
*/
300308
private static function hasColorSupport()
301309
{
302-
if ('\\' === DIRECTORY_SEPARATOR) {
303-
return
304-
defined('STDOUT') && function_exists('sapi_windows_vt100_support') && sapi_windows_vt100_support(STDOUT)
305-
|| '10.0.10586' === PHP_WINDOWS_VERSION_MAJOR.'.'.PHP_WINDOWS_VERSION_MINOR.'.'.PHP_WINDOWS_VERSION_BUILD
310+
if (!defined('STDOUT')) {
311+
return false;
312+
}
313+
314+
if (DIRECTORY_SEPARATOR === '\\') {
315+
return (function_exists('sapi_windows_vt100_support')
316+
&& sapi_windows_vt100_support(STDOUT))
306317
|| false !== getenv('ANSICON')
307318
|| 'ON' === getenv('ConEmuANSI')
308319
|| 'xterm' === getenv('TERM');
309320
}
310321

311-
return defined('STDOUT') && function_exists('posix_isatty') && @posix_isatty(STDOUT);
322+
if (function_exists('stream_isatty')) {
323+
return stream_isatty(STDOUT);
324+
}
325+
326+
if (function_exists('posix_isatty')) {
327+
return posix_isatty(STDOUT);
328+
}
329+
330+
$stat = fstat(STDOUT);
331+
// Check if formatted mode is S_IFCHR
332+
return $stat ? 0020000 === ($stat['mode'] & 0170000) : false;
312333
}
313334
}

src/Symfony/Bridge/PhpUnit/Legacy/Command.php renamed to src/Symfony/Bridge/PhpUnit/Legacy/CommandForV5.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
*
1717
* @internal
1818
*/
19-
class Command extends \PHPUnit_TextUI_Command
19+
class CommandForV5 extends \PHPUnit_TextUI_Command
2020
{
2121
/**
2222
* {@inheritdoc}
2323
*/
2424
protected function createRunner()
2525
{
26-
return new TestRunner($this->arguments['loader']);
26+
return new TestRunnerForV5($this->arguments['loader']);
2727
}
2828
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Legacy;
13+
14+
use PHPUnit\TextUI\Command as BaseCommand;
15+
use PHPUnit\TextUI\TestRunner as BaseRunner;
16+
use Symfony\Bridge\PhpUnit\TextUI\TestRunner;
17+
18+
/**
19+
* {@inheritdoc}
20+
*
21+
* @internal
22+
*/
23+
class CommandForV6 extends BaseCommand
24+
{
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
protected function createRunner(): BaseRunner
29+
{
30+
return new TestRunner($this->arguments['loader']);
31+
}
32+
}

src/Symfony/Bridge/PhpUnit/Legacy/TestRunner.php renamed to src/Symfony/Bridge/PhpUnit/Legacy/TestRunnerForV5.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @internal
1818
*/
19-
class TestRunner extends \PHPUnit_TextUI_TestRunner
19+
class TestRunnerForV5 extends \PHPUnit_TextUI_TestRunner
2020
{
2121
/**
2222
* {@inheritdoc}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bridge\PhpUnit\Legacy;
13+
14+
use PHPUnit\TextUI\TestRunner as BaseRunner;
15+
use Symfony\Bridge\PhpUnit\SymfonyTestsListener;
16+
17+
/**
18+
* {@inheritdoc}
19+
*
20+
* @internal
21+
*/
22+
class TestRunnerForV6 extends BaseRunner
23+
{
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
protected function handleConfiguration(array &$arguments): void
28+
{
29+
$listener = new SymfonyTestsListener();
30+
31+
parent::handleConfiguration($arguments);
32+
33+
$arguments['listeners'] = isset($arguments['listeners']) ? $arguments['listeners'] : array();
34+
35+
$registeredLocally = false;
36+
37+
foreach ($arguments['listeners'] as $registeredListener) {
38+
if ($registeredListener instanceof SymfonyTestsListener) {
39+
$registeredListener->globalListenerDisabled();
40+
$registeredLocally = true;
41+
break;
42+
}
43+
}
44+
45+
if (!$registeredLocally) {
46+
$arguments['listeners'][] = $listener;
47+
}
48+
}
49+
}

src/Symfony/Bridge/PhpUnit/TextUI/Command.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,14 @@
1111

1212
namespace Symfony\Bridge\PhpUnit\TextUI;
1313

14-
use PHPUnit\TextUI\Command as BaseCommand;
15-
1614
if (class_exists('PHPUnit_Runner_Version') && version_compare(\PHPUnit_Runner_Version::id(), '6.0.0', '<')) {
17-
class_alias('Symfony\Bridge\PhpUnit\Legacy\Command', 'Symfony\Bridge\PhpUnit\TextUI\Command');
15+
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV5', 'Symfony\Bridge\PhpUnit\TextUI\Command');
1816
} else {
19-
/**
20-
* {@inheritdoc}
21-
*
22-
* @internal
23-
*/
24-
class Command extends BaseCommand
17+
class_alias('Symfony\Bridge\PhpUnit\Legacy\CommandForV6', 'Symfony\Bridge\PhpUnit\TextUI\Command');
18+
}
19+
20+
if (false) {
21+
class Command
2522
{
26-
/**
27-
* {@inheritdoc}
28-
*/
29-
protected function createRunner()
30-
{
31-
return new TestRunner($this->arguments['loader']);
32-
}
3323
}
3424
}

0 commit comments

Comments
 (0)