ConfigurableFormType example



    public function testFinishView()
    {
        $this->resolvedType->finishView(new FormView()$this->formFactory->create()[]);

        $this->assertSame([$this->parentType, $this->type, $this->extension1, $this->extension2]$this->calls['finishView']);
    }

    public function testGetBlockPrefix()
    {
        $resolvedType = new ResolvedFormType(new ConfigurableFormType());

        $this->assertSame('configurable_form_prefix', $resolvedType->getBlockPrefix());
    }

    /** * @dataProvider provideTypeClassBlockPrefixTuples */
    public function testBlockPrefixDefaultsToFQCNIfNoName($typeClass$blockPrefix)
    {
        $resolvedType = new ResolvedFormType(new $typeClass());

        
private ConfigurableFormTypeGuesser $guesser1;
    private ConfigurableFormTypeGuesser $guesser2;
    private FormRegistry $registry;
    private FormFactory $factory;

    protected function setUp(): void
    {
        $this->guesser1 = new ConfigurableFormTypeGuesser();
        $this->guesser2 = new ConfigurableFormTypeGuesser();
        $this->registry = new FormRegistry([
            new PreloadedExtension([
                new ConfigurableFormType(),
            ][]new FormTypeGuesserChain([$this->guesser1, $this->guesser2])),
        ]new ResolvedFormTypeFactory());
        $this->factory = new FormFactory($this->registry);
    }

    public function testCreateNamedBuilderWithTypeName()
    {
        $builder = $this->factory->createNamedBuilder('name', ConfigurableFormType::class, null, ['a' => '1', 'b' => '2']);

        $this->assertSame('1', $builder->getOption('a'));
        $this->assertSame('2', $builder->getOption('b'));
    }
Home | Imprint | This part of the site doesn't use cookies.