Correct simpletest syntax for adding tags to a story/page form?

Events happening in the community are now at Drupal community events on www.drupal.org.
angeliti's picture

Hello everyone!

I'm having problems when trying to add tags to the story/page creation form using simpletest.

I have a vocabulary which uses FREE TAGGING, and I want create a new page with the tag "cat". The vid of the vocabulary is stored in the class attribute 'free_tagging_voc'. What I've been trying to do is the following:

$edit = array();
$edit['title'] = $this->randomName(10);
$edit['body'] = '';
$edit['taxonomy']['tags'][$this->free_tagging_voc] = 'cat';
$this->drupalPostRequest('node/add/page', $edit, 'Submit');

However, this results in the following error message when running the test:

[browser] Setting taxonomy="Array" at [/Applications/MAMP/htdocs/drupal-5.7/sites/all/modules/simpletest/drupal_test_case.php line 111]

Anybody can please tell me what's the right way of doing what I'm trying to do?

Thanks!
Ángel.-

Comments

It looks like you're trying

catch's picture

It looks like you're trying to access the form array directly instead of what the browser sees. $edit needs to contain the form element as it's rendered in html. So a freetagging vocabulary produces html like

<input id="edit-taxonomy-tags-1" class="form-text form-autocomplete" type="text" value="" size="60" name="taxonomy[tags][1]" maxlength="255" autocomplete="OFF"/>

Meaning that line would look more like this:

$edit["taxonomy[tags][$vid]"] = 'cat';

You were right

angeliti's picture

That was exactly the problem.

Thank you very much!! =)
Ángel.-

Testing and Quality Assurance

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: