Score:0

How do I test managed files upload through configuration?

in flag

I have a configuration form in Drupal9 which extend ConfigFormBase that I need to pass through Behat test. To simplify the form, I have only one managed_file fields.

$form['card_logo_fid'] = [
  '#title' => t('Image'),
  '#type' => 'managed_file',
  '#upload_validators' => ['file_validate_extensions' => ['png gif jpg jpeg']],
  '#default_value' => isset($companyDataConfig['card_logo_fid']) ? $companyDataConfig['card_logo_fid'] : '',
  '#upload_location' => AggregatedContactSettingsForm::UPLOAD_LOCATION,
];

What solution do I have to explicitly upload an image in this field using Behat? Please remember that since it's a configuration form I cannot use the node creation approach which looks like the following.

| field_name |
| value      |
id flag
Are you using a Behat integration module or project specifically for Drupal?
Jaypan avatar
de flag
This answer won't help you at all in the short term, but I have personally dropped all Behat testing, in favor of Cypress testing (Cypress.io), which I have found much, much easier and better to work with. Something to check out for the future. Sorry I can't help on your current issue though.
in flag
I use `"behat/behat": "3.8.0", within Drupal (https://github.com/Behat/Behat), and no I cannot ditch behat for another testing framework.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.