? Success

User tests: Successful: Unsuccessful:

avatar obsidev
obsidev
31 May 2014

We have to throw the error that the folder does not exist (and we do not ask to force the operation) but the test make the inverse.

Thinking about it, I guess that the test is right but the error message is wrong.

avatar obsidev obsidev - open - 31 May 2014
avatar obsidev obsidev - change - 31 May 2014
Labels Added: ? ?
avatar bnisevic
bnisevic - comment - 31 May 2014

I'm developer, let's say avarage one, and I don't understand from issue tracker and the message here what is desired behaviour for JFolder::copy when a folder exists? Can you give more info and step by step instruction how to test this?

avatar Achal-Aggarwal
Achal-Aggarwal - comment - 31 May 2014

JFolder::copy when used with force=false and the destination path already have source directory then it should throw a RuntimeException with message 'Destination folder already exists';

Best way to test it, is to write an assertion in phpunit at https://github.com/joomla/joomla-cms/blob/staging/tests/unit/suites/libraries/joomla/filesystem/JFolderTest.php#L28
as you can see test is marked as skip test. you just have to write an assertion to check for the exception.

example : https://github.com/Achal-Aggarwal/joomla-framework/blob/5ba411878ffbddbbe859114d3683aa10875418b6/src/Joomla/Filesystem/Tests/JFolderTest.php#L95

avatar obsidev
obsidev - comment - 31 May 2014

Hi,

Sorry, I had to write this PR fast, they were closing the doors of the bug squad session.

Here a little test case:
mkdir(JPath::clean(JPATH_ROOT . '/tmp/test'), 0777, true);
file_put_contents(JPath::clean(JPATH_ROOT . '/tmp/test/index.html'), 'test');
JFolder::copy(JPATH_ROOT . '/tmp/test', JPATH_ROOT . '/tmp/test2');
// The folder is copied correctly
file_put_contents(JPath::clean(JPATH_ROOT . '/tmp/test/index2.html'), 'test');
JFolder::copy(JPATH_ROOT . '/tmp/test', JPATH_ROOT . '/tmp/test2');
// The folder "test2" already exist, it throw an exception with the correct error message.

Regards,

avatar bnisevic
bnisevic - comment - 31 May 2014

Sorry. My previous post was wrong. This is what I get for the test case:

-1 Destination folder already exists

So it is good for merge.

avatar Bakual Bakual - close - 4 Jun 2014
avatar Bakual Bakual - change - 4 Jun 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-06-04 14:08:26
avatar Bakual Bakual - close - 4 Jun 2014

Add a Comment

Login with GitHub to post a comment