Baz example


        return $container->services['bar2'] = new \stdClass();
    }

    /** * Gets the public 'baz' shared service. * * @return \Baz */
    protected static function getBazService($container)
    {
        $container->services['baz'] = $instance = new \Baz();

        $instance->setFoo(($container->services['foo_with_inline'] ?? self::getFooWithInlineService($container)));

        return $instance;
    }

    /** * Gets the public 'configured_service' shared service. * * @return \stdClass */
    


    /** * Gets the public 'App\Foo' shared service. * * @return \App\Foo */
    protected static function getFooService($container)
    {
        $a = new \App\Bar();

        $b = new \App\Baz($a);
        $b->bar = $a;

        $container->services['App\\Foo'] = $instance = new \App\Foo($b);

        $a->foo = $instance;

        return $instance;
    }
}

        };
        $data['f2'] = new class(new \ArrayObject(['k' => 'v'])) {
            public $map;

            public function __construct(\ArrayObject $map)
            {
                $this->map = $map;
            }
        };

        $data['g1'] = new Baz([]);
        $data['g2'] = new Baz(['greg']);

        yield [$serializer$data];
    }

    /** @dataProvider provideObjectOrCollectionTests */
    public function testNormalizeWithCollection(Serializer $serializer, array $data)
    {
        $expected = '{"a1":[],"a2":{"k":"v"},"b1":[],"b2":{"k":"v"},"c1":{"nested":[]},"c2":{"nested":{"k":"v"}},"d1":{"nested":[]},"d2":{"nested":{"k":"v"}},"e1":{"map":[]},"e2":{"map":{"k":"v"}},"f1":{"map":[]},"f2":{"map":{"k":"v"}},"g1":{"list":[],"settings":[]},"g2":{"list":["greg"],"settings":[]}}';
        $this->assertSame($expected$serializer->serialize($data, 'json'));
    }

    

    public function testGetAttributes(callable $controller)
    {
        $event = new ControllerEvent(new TestHttpKernel()$controllernew Request(), HttpKernelInterface::MAIN_REQUEST);

        $expected = [
            Bar::class => [
                new Bar('class'),
                new Bar('method'),
            ],
            Baz::class => [
                new Baz(),
            ],
        ];

        $this->assertEquals($expected$event->getAttributes());
    }

    /** * @dataProvider provideGetAttributes */
    public function testGetAttributesByClassName(callable $controller)
    {
        

        return $container->services['bar2'] = new \stdClass();
    }

    /** * Gets the public 'baz' shared service. * * @return \Baz */
    protected static function getBazService($container)
    {
        $container->services['baz'] = $instance = new \Baz();

        $instance->setFoo(($container->services['foo_with_inline'] ?? self::getFooWithInlineService($container)));

        return $instance;
    }

    /** * Gets the public 'configured_service' shared service. * * @return \stdClass */
    
$controllerEvent = new ControllerEvent(new TestHttpKernel()$controller$request, HttpKernelInterface::MAIN_REQUEST);

        $event = new ControllerArgumentsEvent(new TestHttpKernel()$controllerEvent['test']new Request(), HttpKernelInterface::MAIN_REQUEST);

        $expected = [
            Bar::class => [
                new Bar('class'),
                new Bar('method'),
            ],
            Baz::class => [
                new Baz(),
            ],
        ];

        $this->assertEquals($expected$event->getAttributes());

        $expected[Bar::class][] = new Bar('foo');
        $event->setController($controller$expected);

        $this->assertEquals($expected$event->getAttributes());
        $this->assertSame($controllerEvent->getAttributes()$event->getAttributes());
    }

    
Home | Imprint | This part of the site doesn't use cookies.