I am not sure this is an issue, but i have been designing a custom module for a client that creates a directory inside the hook_install function. When I run my test it returns that the folder is there, but not writeable. Which in turn makes the file upload return the error message "The selected file %file could not be uploaded, because the destination %directory is not properly configured.".

Putting :

$path = file_directory_path().'/pdf_templates';
file_check_directory($path, FILE_CREATE_DIRECTORY);

Directly into the test function or the setUp function solves the problem.

Again, I am not sure if this is a problem, but I thought I'd post it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Yeah this is a problem. SimpleTests sets the new file directory variables after it's run all the module installs. We should probably fix this in D7 core first then backport.

sndev’s picture

Title: module install files being run? » file_directory needs to be set before module install
Priority: Minor » Normal
boombatower’s picture

Status: Active » Closed (duplicate)

I am assuming that is related to #577398: Ensure test coverage of simpletest temporary file handling or should be included if not.

Dave Reid’s picture

Status: Closed (duplicate) » Active

This isn't actually a duplicate of it. SimpleTest module has always set the files directory variable after modules have been installed, even before the File API patch landed. I think we need a new issue for core to fix this and backport it.

Dave Reid’s picture

Issue tags: +XML sitemap

Tagging since XML sitemap module maintains a workaround in its test helper's setUp functions until this is fixed.

Dave Reid’s picture

Issue tags: +contrib dependency

Forgot this tag as well.

Dave Reid’s picture

Project: SimpleTest » Drupal core
Version: 6.x-2.x-dev » 7.x-dev
Component: Code » simpletest.module
Priority: Normal » Critical
sndev’s picture

FileSize
1.31 KB

I moved the variable_set calls for the file directories before the initial profile module install. I have tested it somewhat in D6, but don't really have a use case in D7.

c960657’s picture

Status: Active » Reviewed & tested by the community

I think this looks fine. Did some rudimentary testing with D7.

Anonymous’s picture

+1 from me too, don't know why we didn't see this earlier.

perhaps add a comment in there stating why we need to do this early?

webchick’s picture

Priority: Critical » Normal
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

I think a comment isn't really necessary here (never thought you'd hear me say THAT huh?!). I can't imagine people moving this block of code around willy-nilly.

What would be nice is a test for this use case, though. Then they *for sure* won't move the code around willy-nilly. ;)

Also, this smells a bit edge-casey to me to be critical.

sndev’s picture

I wrote a test that uses the image module as a guinea pig. The problem only occurs if the folders/files are installed during setUp. This doesn't occur in most core modules, but image, simpletest and a bunch of contribs do utilize the functionality. I don't think the test is in the right place, but going through the simpletest/modules folder is a bit beyond me.

Anonymous’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, simpletest_folder_test_with_move.patch, failed testing.

sndev’s picture

My last test was a little over zelous. running the uninstall modules function brought up a db error regarding uncreated tables. Lets try something a bit simpler.

sndev’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, simpletest_folder_test_with_move.patch, failed testing.

grendzy’s picture

Issue tags: +imagecache

This affects imagecache too.

Berdir’s picture

Status: Needs work » Needs review
FileSize
2.38 KB

This just failed because there was a "." added to the comment below, This is just a re-roll.

gowriabhaya’s picture

Issue tags: +TestingPartySF

Code sprint tag

jrbeeman’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
2.38 KB

Patch successfully applied to a fresh CVS checkout and test passes. Minor cosmetic change made to patch ("Directory Created" to "Directory created").

Dave Reid’s picture

Looks great and I've been using this patch for a while now on core with XML sitemap tests, which create a folder on install.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks.

Status: Fixed » Closed (fixed)
Issue tags: -imagecache, -Needs tests, -XML sitemap, -contrib dependency, -TestingPartySF

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