Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4281501

Browse filesBrowse files
Merge branch '2.7' into 2.8
* 2.7: Fix backport [travis] Upgrade phpunit wrapper & hirak/prestissimo [Bridge\PhpUnit] Workaround old phpunit bug, no colors in weak mode, add tests [PropertyAccess] Fix isPropertyWritable not using the reflection cache [PropertyAccess] Backport fixes from 2.7 [Validator] use correct term for a property in docblock (not "option") [Routing] small refactoring for scheme requirement [PropertyAccess] Remove most ref mismatches to improve perf [Validator] EmailValidator cannot extract hostname if email contains multiple @ symbols [NumberFormatter] Fix invalid numeric literal on PHP 7 [Process] fix docblock syntax Use XML_ELEMENT_NODE in nodeType check [PropertyAccess] Reduce overhead of UnexpectedTypeException tracking [PropertyAccess] Throw an UnexpectedTypeException when the type do not match [FrameworkBundle] Add tests for the Controller class [FrameworkBundle] Add tests for the Controller class [Process] getIncrementalOutput should work without calling getOutput Conflicts: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php src/Symfony/Bridge/PhpUnit/TextUI/Command.php src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php
2 parents dd7e05d + 2b3f426 commit 4281501
Copy full SHA for 4281501

File tree

Expand file treeCollapse file tree

26 files changed

+778
-322
lines changed
Filter options
Expand file treeCollapse file tree

26 files changed

+778
-322
lines changed

‎.composer/composer.lock

Copy file name to clipboardExpand all lines: .composer/composer.lock
+5-5Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.composer/config.json

Copy file name to clipboard
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"config": {
3+
"preferred-install": {
4+
"*": "dist"
5+
}
6+
}
7+
}

‎.travis.yml

Copy file name to clipboardExpand all lines: .travis.yml
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ before_install:
5151
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then echo extension = ldap.so >> $INI_FILE; fi;
5252
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then phpenv config-rm xdebug.ini; fi;
5353
- if [[ $deps != skip ]]; then composer self-update; fi;
54-
- if [[ $deps != skip && $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer/* ~/.composer/; composer global install --prefer-dist; fi;
54+
- if [[ $deps != skip && $TRAVIS_REPO_SLUG = symfony/symfony ]]; then cp .composer/* ~/.composer/; composer global install; fi;
5555
- if [[ $deps != skip ]]; then ./phpunit install; fi;
5656
- export PHPUNIT=$(readlink -f ./phpunit)
5757

@@ -61,17 +61,18 @@ install:
6161
- if [[ $deps != skip && $deps ]]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $COMPONENTS; fi;
6262
# For the master branch when deps=high, the version before master is checked out and tested with the locally patched components
6363
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then SYMFONY_VERSION=$(git ls-remote --heads | grep -o '/[1-9].*' | tail -n 1 | sed s/.//); else SYMFONY_VERSION=$(cat composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9.]*'); fi;
64-
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); fi;
64+
- if [[ $deps = high && $TRAVIS_BRANCH = master ]]; then git fetch origin $SYMFONY_VERSION; git checkout -m FETCH_HEAD; COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n'); ./phpunit install; fi;
6565
# Legacy tests are skipped when deps=high and when the current branch version has not the same major version number than the next one
6666
- if [[ $deps = high && ${SYMFONY_VERSION%.*} != $(git show $(git ls-remote --heads | grep -FA1 /$SYMFONY_VERSION | tail -n 1):composer.json | grep '^ *"dev-master". *"[1-9]' | grep -o '[0-9]*' | head -n 1) ]]; then LEGACY=,legacy; fi;
6767
- export COMPOSER_ROOT_VERSION=$SYMFONY_VERSION.x-dev;
68-
- if [[ ! $deps ]]; then composer update --prefer-dist; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi;
68+
- if [[ ! $deps ]]; then composer update; else export SYMFONY_DEPRECATIONS_HELPER=weak; fi;
69+
- if [[ $TRAVIS_BRANCH = master ]]; then export SYMFONY_PHPUNIT_OVERLOAD=1; fi;
6970
- if [[ $TRAVIS_PHP_VERSION != hhvm ]]; then php -i; else hhvm --php -r 'print_r($_SERVER);print_r(ini_get_all());'; fi;
7071

7172
script:
7273
- if [[ ! $deps ]]; then echo "$COMPONENTS" | parallel --gnu '$PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
7374
- if [[ ! $deps ]]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi;
7475
- if [[ ! $deps && $TRAVIS_PHP_VERSION = ${MIN_PHP%.*} ]]; then echo -e "1\\n0" | xargs -I{} sh -c 'echo "\\nPHP --enable-sigchild enhanced={}" && ENHANCE_SIGCHLD={} php-$MIN_PHP/sapi/cli/php .phpunit/phpunit-4.8/phpunit --colors=always src/Symfony/Component/Process/'; fi;
75-
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --prefer-dist; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi;
76-
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --prefer-dist --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
76+
- if [[ $deps = high ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update; $PHPUNIT --exclude-group tty,benchmark,intl-data'$LEGACY; fi;
77+
- if [[ $deps = low ]]; then echo "$COMPONENTS" | parallel --gnu -j10% 'cd {}; composer update --prefer-lowest --prefer-stable; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
7778
- if [[ $deps = skip ]]; then echo This matrix line is skipped for pull requests.; fi;

‎appveyor.yml

Copy file name to clipboardExpand all lines: appveyor.yml
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ install:
5555
- cd c:\projects\symfony
5656
- mkdir %APPDATA%\Composer
5757
- IF %APPVEYOR_REPO_NAME%==symfony/symfony copy /Y .composer\* %APPDATA%\Composer\
58-
- IF %APPVEYOR_REPO_NAME%==symfony/symfony composer global install --prefer-dist --no-progress --ansi || echo curl.cainfo needs PHP 5.3.7
58+
- IF %APPVEYOR_REPO_NAME%==symfony/symfony composer global install --no-progress --ansi || echo curl.cainfo needs PHP 5.3.7
5959
- php phpunit install
6060
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
61-
- composer update --prefer-dist --no-progress --ansi
61+
- composer update --no-progress --ansi
6262

6363
test_script:
6464
- cd c:\projects\symfony

‎composer.json

Copy file name to clipboardExpand all lines: composer.json
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,7 @@
9393
},
9494
"autoload": {
9595
"psr-4": {
96-
"Symfony\\Bridge\\Doctrine\\": "src/Symfony/Bridge/Doctrine/",
97-
"Symfony\\Bridge\\Monolog\\": "src/Symfony/Bridge/Monolog/",
98-
"Symfony\\Bridge\\ProxyManager\\": "src/Symfony/Bridge/ProxyManager/",
99-
"Symfony\\Bridge\\Swiftmailer\\": "src/Symfony/Bridge/Swiftmailer/",
100-
"Symfony\\Bridge\\Twig\\": "src/Symfony/Bridge/Twig/",
96+
"Symfony\\Bridge\\": "src/Symfony/Bridge/",
10197
"Symfony\\Bundle\\": "src/Symfony/Bundle/",
10298
"Symfony\\Component\\": "src/Symfony/Component/"
10399
},

‎phpunit

Copy file name to clipboardExpand all lines: phpunit
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*/
1212

1313
// Please update when phpunit needs to be reinstalled with fresh deps:
14-
// Cache-Id-Version: 2016-03-16 15:36 UTC
14+
// Cache-Id-Version: 2016-03-22 17:23 UTC
1515

1616
use Symfony\Component\Process\ProcessUtils;
1717

@@ -54,11 +54,17 @@ if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit") || md5_file(__
5454
passthru("$COMPOSER remove --no-update symfony/yaml");
5555
passthru("$COMPOSER require --dev --no-update symfony/phpunit-bridge \">=3.1@dev\"");
5656
passthru("$COMPOSER install --prefer-dist --no-progress --ansi");
57-
file_put_contents('phpunit', <<<EOPHP
57+
file_put_contents('phpunit', <<<'EOPHP'
5858
<?php
5959
6060
define('PHPUNIT_COMPOSER_INSTALL', __DIR__.'/vendor/autoload.php');
61-
require PHPUNIT_COMPOSER_INSTALL;
61+
62+
$loader = require PHPUNIT_COMPOSER_INSTALL;
63+
64+
if (getenv('SYMFONY_PHPUNIT_OVERLOAD') && file_exists(__DIR__.'/../../src/Symfony/Bridge/PhpUnit')) {
65+
$loader->addPsr4('Symfony\\Bridge\\PhpUnit\\', array('src/Symfony/Bridge/PhpUnit'), true);
66+
}
67+
unset($loader);
6268
Symfony\Bridge\PhpUnit\TextUI\Command::main();
6369

6470
EOPHP

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php
+29-9Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,23 @@ public static function register($mode = 0)
3939
if (self::$isRegistered) {
4040
return;
4141
}
42-
if (self::MODE_WEAK !== $mode && (!isset($mode[0]) || '/' !== $mode[0])) {
43-
$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0;
44-
}
42+
43+
$getMode = function () use ($mode) {
44+
static $memoizedMode = false;
45+
46+
if (false !== $memoizedMode) {
47+
return $memoizedMode;
48+
}
49+
if (false === $mode) {
50+
$mode = getenv('SYMFONY_DEPRECATIONS_HELPER');
51+
}
52+
if (DeprecationErrorHandler::MODE_WEAK !== $mode && (!isset($mode[0]) || '/' !== $mode[0])) {
53+
$mode = preg_match('/^[1-9][0-9]*$/', $mode) ? (int) $mode : 0;
54+
}
55+
56+
return $memoizedMode = $mode;
57+
};
58+
4559
$deprecations = array(
4660
'unsilencedCount' => 0,
4761
'remainingCount' => 0,
@@ -52,15 +66,17 @@ public static function register($mode = 0)
5266
'legacy' => array(),
5367
'other' => array(),
5468
);
55-
$deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations, $mode) {
69+
$deprecationHandler = function ($type, $msg, $file, $line, $context) use (&$deprecations, $getMode) {
5670
if (E_USER_DEPRECATED !== $type) {
5771
return \PHPUnit_Util_ErrorHandler::handleError($type, $msg, $file, $line, $context);
5872
}
5973

60-
$trace = debug_backtrace(PHP_VERSION_ID >= 50400 ? DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT : true);
74+
$mode = $getMode();
75+
$trace = debug_backtrace(true);
76+
$group = 'other';
6177

6278
$i = count($trace);
63-
while (isset($trace[--$i]['class']) && ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_'))) {
79+
while (1 < $i && (!isset($trace[--$i]['class']) || ('ReflectionMethod' === $trace[$i]['class'] || 0 === strpos($trace[$i]['class'], 'PHPUnit_')))) {
6480
// No-op
6581
}
6682

@@ -101,8 +117,7 @@ public static function register($mode = 0)
101117
$ref = &$deprecations[$group][$msg][$class.'::'.$method];
102118
++$ref;
103119
}
104-
} else {
105-
$group = 'other';
120+
} elseif (DeprecationErrorHandler::MODE_WEAK !== $mode) {
106121
$ref = &$deprecations[$group][$msg]['count'];
107122
++$ref;
108123
}
@@ -127,10 +142,14 @@ public static function register($mode = 0)
127142
} else {
128143
$colorize = function ($str) {return $str;};
129144
}
130-
register_shutdown_function(function () use ($mode, &$deprecations, $deprecationHandler, $colorize) {
145+
register_shutdown_function(function () use ($getMode, &$deprecations, $deprecationHandler, $colorize) {
146+
$mode = $getMode();
131147
$currErrorHandler = set_error_handler('var_dump');
132148
restore_error_handler();
133149

150+
if (DeprecationErrorHandler::MODE_WEAK === $mode) {
151+
$colorize = function ($str) {return $str;};
152+
}
134153
if ($currErrorHandler !== $deprecationHandler) {
135154
echo "\n", $colorize('THE ERROR HANDLER HAS CHANGED!', true), "\n";
136155
}
@@ -161,6 +180,7 @@ public static function register($mode = 0)
161180
if (!empty($notices)) {
162181
echo "\n";
163182
}
183+
164184
if (DeprecationErrorHandler::MODE_WEAK !== $mode && $mode < $deprecations['unsilencedCount'] + $deprecations['remainingCount'] + $deprecations['otherCount']) {
165185
exit(1);
166186
}

‎src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/SymfonyTestsListener.php
+27-7Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,34 @@ class SymfonyTestsListener extends \PHPUnit_Framework_BaseTestListener
2626
private $wasSkipped = array();
2727
private $isSkipped = array();
2828

29-
public function __construct(array $extraClockMockedNamespaces = array())
29+
/**
30+
* @param array $mockedNamespaces List of namespaces, indexed by mocked features (time-sensitive).
31+
*/
32+
public function __construct(array $mockedNamespaces = array())
3033
{
31-
if ($extraClockMockedNamespaces) {
32-
foreach ($extraClockMockedNamespaces as $ns) {
33-
ClockMock::register($ns.'\DummyClass');
34+
$warn = false;
35+
foreach ($mockedNamespaces as $type => $namespaces) {
36+
if (!is_array($namespaces)) {
37+
$namespaces = array($namespaces);
38+
}
39+
if (is_int($type)) {
40+
// @deprecated BC with v2.8 to v3.0
41+
$type = 'time-sensitive';
42+
$warn = true;
43+
}
44+
if ('time-sensitive' === $type) {
45+
foreach ($namespaces as $ns) {
46+
ClockMock::register($ns.'\DummyClass');
47+
}
3448
}
3549
}
3650
if (self::$globallyEnabled) {
3751
$this->state = -2;
3852
} else {
3953
self::$globallyEnabled = true;
54+
if ($warn) {
55+
echo "Clock-mocked namespaces for SymfonyTestsListener need to be nested in a \"time-sensitive\" key. This will be enforced in Symfony 4.0.\n";
56+
}
4057
}
4158
}
4259

@@ -75,10 +92,13 @@ public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
7592
for ($i = 0; isset($testSuites[$i]); ++$i) {
7693
foreach ($testSuites[$i]->tests() as $test) {
7794
if ($test instanceof \PHPUnit_Framework_TestSuite) {
78-
if (class_exists($test->getName(), false) && in_array('time-sensitive', \PHPUnit_Util_Test::getGroups($test->getName()), true)) {
79-
ClockMock::register($test->getName());
80-
} else {
95+
if (!class_exists($test->getName(), false)) {
8196
$testSuites[] = $test;
97+
continue;
98+
}
99+
$groups = \PHPUnit_Util_Test::getGroups($test->getName());
100+
if (in_array('time-sensitive', $groups, true)) {
101+
ClockMock::register($test->getName());
82102
}
83103
}
84104
}
+69Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
--TEST--
2+
Test DeprecationErrorHandler in default mode
3+
--FILE--
4+
<?php
5+
6+
putenv('SYMFONY_DEPRECATIONS_HELPER');
7+
putenv('ANSICON');
8+
putenv('ConEmuANSI');
9+
putenv('TERM');
10+
11+
$vendor = __DIR__;
12+
while (!file_exists($vendor.'/vendor')) {
13+
$vendor = dirname($vendor);
14+
}
15+
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
16+
require PHPUNIT_COMPOSER_INSTALL;
17+
require_once __DIR__.'/../../bootstrap.php';
18+
19+
@trigger_error('root deprecation', E_USER_DEPRECATED);
20+
21+
class PHPUnit_Util_Test
22+
{
23+
public static function getGroups()
24+
{
25+
return array();
26+
}
27+
}
28+
29+
class FooTestCase
30+
{
31+
public function testLegacyFoo()
32+
{
33+
@trigger_error('silenced foo deprecation', E_USER_DEPRECATED);
34+
trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED);
35+
trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED);
36+
}
37+
38+
public function testNonLegacyBar()
39+
{
40+
@trigger_error('silenced bar deprecation', E_USER_DEPRECATED);
41+
trigger_error('unsilenced bar deprecation', E_USER_DEPRECATED);
42+
}
43+
}
44+
45+
$foo = new FooTestCase();
46+
$foo->testLegacyFoo();
47+
$foo->testNonLegacyBar();
48+
49+
?>
50+
--EXPECTF--
51+
Unsilenced deprecation notices (3)
52+
53+
unsilenced foo deprecation: 2x
54+
2x in FooTestCase::testLegacyFoo
55+
56+
unsilenced bar deprecation: 1x
57+
1x in FooTestCase::testNonLegacyBar
58+
59+
Remaining deprecation notices (1)
60+
61+
silenced bar deprecation: 1x
62+
1x in FooTestCase::testNonLegacyBar
63+
64+
Legacy deprecation notices (1)
65+
66+
Other deprecation notices (1)
67+
68+
root deprecation: 1x
69+
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
Test DeprecationErrorHandler in weak mode
3+
--FILE--
4+
<?php
5+
6+
putenv('SYMFONY_DEPRECATIONS_HELPER=weak');
7+
putenv('ANSICON');
8+
putenv('ConEmuANSI');
9+
putenv('TERM');
10+
11+
$vendor = __DIR__;
12+
while (!file_exists($vendor.'/vendor')) {
13+
$vendor = dirname($vendor);
14+
}
15+
define('PHPUNIT_COMPOSER_INSTALL', $vendor.'/vendor/autoload.php');
16+
require PHPUNIT_COMPOSER_INSTALL;
17+
require_once __DIR__.'/../../bootstrap.php';
18+
19+
@trigger_error('root deprecation', E_USER_DEPRECATED);
20+
21+
class FooTestCase
22+
{
23+
public function testLegacyFoo()
24+
{
25+
@trigger_error('silenced foo deprecation', E_USER_DEPRECATED);
26+
trigger_error('unsilenced foo deprecation', E_USER_DEPRECATED);
27+
}
28+
}
29+
30+
$foo = new FooTestCase();
31+
$foo->testLegacyFoo();
32+
33+
?>
34+
--EXPECTF--
35+
Unsilenced deprecation notices (1)
36+
37+
Legacy deprecation notices (1)
38+
39+
Other deprecation notices (1)
40+

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

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/TextUI/Command.php
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,24 @@ protected function createRunner()
2323
{
2424
return new TestRunner($this->arguments['loader']);
2525
}
26+
27+
/**
28+
* {@inheritdoc}
29+
*/
30+
protected function handleBootstrap($filename)
31+
{
32+
parent::handleBootstrap($filename);
33+
34+
// By default, we want PHPUnit's autoloader before Symfony's one
35+
if (!getenv('SYMFONY_PHPUNIT_OVERLOAD')) {
36+
$filename = realpath(stream_resolve_include_path($filename));
37+
$symfonyLoader = realpath(dirname(PHPUNIT_COMPOSER_INSTALL).'/../../../vendor/autoload.php');
38+
39+
if ($filename === $symfonyLoader) {
40+
$symfonyLoader = require $symfonyLoader;
41+
$symfonyLoader->unregister();
42+
$symfonyLoader->register(false);
43+
}
44+
}
45+
}
2646
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.