8000 Merge branch '2.3' into 2.7 · symfony/symfony@e924d56 · GitHub
[go: up one dir, main page]

Skip to content

Commit e924d56

Browse files
Merge branch '2.3' into 2.7
* 2.3: Windows and Intl fixes Add appveyor.yml for C.I. on Windows [travis] merge php: nightly and deps=high test-matrix lines [Security] Add missing docblock in PreAuthenticatedToken Conflicts: .travis.yml src/Symfony/Component/Filesystem/Tests/FilesystemTest.php src/Symfony/Component/HttpFoundation/JsonResponse.php src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php
2 parents de7b255 + fed77a3 commit e924d56

File tree

27 files changed

+371
-158
lines changed

27 files changed

+371
-158
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ phpunit.xml
55
composer.phar
66
package.tar
77
/packages.json
8+
/.phpunit

.travis.yml

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ language: php
33
sudo: false
44

55
addons:
6-
apt_packages:
7-
- parallel
8-
- language-pack-fr-base
6+
apt_packages:
7+
- parallel
8+
- language-pack-fr-base
99

1010
matrix:
1111
include:
@@ -15,9 +15,8 @@ matrix:
1515
- php: 5.5
1616
- php: 5.6
1717
env: deps=low
18-
- php: 5.6
19-
env: deps=high
2018
- php: 7.0
19+
env: deps=high
2120
fast_finish: true
2221

2322
services: mongodb
@@ -30,27 +29,24 @@ env:
3029
before_install:
3130
- composer self-update
3231
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "memory_limit = -1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini; fi;
33-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then phpenv config-rm xdebug.ini; fi;
34-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
35-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
36-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Let's continue without memcache extension"; fi;
37-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo "extension = $(pwd)/modules/symfony_debug.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini); fi;
38-
- if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]] && [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php -i; fi;
39-
40-
# Build a standalone phpunit without symfony/yaml and that works around https://github.com/sebastianbergmann/phpunit-mock-objects/issues/223
41-
- (mkdir phpunit && cd phpunit && wget https://github.com/sebastianbergmann/phpunit/archive/4.7.zip && unzip 4.7.zip && cd phpunit-4.7 && composer remove --no-update symfony/yaml && composer require --prefer-source phpunit/phpunit-mock-objects '2.3.0')
42-
- export PHPUNIT="$(readlink -f ./phpunit/phpunit-4.7/phpunit) --colors=always"
43-
# Set the COMPOSER_ROOT_VERSION to the right version according to the branch being built
44-
- if [ "$TRAVIS_BRANCH" = "master" ]; then export COMPOSER_ROOT_VERSION=dev-master; else export COMPOSER_ROOT_VERSION="$TRAVIS_BRANCH".x-dev; fi;
32+
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then phpenv config-rm xdebug.ini; fi;
33+
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
34+
- if [[ "$TRAVIS_PHP_VERSION" =~ 5.[34] ]]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;
35+
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (pecl install -f memcached-2.1.0 && echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini) || echo "Let's continue without memcache extension"; fi;
36+
- if [[ "$TRAVIS_PHP_VERSION" = 5.* ]]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo "extension = $(pwd)/modules/symfony_debug.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini); fi;
37+
- if [[ "$TRAVIS_PHP_VERSION" != "hhvm" ]]; then php -i; fi;
38+
- ./phpunit install
39+
- export PHPUNIT="$(readlink -f ./phpunit)"
4540

4641
install:
42+
- if [ "$TRAVIS_BRANCH" = "master" ]; then export COMPOSER_ROOT_VERSION=dev-master; else export COMPOSER_ROOT_VERSION="$TRAVIS_BRANCH".x-dev; fi;
4743
- if [ "$deps" = "no" ]; then export SYMFONY_DEPRECATIONS_HELPER=strict; fi;
4844
- if [ "$deps" = "no" ]; then composer --prefer-source install; fi;
49-
- components=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
50-
- if [ "$deps" != "no" ]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $components; fi;
45+
- COMPONENTS=$(find src/Symfony -mindepth 3 -type f -name phpunit.xml.dist -printf '%h\n')
46+
- if [ "$deps" != "no" ]; then php .travis.php $TRAVIS_COMMIT_RANGE $TRAVIS_BRANCH $COMPONENTS; fi;
5147

5248
script:
53-
- if [ "$deps" = "no" ]; then echo "$components" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; $PHPUNIT --exclude-group tty,benchmark,intl-data {} || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
54-
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty || (echo -e "\\e[41mKO\\e[0m tty group" && $(exit 1)); fi;
55-
- if [ "$deps" = "high" ]; then echo "$components" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
56-
- if [ "$deps" = "low" ]; then echo "$components" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; $PHPUNIT --exclude-group tty,benchmark,intl-data || (echo -e "\\e[41mKO\\e[0m {}" && $(exit 1));'; fi;
49+
- if [ "$deps" = "no" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order 'echo -e "\\nRunning {} tests"; $PHPUNIT --exclude-group tty,benchmark,intl-data {}'; fi;
50+
- if [ "$deps" = "no" ]; then echo -e "\\nRunning tests requiring tty"; $PHPUNIT --group tty; fi;
51+
- if [ "$deps" = "high" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;
52+
- if [ "$deps" = "low" ]; then echo "$COMPONENTS" | parallel --gnu --keep-order -j10% 'echo -e "\\nRunning {} tests"; cd {}; composer --prefer-source --prefer-lowest --prefer-stable update; $PHPUNIT --exclude-group tty,benchmark,intl-data'; fi;

appveyor.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
build: false
2+
shallow_clone: true
3+
platform: x86
4+
clone_folder: c:\projects\symfony
5+
6+
environment:
7+
matrix:
8+
- PHP_EXT: 1
9+
- PHP_EXT: 0
10+
11+
cache:
12+
- c:\php -> appveyor.yml
13+
- .phpunit -> phpunit
14+
- vendor -> composer.json
15+
16+
init:
17+
- SET PATH=c:\php;%PATH%
18+
- SET COMPOSER_NO_INTERACTION=1
19+
- SET SYMFONY_DEPRECATIONS_HELPER=weak
20+
- SET PHP=1
21+
22+
install:
23+
- IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php)
24+
- cd c:\php
25+
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-5.4.43-nts-Win32-VC9-x86.zip
26+
- IF %PHP%==1 7z x php-5.4.43-nts-Win32-VC9-x86.zip -y > 7z.log
27+
- IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/ICU-51.2-dlls.zip
28+
- IF %PHP%==1 7z x ICU-51.2-dlls.zip -y > 7z.log
29+
- IF %PHP%==1 cd ext
30+
- IF %PHP%==1 appveyor DownloadFile http://nebm.ist.utl.pt/~glopes/misc/intl_win/php_intl-3.0.0-5.4-nts-vc9-x86.zip
31+
- IF %PHP%==1 7z x php_intl-3.0.0-5.4-nts-vc9-x86.zip -y > 7z.log
32+
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/pecl/releases/apc/3.1.13/php_apc-3.1.13-5.4-nts-vc9-x86.zip
33+
- IF %PHP%==1 7z x php_apc-3.1.13-5.4-nts-vc9-x86.zip -y > 7z.log
34+
- IF %PHP%==1 cd ..
35+
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
36+
- appveyor DownloadFile https://getcomposer.org/composer.phar
37+
- copy php.ini-production php.ini /Y
38+
- echo date.timezone="UTC" >> php.ini
39+
- echo extension_dir=ext >> php.ini
40+
- echo extension=php_openssl.dll >> php.ini
41+
- IF %PHP_EXT%==1 echo extension=php_apc.dll >> php.ini
42+
- IF %PHP_EXT%==1 echo extension=php_intl.dll >> php.ini
43+
- IF %PHP_EXT%==1 echo extension=php_mbstring.dll >> php.ini
44+
- IF %PHP_EXT%==1 echo extension=php_fileinfo.dll >> php.ini
45+
- IF %PHP_EXT%==1 echo extension=php_pdo_sqlite.dll >> php.ini
46+
- cd c:\projects\symfony
47+
- php phpunit install
48+
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
49+
- composer update --prefer-dist --no-progress --ansi
50+
51+
test_script:
52+
- cd c:\projects\symfony
53+
- php phpunit symfony --exclude-group benchmark,intl-data

phpunit

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
error_reporting(-1);
5+
6+
$PHPUNIT_VERSION = 4.8;
7+
$PHPUNIT_DIR = __DIR__.'/.phpunit';
8+
9+
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) {
10+
# Build a standalone phpunit without symfony/yaml
11+
12+
$oldPwd = getcwd();
13+
mkdir($PHPUNIT_DIR);
14+
chdir($PHPUNIT_DIR);
15+
if (extension_loaded('openssl') && ini_get('allow_url_fopen')) {
16+
stream_copy_to_stream(fopen("https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip", 'rb'), fopen("$PHPUNIT_VERSION.zip", 'wb'));
17+
} else {
18+
passthru("wget https://github.com/sebastianbergmann/phpunit/archive/$PHPUNIT_VERSION.zip");
19+
}
20+
$zip = new ZipArchive();
21+
$zip->open("$PHPUNIT_VERSION.zip");
22+
$zip->extractTo(getcwd());
23+
$zip->close();
24+
chdir("phpunit-$PHPUNIT_VERSION");
25+
passthru("composer remove --no-update symfony/yaml");
26+
passthru("composer install --prefer-source --no-progress --ansi");
27+
chdir($oldPwd);
28+
}
29+
30+
$cmd = array_map('escapeshellarg', $argv);
31+
$exit = 0;
32+
33+
if (isset($argv[1]) && 'symfony' === $argv[1]) {
34+
# Find Symfony components in plain php for Windows portability
35+
36+
$finder = new RecursiveDirectoryIterator('src/Symfony', FilesystemIterator::KEY_AS_FILENAME | FilesystemIterator::UNIX_PATHS);
37+
$finder = new RecursiveIteratorIterator($finder);
38+
$finder->setMaxDepth(3);
39+
40+
array_shift($cmd);
41+
$cmd[0] = "php $PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit --colors=always";
42+
$procs = array();
43+
44+
foreach ($finder as $file => $fileInfo) {
45+
if ('phpunit.xml.dist' === $file) {
46+
$component = dirname($fileInfo->getPathname());
47+
48+
# Run phpunit tests in parallel
49+
50+
$c = escapeshellarg($component);
51+
52+
if ($proc = proc_open(implode(' ', $cmd)." $c > $c/phpunit.stdout 2> $c/phpunit.stderr", array(), $pipes)) {
53+
$procs[$component] = $proc;
54+
} else {
55+
$exit = 1;
56+
echo "\033[41mKO\033[0m $component\n\n";
57+
}
58+
}
59+
}
60+
61+
foreach ($procs as $component => $proc) {
62+
$procStatus = proc_close($proc);
63+
64+
foreach (array('out', 'err') as $file) {
65+
$file = "$component/phpunit.std$file";
66+
$h = fopen($file, 'rb');
67+
while (false !== $line = fgets($h)) {
68+
echo preg_replace_callback(
69+
'/\033\[[0-9]++(?:;[0-9]++)++m/',
70+
function ($m) {return str_replace(';', "m\033[", $m[0]);},
71+
$line
72+
);
73+
}
74+
fclose($h);
75+
unlink($file);
76+
}
77+
78+
if ($procStatus) {
79+
$exit = 1;
80+
echo "\033[41mKO\033[0m $component\n\n";
81+
} else {
82+
echo "\033[32mOK\033[0m $component\n\n";
83+
}
84+
}
85+
86+
} elseif (!isset($argv[1]) || 'install' !== $argv[1]) {
87+
# Run regular phpunit in a subprocess
88+
89+
$cmd[0] = "php $PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit --colors=always";
90+
91+
$errFile = tempnam(sys_get_temp_dir(), 'phpunit.stderr.');
92+
if ($proc = proc_open(implode(' ', $cmd).' 2> '.escapeshellarg($errFile), array(1 => array('pipe', 'w')), $pipes)) {
93+
while (false !== $line = fgets($pipes[1])) {
94+
echo $line;
95+
}
96+
fclose($pipes[1]);
97+
$exit = proc_close($proc);
98+
99+
$h = fopen($errFile, 'rb');
100+
while (false !== $line = fgets($h)) {
101+
echo $line;
102+
}
103+
fclose($h);
104+
unlink($errFile);
105+
}
106+
107+
if (file_exists($component = array_pop($argv))) {
108+
if ($exit) {
109+
echo "\033[41mKO\033[0m $component\n\n";
110+
} else {
111+
echo "\033[32mOK\033[0m $component\n\n";
112+
}
113+
}
114+
}
115+
116+
exit($exit);

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,10 @@ public function testRenderException()
553553

554554
public function testRenderExceptionWithDoubleWidthCharacters()
555555
{
556+
if (!function_exists('mb_strwidth')) {
557+
$this->markTestSkipped('The "mb_strwidth" function is not available');
558+
}
559+
556560
$application = $this->getMock('Symfony\Component\Console\Application', array('getTerminalWidth'));
557561
$application->setAutoExit(false);
558562
$application->expects($this->any())

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,20 +166,43 @@ public function addHtmlContent($content, $charset = 'UTF-8')
166166
$dom = new \DOMDocument('1.0', $charset);
167167
$dom->validateOnParse = true;
168168

169-
if (function_exists('mb_convert_encoding')) {
170-
$hasError = false;
171-
set_error_handler(function () use (&$hasError) {
172-
$hasError = true;
173-
});
174-
$tmpContent = @mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
175-
176-
restore_error_handler();
177-
178-
if (!$hasError) {
179-
$content = $tmpContent;
169+
set_error_handler(function () {throw new \Exception();});
170+
171+
try {
172+
// Convert charset to HTML-entities to work around bugs in DOMDocument::loadHTML()
173+
174+
if (function_exists('mb_convert_encoding')) {
175+
$content = mb_convert_encoding($content, 'HTML-ENTITIES', $charset);
176+
} elseif (function_exists('iconv')) {
177+
$content = preg_replace_callback(
178+
'/[\x80-\xFF]+/',
179+
function ($m) {
180+
$m = unpack('C*', $m[0]);
181+
$i = 1;
182+
$entities = '';
183+
184+
while (isset($m[$i])) {
185+
if (0xF0 <= $m[$i]) {
186+
$c = (($m[$i++] - 0xF0) << 18) + (($m[$i++] - 0x80) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
187+
} elseif (0xE0 <= $m[$i]) {
188+
$c = (($m[$i++] - 0xE0) << 12) + (($m[$i++] - 0x80) << 6) + $m[$i++] - 0x80;
189+
} else {
190+
$c = (($m[$i++] - 0xC0) << 6) + $m[$i++] - 0x80;
191+
}
192+
193+
$entities .= '&#'.$c.';';
194+
}
195+
196+
return $entities;
197+
},
198+
iconv($charset, 'UTF-8', $content)
199+
);
180200
}
201+
} catch (\Exception $e) {
181202
}
182203

204+
restore_error_handler();
205+
183206
if ('' !== trim($content)) {
184207
@$dom->loadHTML($content);
185208
}

src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public function testAddHtmlContent()
8181

8282
/**
8383
* @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent
84+
* @requires extension mbstring
8485
*/
8586
public function testAddHtmlContentCharset()
8687
{
@@ -115,6 +116,7 @@ public function testAddHtmlContentUnsupportedCharset()
115116

116117
/**
117118
* @covers Symfony\Component\DomCrawler\Crawler::addHtmlContent
119+
* @requires extension mbstring
118120
*/
119121
public function testAddHtmlContentCharsetGbk()
120122
{
@@ -235,7 +237,7 @@ public function testAddContent()
235237
$this->assertEquals('中文', $crawler->filterXPath('//span')->text(), '->addContent() guess wrong charset');
236238

237239
$crawler = new Crawler();
238-
$crawler->addContent(mb_convert_encoding('<html><head><meta charset="Shift_JIS"></head><body>日本語</body></html>', 'SJIS', 'UTF-8'));
240+
$crawler->addContent(iconv('UTF-8', 'SJIS', '<html><head><meta charset="Shift_JIS"></head><body>日本語</body></html>'));
239241
$this->assertEquals('日本語', $crawler->filterXPath('//body')->text(), '->addContent() can recognize "Shift_JIS" in html5 meta charset tag');
240242
}
241243

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,11 @@
1111

1212
namespace Symfony\Component\Filesystem\Tests;
1313

14-
use Symfony\Component\Filesystem\Filesystem;
15-
1614
/**
1715
* Test class for Filesystem.
1816
*/
1917
class FilesystemTest extends FilesystemTestCase
2018
{
21-
/**
22-
* @var \Symfony\Component\Filesystem\Filesystem
23-
*/
24-
private $filesystem = null;
25-
26-
protected function setUp()
27-
{
28-
parent::setUp();
29-
$this->filesystem = new Filesystem();
30-
}
31-
3219
public function testCopyCreatesNewFile()
3320
{
3421
$sourceFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_source_file';

0 commit comments

Comments
 (0)
0