Hey,

I just noticed that drupalGetTestFiles('image') returns nothing as there are no images in the 'files/simpletest' directory.
I had a look into it and the only place I can see files being put into the 'files/simpletest' directory is in the .install file, which is only creating binary and text files, yet there is a directory in simpletest module directory full of files.

Is it a bug, or am I using the wrong function? Is there a function other than drupalGetTestFiles to reference the test files in the 'modules/simpletest/files' directory?

Cheers,
Deciphered.

CommentFileSizeAuthor
#3 487090.patch1.58 KBdave reid

Comments

dave reid’s picture

Status: Active » Postponed (maintainer needs more info)

It should not be referencing files from modules/simpletest/files...it should be your site's files directory (i.e. sites/yoursite.com/files/simpletest). What do you have in that directory (replace yoursite.com with default or the multisite folder for your site)?

deciphered’s picture

Status: Postponed (maintainer needs more info) » Active

Hi Dave,

I realize this, maybe I was being to general when I said 'files/simpletest', I was of course referring to 'sites/default/files/simpletest' or 'sites/yoursite.com/files/simpletest'.

The directory only has the files that the .install file creates:
binary-1.txt
binary-2.txt
text-1.txt
text-2.txt
text-3.txt
text-4.txt
text-5.txt

Which means that when drupalGetTestFiles scans for any $type other than 'binary' or 'text' it won't return any files, as to be expected as no other files exist.

It appears to me that there is something missing in either simpletest_install or drupalGetTestFiles, such as a file_copy() call to duplicate the test files from 'sites/all/modules/simpletest/files' to 'sites/default/files/simpletest'.

I checked the install file of the DRUPAL 7 version and it looked roughly the same. I have not checked the drupalGetTestFiles in the DRUPAL 7 version, or tested the DRUPAL 7 version.

dave reid’s picture

Title: No images in /files/simpletest » Drupal 7 functions in simpletest_install()
Status: Active » Needs review
StatusFileSize
new1.58 KB

I uninstalled SimpleTest then installed it again, and confirmed that it only created the 'generated' files into sites/default/files/simpletest and did not copy any of the files from sites/all/modules/simpletest/files. A look into simpletest_install() shows that the D7-PREG syntax was used in file_scan_directory() instead of the D6-EREG syntax. With this patch, all the files were copied/generated correctly. Patch also fixes the fact that there is no file_unmanaged_copy in D6. It's file_copy(). :) We didn't catch this since the foreach loop never executed.

Give this patch a try!

deciphered’s picture

Status: Needs review » Reviewed & tested by the community

Worked like a charm, thanks Dave.

boombatower’s picture

Seems to be related to #304936: SimpleTest proper installation of test files and removal which just needs to be backported?

dave reid’s picture

It will help, but we still need to be using the D6 functions and ereg-style regular expressions in drupal_scan_directory().

boombatower’s picture

Status: Reviewed & tested by the community » Fixed

Fixed per #567422: Fresh backport of Drupal 7 SimpleTest please reopen if not.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.