From 1e9aeaef3e4b16a285823a0810fffca573ea803f Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 18 Mar 2010 02:54:08 +0000 Subject: [PATCH] BUGFIX Fixed Folder writing by overloading validate() (was inheriting File->validate() which does extension checks) BUGFIX Fixed Folder::findOrMake() not to create "new-folder" through File->setName() if using a trailing slash in the path (which causes an empty name). Added FolderTest to verify this. git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@101266 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- filesystem/File.php | 11 +++++++--- filesystem/Folder.php | 12 ++++++++--- tests/filesystem/FolderTest.php | 36 +++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 tests/filesystem/FolderTest.php diff --git a/filesystem/File.php b/filesystem/File.php index 5e9598a74..e03da57fa 100755 --- a/filesystem/File.php +++ b/filesystem/File.php @@ -1,10 +1,10 @@ ParentID) { $p = DataObject::get_by_id('Folder', $this->ParentID); diff --git a/filesystem/Folder.php b/filesystem/Folder.php index 6f496b165..62f5ed67a 100755 --- a/filesystem/Folder.php +++ b/filesystem/Folder.php @@ -1,6 +1,7 @@ assertEquals(ASSETS_DIR . $path,$folder->getRelativePath(), + 'Nested path information is correctly saved to database (with trailing slash)' + ); + + $this->assertTrue(file_exists(ASSETS_PATH . $path), 'File'); + $parentFolder = DataObject::get_one('Folder', '"Name" = \'FolderTest\''); + $this->assertNotNull($parentFolder); + $this->assertEquals($parentFolder->ID, $folder->ParentID); + + $path = '/FolderTest/testFindOrMake'; + $folder = Folder::findOrMake($path); + $this->assertEquals(ASSETS_DIR . $path . '/',$folder->getRelativePath(), + 'Path information is correctly saved to database (without trailing slash)' + ); + } +} \ No newline at end of file