Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0:
  [HttpClient][Mailer] Revert "Let curl handle transfer encoding", use HTTP/1.1 for Mailgun
  Reviewed Catalan missing translations
  [AssetMapper] Upgrade importmap polyfill
  Fix typo: synchronous -> synchronously
  [Serializer] Check if exception message in test is correct
  Ibexa is sponsoring Symfony 5.4, thanks to them! \o/
  [VarDumper] Fix `FFICaster` test to be platform-adaptable
  [String] Add `alias` case to `EnglishInflector`
  [FrameworkBundle] Throw runtime exception when trying to use asset-mapper while http-client is disabled
  [SecurityBundle] Remove unused memory users’ `name` attribute from the XSD
  [VarExporter] generate __doUnserialize() method in ProxyHelper::generateLazyProxy()
  Double check if pcntl function exists
  Add additional headers in Scaleway bridge
  [VarDumper] Fix FFI caster test
  [DependencyInjection] Add test coverage for `AutowireCallable::buildDefinition()`
  • Loading branch information
nicolas-grekas committed Jun 28, 2024
2 parents 9084258 + 4e6e9fa commit aaf3e9d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Tests/Attribute/AutowireCallableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,35 @@ public function testArrayCallableWithServiceOnly()
self::assertEquals([new Reference('my_service'), '__invoke'], $attribute->value);
self::assertFalse($attribute->lazy);
}

public function testLazyAsArrayInDefinition()
{
$attribute = new AutowireCallable(callable: [Foo::class, 'myMethod'], lazy: 'my_lazy_class');

self::assertSame([Foo::class, 'myMethod'], $attribute->value);

$definition = $attribute->buildDefinition('my_value', 'my_custom_type', new \ReflectionParameter([Foo::class, 'myMethod'], 'myParameter'));

self::assertSame('my_lazy_class', $definition->getClass());
self::assertTrue($definition->isLazy());
}

public function testLazyIsFalseInDefinition()
{
$attribute = new AutowireCallable(callable: [Foo::class, 'myMethod'], lazy: false);

self::assertFalse($attribute->lazy);

$definition = $attribute->buildDefinition('my_value', 'my_custom_type', new \ReflectionParameter([Foo::class, 'myMethod'], 'myParameter'));

self::assertSame('my_custom_type', $definition->getClass());
self::assertFalse($definition->isLazy());
}
}

class Foo
{
public function myMethod(callable $myParameter)
{
}
}

0 comments on commit aaf3e9d

Please sign in to comment.