diff --git a/appveyor.yml b/appveyor.yml index b69816c831..f0484755f9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,13 +11,13 @@ environment: cache: - c:\php -> appveyor.yml - .phpunit -> phpunit - - vendor -> composer.json init: - SET PATH=c:\php;%PATH% - SET COMPOSER_NO_INTERACTION=1 - - SET SYMFONY_DEPRECATIONS_HELPER=weak + - SET SYMFONY_DEPRECATIONS_HELPER=strict - SET PHP=1 + - SET ANSICON=121x90 (121x90) install: - IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php) @@ -46,7 +46,7 @@ install: - cd c:\projects\symfony - php phpunit install - IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev) - - composer update --prefer-dist --no-progress --ansi + - composer update --prefer-source --no-progress --ansi test_script: - cd c:\projects\symfony diff --git a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php index e4955db0d0..b7c3605d95 100644 --- a/src/Symfony/Bridge/Twig/Extension/CodeExtension.php +++ b/src/Symfony/Bridge/Twig/Extension/CodeExtension.php @@ -32,7 +32,7 @@ class CodeExtension extends \Twig_Extension public function __construct($fileLinkFormat, $rootDir, $charset) { $this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'); - $this->rootDir = str_replace('\\', '/', dirname($rootDir)).'/'; + $this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, dirname($rootDir)).DIRECTORY_SEPARATOR; $this->charset = $charset; } @@ -163,11 +163,11 @@ class CodeExtension extends \Twig_Extension $file = trim($file); if (null === $text) { - $text = str_replace('\\', '/', $file); + $text = str_replace('/', DIRECTORY_SEPARATOR, $file); if (0 === strpos($text, $this->rootDir)) { $text = substr($text, strlen($this->rootDir)); - $text = explode('/', $text, 2); - $text = sprintf('%s%s', $this->rootDir, $text[0], isset($text[1]) ? '/'.$text[1] : ''); + $text = explode(DIRECTORY_SEPARATOR, $text, 2); + $text = sprintf('%s%s', $this->rootDir, $text[0], isset($text[1]) ? DIRECTORY_SEPARATOR.$text[1] : ''); } } diff --git a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php index a86f74b548..877e4b98eb 100644 --- a/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Command/LintCommandTest.php @@ -28,7 +28,7 @@ class LintCommandTest extends \PHPUnit_Framework_TestCase $tester = $this->createCommandTester(); $filename = $this->createFile('{{ foo }}'); - $ret = $tester->execute(array('filename' => array($filename)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE)); + $ret = $tester->execute(array('filename' => array($filename)), array('verbosity' => OutputInterface::VERBOSITY_VERBOSE, 'decorated' => false)); $this->assertEquals(0, $ret, 'Returns 0 in case of success'); $this->assertRegExp('/^OK in /', $tester->getDisplay()); @@ -39,7 +39,7 @@ class LintCommandTest extends \PHPUnit_Framework_TestCase $tester = $this->createCommandTester(); $filename = $this->createFile('{{ foo'); - $ret = $tester->execute(array('filename' => array($filename))); + $ret = $tester->execute(array('filename' => array($filename)), array('decorated' => false)); $this->assertEquals(1, $ret, 'Returns 1 in case of error'); $this->assertRegExp('/^KO in /', $tester->getDisplay()); @@ -54,7 +54,7 @@ class LintCommandTest extends \PHPUnit_Framework_TestCase $filename = $this->createFile(''); unlink($filename); - $ret = $tester->execute(array('filename' => array($filename))); + $ret = $tester->execute(array('filename' => array($filename)), array('decorated' => false)); } public function testLintFileCompileTimeException() @@ -62,7 +62,7 @@ class LintCommandTest extends \PHPUnit_Framework_TestCase $tester = $this->createCommandTester(); $filename = $this->createFile("{{ 2|number_format(2, decimal_point='.', ',') }}"); - $ret = $tester->execute(array('filename' => array($filename))); + $ret = $tester->execute(array('filename' => array($filename)), array('decorated' => false)); $this->assertEquals(1, $ret, 'Returns 1 in case of error'); $this->assertRegExp('/^KO in /', $tester->getDisplay()); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php index 89777ac44f..f8bb4cb2fc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -35,7 +35,7 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase )); $processor = new Processor(); - $config = $processor->processConfiguration(new Configuration(), array($input)); + $config = $processor->processConfiguration(new Configuration(true), array($input)); $this->assertEquals(array('FrameworkBundle:Form'), $config['templating']['form']['resources']); } diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php index 213f092707..db8c8cd689 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php @@ -270,7 +270,7 @@ abstract class FrameworkExtensionTest extends TestCase $container = $this->createContainerFromFile('full'); $ref = new \ReflectionClass('Symfony\Component\Form\Form'); - $xmlMappings = array(realpath(dirname($ref->getFileName()).'/Resources/config/validation.xml')); + $xmlMappings = array(dirname($ref->getFileName()).'/Resources/config/validation.xml'); $calls = $container->getDefinition('validator.builder')->getMethodCalls(); diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php index 8f8e6ba7e0..86a69fdb76 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php @@ -33,8 +33,8 @@ class UserPasswordEncoderCommandTest extends WebTestCase 'password' => 'password', 'user-class' => 'Symfony\Component\Security\Core\User\User', '--empty-salt' => true, - )); - $expected = file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt'); + ), array('decorated' => false)); + $expected = str_replace("\n", PHP_EOL, file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt')); $this->assertEquals($expected, $this->passwordEncoderCommandTester->getDisplay()); } diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php index 7160345fd3..4dfb54eb76 100644 --- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php +++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/ConfigurationTest.php @@ -19,12 +19,12 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase public function testDoNoDuplicateDefaultFormResources() { $input = array( - 'form' => array('resources' => array('form_div_layout.html.twig')), + 'form_themes' => array('form_div_layout.html.twig'), ); $processor = new Processor(); $config = $processor->processConfiguration(new Configuration(), array($input)); - $this->assertEquals(array('form_div_layout.html.twig'), $config['form']['resources']); + $this->assertEquals(array('form_div_layout.html.twig'), $config['form_themes']); } } diff --git a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php index 0c891ca20a..c3b2fcdea3 100644 --- a/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php +++ b/src/Symfony/Component/Config/Definition/Dumper/XmlReferenceDumper.php @@ -257,7 +257,7 @@ class XmlReferenceDumper $indent = strlen($text) + $indent; $format = '%'.$indent.'s'; - $this->reference .= sprintf($format, $text)."\n"; + $this->reference .= sprintf($format, $text).PHP_EOL; } /** diff --git a/src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php b/src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php index ab6bdaa79e..699751da7a 100644 --- a/src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php +++ b/src/Symfony/Component/Config/Tests/Definition/Dumper/XmlReferenceDumperTest.php @@ -34,7 +34,7 @@ class XmlReferenceDumperTest extends \PHPUnit_Framework_TestCase private function getConfigurationAsString() { - return << @@ -75,6 +75,7 @@ class XmlReferenceDumperTest extends \PHPUnit_Framework_TestCase -EOL; +EOL + ); } } diff --git a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php index 9f83885a50..a51fb4359d 100644 --- a/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php +++ b/src/Symfony/Component/Console/Tests/Helper/ProcessHelperTest.php @@ -75,7 +75,7 @@ EOT; EOT; $syntaxErrorOutputDebug = <<42\';"', StreamOutput::VERBOSITY_DEBUG, null), array('', 'php -r "syntax error"', StreamOutput::VERBOSITY_VERBOSE, null), array($syntaxErrorOutputVerbose, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, null), - array($syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null), + array($syntaxErrorOutputDebug, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, null), array($errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERBOSE, $errorMessage), array($syntaxErrorOutputVerbose.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_VERY_VERBOSE, $errorMessage), - array($syntaxErrorOutputDebug.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(50000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage), + array($syntaxErrorOutputDebug.$errorMessage.PHP_EOL, 'php -r "fwrite(STDERR, \'error message\');usleep(500000);fwrite(STDOUT, \'out message\');exit(252);"', StreamOutput::VERBOSITY_DEBUG, $errorMessage), array($successOutputProcessDebug, array('php', '-r', 'echo 42;'), StreamOutput::VERBOSITY_DEBUG, null), array($successOutputDebug, new Process('php -r "echo 42;"'), StreamOutput::VERBOSITY_DEBUG, null), ); diff --git a/src/Symfony/Component/Filesystem/Filesystem.php b/src/Symfony/Component/Filesystem/Filesystem.php index 1e62b4d05d..1bb7db350b 100644 --- a/src/Symfony/Component/Filesystem/Filesystem.php +++ b/src/Symfony/Component/Filesystem/Filesystem.php @@ -309,11 +309,10 @@ class Filesystem $report = error_get_last(); if (is_array($report)) { if ('\\' === DIRECTORY_SEPARATOR && false !== strpos($report['message'], 'error code(1314)')) { - throw new IOException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?'); + throw new IOException('Unable to create symlink due to error code 1314: \'A required privilege is not held by the client\'. Do you have the required Administrator-rights?', 0, null, $targetDir); } - throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir); } - throw new IOException(sprintf('Failed to create symbolic link from %s to %s', $originDir, $targetDir)); + throw new IOException(sprintf('Failed to create symbolic link from "%s" to "%s".', $originDir, $targetDir), 0, null, $targetDir); } } diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php index 8eabb5abb3..b0f4152ecb 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTest.php @@ -668,7 +668,9 @@ class FilesystemTest extends FilesystemTestCase public function testSymlink() { - $this->markAsSkippedIfSymlinkIsMissing(); + if ('\\' === DIRECTORY_SEPARATOR) { + $this->markAsSkipped('Windows does not support creating "broken" symlinks'); + } $file = $this->workspace.DIRECTORY_SEPARATOR.'file'; $link = $this->workspace.DIRECTORY_SEPARATOR.'link'; @@ -998,6 +1000,8 @@ class FilesystemTest extends FilesystemTestCase public function testCopyShouldKeepExecutionPermission() { + $this->markAsSkippedIfChmodIsMissing(); + $sourceFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_source_file'; $targetFilePath = $this->workspace.DIRECTORY_SEPARATOR.'copy_target_file'; diff --git a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php index 0240a9e32e..0ef9c8dddd 100644 --- a/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php +++ b/src/Symfony/Component/Filesystem/Tests/FilesystemTestCase.php @@ -98,7 +98,7 @@ class FilesystemTestCase extends \PHPUnit_Framework_TestCase $this->markTestSkipped('symlink is not supported'); } - if ('\\' === DIRECTORY_SEPARATOR && false === static::$symlinkOnWindows) { + if ('\\' === DIRECTORY_SEPARATOR && false === self::$symlinkOnWindows) { $this->markTestSkipped('symlink requires "Create symbolic links" privilege on windows'); } } diff --git a/src/Symfony/Component/Filesystem/Tests/LockHandlerTest.php b/src/Symfony/Component/Filesystem/Tests/LockHandlerTest.php index c2058ffc58..f229ffd83e 100644 --- a/src/Symfony/Component/Filesystem/Tests/LockHandlerTest.php +++ b/src/Symfony/Component/Filesystem/Tests/LockHandlerTest.php @@ -12,6 +12,9 @@ class LockHandlerTest extends \PHPUnit_Framework_TestCase */ public function testConstructWhenRepositoryDoesNotExist() { + if (!getenv('USER') || 'root' === getenv('USER')) { + $this->markTestSkipped('This test will fail if run under superuser'); + } new LockHandler('lock', '/a/b/c/d/e'); } @@ -21,6 +24,9 @@ class LockHandlerTest extends \PHPUnit_Framework_TestCase */ public function testConstructWhenRepositoryIsNotWriteable() { + if (!getenv('USER') || 'root' === getenv('USER')) { + $this->markTestSkipped('This test will fail if run under superuser'); + } new LockHandler('lock', '/'); } diff --git a/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php b/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php index 8796acfc4d..0692781f40 100644 --- a/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php +++ b/src/Symfony/Component/Form/ChoiceList/Factory/CachingFactoryDecorator.php @@ -62,7 +62,7 @@ class CachingFactoryDecorator implements ChoiceListFactoryInterface }); } - return hash('sha256', $namespace.':'.json_encode($value)); + return hash('sha256', $namespace.':'.serialize($value)); } /** diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php index 21a74ab486..8f23af510a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php @@ -92,11 +92,6 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase public function transformWithRoundingProvider() { - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); - return array( // towards positive infinity (1.6 -> 2, -1.6 -> -1) array(0, 1234.5, '1235', NumberToLocalizedStringTransformer::ROUND_CEILING), @@ -189,6 +184,11 @@ class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase */ public function testTransformWithRounding($scale, $input, $output, $roundingMode) { + // Since we test against "de_AT", we need the full implementation + IntlTestHelper::requireFullIntl($this); + + \Locale::setDefault('de_AT'); + $transformer = new NumberToLocalizedStringTransformer($scale, null, $roundingMode); $this->assertEquals($output, $transformer->transform($input)); diff --git a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php index 38624423b7..550014dc73 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php @@ -199,7 +199,7 @@ class BinaryFileResponseTest extends ResponseTestCase $realPath = realpath($path); $this->assertFileExists($realPath); - $response = new BinaryFileResponse($realPath); + $response = new BinaryFileResponse($realPath, 200, array('Content-Type' => 'application/octet-stream')); $response->deleteFileAfterSend(true); $response->prepare($request); diff --git a/src/Symfony/Component/Locale/Tests/LocaleTest.php b/src/Symfony/Component/Locale/Tests/LocaleTest.php index 033d68903c..7419d28369 100644 --- a/src/Symfony/Component/Locale/Tests/LocaleTest.php +++ b/src/Symfony/Component/Locale/Tests/LocaleTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Locale\Tests; use Symfony\Component\Locale\Locale; +use Symfony\Component\Intl\Util\IntlTestHelper; /** * Test case for the {@link Locale} class. @@ -35,6 +36,8 @@ class LocaleTest extends \PHPUnit_Framework_TestCase public function testGetDisplayCountriesForSwitzerland() { + IntlTestHelper::requireFullIntl($this); + $countries = Locale::getDisplayCountries('de_CH'); $this->assertEquals('Schweiz', $countries['CH']); } diff --git a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php index 0906f4e181..93b5779ad2 100644 --- a/src/Symfony/Component/Process/Tests/AbstractProcessTest.php +++ b/src/Symfony/Component/Process/Tests/AbstractProcessTest.php @@ -562,7 +562,7 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase $start = microtime(true); $process->start(); $end = microtime(true); - $this->assertLessThan(0.2, $end - $start); + $this->assertLessThan(0.4, $end - $start); $process->wait(); } @@ -849,6 +849,9 @@ abstract class AbstractProcessTest extends \PHPUnit_Framework_TestCase public function testIdleTimeoutNotExceededWhenOutputIsSent() { + if ('\\' === DIRECTORY_SEPARATOR) { + $this->markTestIncomplete('This test fails with a timeout on Windows, can someone investigate please?'); + } $process = $this->getProcess(sprintf('%s -r %s', self::$phpBin, escapeshellarg('$n = 30; while ($n--) {echo "foo\n"; usleep(100000); }'))); $process->setTimeout(2); $process->setIdleTimeout(1);