lundi 6 juin 2016

PhpUnit symfony2 test form input file

i want to test with phpUnit and Symfony an upload file in my form. this is my form:

public function buildForm(FormBuilderInterface $builder, array $options)
    {

        $builder
            ->add('fotoprofilo', null, array(
                    'label' => 'ProfilePhoto',
                    'required' => false,
                    'attr' => array('class' => 'upload-image'), )
            )
            ->add('ilmionome', 'text', array(
                    'label' => 'MyName',
                    'required' => false, )
            )

and this is my test:

public function testRegistrationGadgetPuppy()
    {
        $client = $this->createLoggedClient();

        $crawler = $client->request('GET', '/reg_form');

        $button = $crawler->selectButton('Registra');

        $form = $button->form(array(
            'rf[fotoprofilo]' => ??
            'rf[ilmionome]' => 'Zelda',
        ));

        $client->submit($form);

        $crawler = $client->followRedirect();
    }

I don't know how to pass that input. Can you help me?

Aucun commentaire:

Enregistrer un commentaire