Hello,
In a module, i need to create archive files from some data. I want to run unit tests on this creation. Files are stored in sites/default/files/archive_currency/
:
$filepath = file_directory_path() . '/archive_currency';
$filename = 'change'.date('Y-m-d', time()).'.xml';
file_save_data($output,"$filepath/$filename");
Here is my test :
$archive = file_directory_path() . '/archive_currency/change' . date('Y-m-d', time()) . '.xml';
$this->assertTrue(file_exists($archive), 'The archive file is create.');
The test never validates although i think it should.
Here is the path that it gives me for the file : /default/files/simpletest287745/archive_currency/change2010-04-07.xml
No directory simpletestXXXXX exists.
Permissions are properly set on the files directory.
Does anyone have an idea?
Comments
Comment #1
rpetrenko commentedtry this:
keep in mind that after that test is finished due to simpletest self-cleanup the directory (along with you file) will be deleted. But you will know that the file was created using this test:
Comment #3
boombatower commentedAre you creating the file during the test because the testing system changes the files directory so it can clean it up when done? Please re-open with more details if having issue.