Merge branch '2.7' into 2.8

Conflicts:
	appveyor.yml
This commit is contained in:
Nicolas Grekas 2015-10-07 09:09:15 +02:00
commit f35a0d202f
8 changed files with 67 additions and 26 deletions

View File

@ -13,7 +13,7 @@ init:
- SET SYMFONY_DEPRECATIONS_HELPER=strict
- SET PHP=1
- SET ANSICON=121x90 (121x90)
- SET PHP_INI_MATRIX=php.ini-min-ext php.ini-max-ext
- SET PHP_INI_MATRIX=php.ini-min php.ini-max
install:
- IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php)
@ -31,19 +31,19 @@ install:
- IF %PHP%==1 7z x php_memcache-3.0.8-5.3-nts-vc9-x86.zip -y > 7z.log
- IF %PHP%==1 cd ..
- IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat
- IF %PHP%==1 copy /Y php.ini-development php.ini-min-ext
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini-min-ext
- IF %PHP%==1 echo extension_dir=ext >> php.ini-min-ext
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini-min-ext
- IF %PHP%==1 copy /Y php.ini-min-ext php.ini-max-ext
- IF %PHP%==1 echo extension=php_apc.dll >> php.ini-max-ext
- IF %PHP%==1 echo extension=php_intl.dll >> php.ini-max-ext
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini-max-ext
- IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini-max-ext
- IF %PHP%==1 echo extension=php_pdo_sqlite.dll >> php.ini-max-ext
- IF %PHP%==1 echo extension=php_ldap.dll >> php.ini-max-ext
- IF %PHP%==1 copy /Y php.ini-development php.ini-min
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini-min
- IF %PHP%==1 echo extension_dir=ext >> php.ini-min
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini-min
- IF %PHP%==1 copy /Y php.ini-min php.ini-max
- IF %PHP%==1 echo extension=php_apc.dll >> php.ini-max
- IF %PHP%==1 echo extension=php_intl.dll >> php.ini-max
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini-max
- IF %PHP%==1 echo extension=php_fileinfo.dll >> php.ini-max
- IF %PHP%==1 echo extension=php_pdo_sqlite.dll >> php.ini-max
- IF %PHP%==1 echo extension=php_ldap.dll >> php.ini-max
- appveyor DownloadFile https://getcomposer.org/composer.phar
- copy /Y php.ini-max-ext php.ini
- copy /Y php.ini-max php.ini
- 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)

View File

@ -24,10 +24,6 @@ if (!file_exists($COMPOSER = __DIR__.'/composer.phar')) {
$PHP = ProcessUtils::escapeArgument($PHP);
$COMPOSER = $PHP.' '.ProcessUtils::escapeArgument($COMPOSER);
if (!(isset($argv[1]) && 'install' === $argv[1]) && !file_exists(__DIR__.'/vendor')) {
passthru("$COMPOSER update --no-progress --ansi");
}
if (!file_exists("$PHPUNIT_DIR/phpunit-$PHPUNIT_VERSION/phpunit")) {
// Build a standalone phpunit without symfony/yaml

View File

@ -91,12 +91,16 @@ class ClassLoader
return;
}
if (isset($this->prefixes[$prefix])) {
$this->prefixes[$prefix] = array_merge(
$this->prefixes[$prefix],
(array) $paths
);
if (is_array($paths)) {
$this->prefixes[$prefix] = array_unique(array_merge(
$this->prefixes[$prefix],
$paths
));
} elseif (!in_array($paths, $this->prefixes[$prefix])) {
$this->prefixes[$prefix][] = $paths;
}
} else {
$this->prefixes[$prefix] = (array) $paths;
$this->prefixes[$prefix] = array_unique((array) $paths);
}
}

View File

@ -76,14 +76,36 @@ class ClassLoaderTest extends \PHPUnit_Framework_TestCase
);
}
public function testAddPrefix()
public function testAddPrefixSingle()
{
$loader = new ClassLoader();
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$loader->addPrefix('Foo', __DIR__.DIRECTORY_SEPARATOR.'Fixtures');
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('Foo', $prefixes);
$this->assertCount(1, $prefixes['Foo']);
}
public function testAddPrefixesSingle()
{
$loader = new ClassLoader();
$loader->addPrefixes(array('Foo' => array('foo', 'foo')));
$loader->addPrefixes(array('Foo' => array('foo')));
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('Foo', $prefixes);
$this->assertCount(1, $prefixes['Foo'], print_r($prefixes, true));
}
public function testAddPrefixMulti()
{
$loader = new ClassLoader();
$loader->addPrefix('Foo', 'foo');
$loader->addPrefix('Foo', 'bar');
$prefixes = $loader->getPrefixes();
$this->assertArrayHasKey('Foo', $prefixes);
$this->assertCount(2, $prefixes['Foo']);
$this->assertContains('foo', $prefixes['Foo']);
$this->assertContains('bar', $prefixes['Foo']);
}
public function testUseIncludePath()

View File

@ -417,7 +417,7 @@ class Filesystem
}
} else {
if (is_link($file)) {
$this->symlink($file->getRealPath(), $target);
$this->symlink($file->getLinkTarget(), $target);
} elseif (is_dir($file)) {
$this->mkdir($target);
} elseif (is_file($file)) {

View File

@ -915,7 +915,7 @@ class FilesystemTest extends FilesystemTestCase
$this->assertTrue(is_dir($targetPath));
$this->assertFileEquals($sourcePath.'/nested/file1.txt', $targetPath.DIRECTORY_SEPARATOR.'link1/file1.txt');
$this->assertTrue(is_link($targetPath.DIRECTORY_SEPARATOR.'link1'));
$this->assertEquals($sourcePath.'nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
$this->assertEquals('nested', readlink($targetPath.DIRECTORY_SEPARATOR.'link1'));
}
/**

View File

@ -46,7 +46,7 @@ class UrlValidator extends ConstraintValidator
throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Url');
}
if (null === $value || '' === $value) {
if (null === $value) {
return;
}
@ -55,6 +55,10 @@ class UrlValidator extends ConstraintValidator
}
$value = (string) $value;
if ('' === $value) {
return;
}
$pattern = sprintf(static::PATTERN, implode('|', $constraint->protocols));
if (!preg_match($pattern, $value)) {

View File

@ -41,6 +41,13 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest
$this->assertNoViolation();
}
public function testEmptyStringFromObjectIsValid()
{
$this->validator->validate(new EmailProvider(), new Url());
$this->assertNoViolation();
}
/**
* @expectedException \Symfony\Component\Validator\Exception\UnexpectedTypeException
*/
@ -178,3 +185,11 @@ class UrlValidatorTest extends AbstractConstraintValidatorTest
);
}
}
class EmailProvider
{
public function __toString()
{
return '';
}
}