AutowireCallable example

use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Attribute\AutowireCallable;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Reference;

class AutowireCallableTest extends TestCase
{
    public function testNoArguments()
    {
        $this->expectException(LogicException::class);

        new AutowireCallable();
    }

    public function testCallableAndService()
    {
        $this->expectException(LogicException::class);

        new AutowireCallable(callable: 'my_callable', service: 'my_service', method: 'my_method');
    }

    public function testMethodOnly()
    {
        
Home | Imprint | This part of the site doesn't use cookies.