0

I'm trying to write a test that will do the following:

  • Create a user
  • Create an 'article' node
  • Upload a file via Media module
  • Insert that file into the body via pre-determined markup
  • Save the node
  • Load file usage info to ascertain usage was incremented on node save.

I know all this stuff works right when I test manually.

I know creating a user, letting that user create an article, and saving the node with custom body text works in the automated test.

I'm stuck on how to upload a file via the Media module's media library, the same way it would do if you pressed the 'media browser' button in a WYSIWYG editor that's set up to work with Media.

Ultimately I'd like to be able to test all the features of the latest patch in this issue: https://drupal.org/node/1268116 .

How do I include this type of file upload in my simpletest? I can't use the built-in file upload field because that would mess up testing of Media's handling of file usage tracking.

  • 1
    can you look in the Media modules /test directory and see how they run their simpletests and that form? Failing that Firebug and drupal_form_submit() with persistance turned on in FB will let you see all the parameters they pass through the Ajaxy file upload window. ... maybe these thoughts will help. – tenken Jan 7 '13 at 23:45
  • That is interesting. I didn't know that about Firebug and the Ajax variables. – beth Jan 7 '13 at 23:47
  • See this small tutorial regarding Firebug and submitting forms programmaticaly. lionide.wordpress.com/2010/12/06/… Still, look at the Tests in Media ... because guess what, they do it all in-code :) – tenken Jan 7 '13 at 23:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.