mercredi 29 juillet 2015

Testing a file upload to a form in a Behat feature file

I am quite new to writing Behat test suites and I am currently trying to flesh out my existing feature file with an added test to test an uploaded file.

This is what I have come up with so far.

  Scenario: Submitting a valid asset form and uploading a file
    When I submit a asset form with values:
      | name               | type  | position | active | file                                 |
      | St Andrews Release | image | 1        | 1      | /web/images/product/icon/default.jpg |
    Then the form should be valid
    And the entity form entity should have the following values
      | name               | type  | position | active | file                                 |
      | St Andrews Release | image | 1        | 1      | /web/images/product/icon/default.jpg |
      Failed asserting that null matches expected '/web/images/product/icon/default.jpg'.
    And the entity form entity should be persisted correctly

This is the method handling the scenario:

   /**
     * @When I submit a asset form with values:
     */
    public function iSubmitAssetFormWithValues(TableNode $table)
    {
        $data       = $table->getColumnsHash()[0];
        $this->form = $this->submitTheForm('crmpicco.asset.type', $this->entity, $data);
    }

The submitTheForm method returns a Symfony\Component\Form\FormInterface.

Am I along the right lines? I am currently getting an error:

Failed asserting that null matches expected '/web/images/product/swatch/default.jpg'.

Aucun commentaire:

Enregistrer un commentaire