Skip to content

Commit

Permalink
Merge branch '3.1' into 3.2
Browse files Browse the repository at this point in the history
* 3.1:
  fix getMock usage
  [DependencyInjection] Fixed variadic method parameter in autowired classes
  update German translation
  [Validator] Improved error message for missing upload_tmp_dir
  • Loading branch information
nicolas-grekas committed Jan 23, 2017
2 parents 482828c + 4268aba commit ba41e70
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 11 deletions.
Expand Up @@ -345,10 +345,11 @@ private static function getResourceMetadataForMethod(\ReflectionMethod $method)
$class = false;
}

$isVariadic = method_exists($parameter, 'isVariadic') && $parameter->isVariadic();
$methodArgumentsMetadata[] = array(
'class' => $class,
'isOptional' => $parameter->isOptional(),
'defaultValue' => $parameter->isOptional() ? $parameter->getDefaultValue() : null,
'defaultValue' => ($parameter->isOptional() && !$isVariadic) ? $parameter->getDefaultValue() : null,
);
}

Expand Down
Expand Up @@ -14,6 +14,7 @@
use Symfony\Component\DependencyInjection\Compiler\AutowirePass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\Tests\Fixtures\includes\FooVariadic;

/**
* @author Kévin Dunglas <dunglas@gmail.com>
Expand All @@ -35,6 +36,23 @@ public function testProcess()
$this->assertEquals('foo', (string) $container->getDefinition('bar')->getArgument(0));
}

/**
* @requires PHP 5.6
*/
public function testProcessVariadic()
{
$container = new ContainerBuilder();
$container->register('foo', Foo::class);
$definition = $container->register('fooVariadic', FooVariadic::class);
$definition->setAutowired(true);

$pass = new AutowirePass();
$pass->process($container);

$this->assertCount(1, $container->getDefinition('fooVariadic')->getArguments());
$this->assertEquals('foo', (string) $container->getDefinition('fooVariadic')->getArgument(0));
}

public function testProcessAutowireParent()
{
$container = new ContainerBuilder();
Expand Down
@@ -0,0 +1,16 @@
<?php

namespace Symfony\Component\DependencyInjection\Tests\Fixtures\includes;

use Symfony\Component\DependencyInjection\Tests\Compiler\Foo;

class FooVariadic
{
public function __construct(Foo $foo)
{
}

public function bar(...$arguments)
{
}
}
Expand Up @@ -156,14 +156,14 @@ public function testLoadUserByUsernameFailsIfMoreThanOneLdapPasswordsInEntry()
*/
public function testLoadUserByUsernameFailsIfEntryHasNoUidKeyAttribute()
{
$result = $this->getMock(CollectionInterface::class);
$query = $this->getMock(QueryInterface::class);
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
->will($this->returnValue($result))
;
$ldap = $this->getMock(LdapInterface::class);
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
Expand Down Expand Up @@ -321,14 +321,14 @@ public function testLoadUserByUsernameIsSuccessfulWithoutPasswordAttributeAndWro

public function testLoadUserByUsernameIsSuccessfulWithPasswordAttribute()
{
$result = $this->getMock(CollectionInterface::class);
$query = $this->getMock(QueryInterface::class);
$result = $this->getMockBuilder(CollectionInterface::class)->getMock();
$query = $this->getMockBuilder(QueryInterface::class)->getMock();
$query
->expects($this->once())
->method('execute')
->will($this->returnValue($result))
;
$ldap = $this->getMock(LdapInterface::class);
$ldap = $this->getMockBuilder(LdapInterface::class)->getMock();
$result
->expects($this->once())
->method('offsetGet')
Expand Down
Expand Up @@ -192,7 +192,7 @@
</trans-unit>
<trans-unit id="51">
<source>No temporary folder was configured in php.ini.</source>
<target>Es wurde kein temporärer Ordner in der php.ini konfiguriert.</target>
<target>Es wurde kein temporärer Ordner in der php.ini konfiguriert oder der temporäre Ordner existiert nicht.</target>
</trans-unit>
<trans-unit id="52">
<source>Cannot write temporary file to disk.</source>
Expand Down
Expand Up @@ -192,7 +192,7 @@
</trans-unit>
<trans-unit id="51">
<source>No temporary folder was configured in php.ini.</source>
<target>No temporary folder was configured in php.ini.</target>
<target>No temporary folder was configured in php.ini, or the configured folder does not exist.</target>
</trans-unit>
<trans-unit id="52">
<source>Cannot write temporary file to disk.</source>
Expand Down
Expand Up @@ -192,7 +192,7 @@
</trans-unit>
<trans-unit id="51">
<source>No temporary folder was configured in php.ini.</source>
<target>Er is geen tijdelijke map geconfigureerd in php.ini.</target>
<target>Er is geen tijdelijke map geconfigureerd in php.ini, of de gespecificeerde map bestaat niet.</target>
</trans-unit>
<trans-unit id="52">
<source>Cannot write temporary file to disk.</source>
Expand Down
Expand Up @@ -192,7 +192,7 @@
</trans-unit>
<trans-unit id="51">
<source>No temporary folder was configured in php.ini.</source>
<target>Nie skonfigurowano folderu tymczasowego w php.ini.</target>
<target>Nie skonfigurowano folderu tymczasowego w php.ini, lub skonfigurowany folder nie istnieje.</target>
</trans-unit>
<trans-unit id="52">
<source>Cannot write temporary file to disk.</source>
Expand Down

0 comments on commit ba41e70

Please sign in to comment.