diff --git a/tests/filesystem/FolderTest.php b/tests/filesystem/FolderTest.php index 775278946..036fad84e 100644 --- a/tests/filesystem/FolderTest.php +++ b/tests/filesystem/FolderTest.php @@ -33,4 +33,48 @@ class FolderTest extends SapphireTest { 'Path information is correctly saved to database (without trailing slash)' ); } + + function testFilesystemFolderIsCreatedOnFirstWrite() { + $parentFolder = new Folder(); + $parentFolder->Name = '__FolderTest'; + $parentFolder->write(); + $this->assertEquals( + $parentFolder->getFullPath(), + ASSETS_PATH . '/' . $parentFolder->Name . '/', + 'Folder record creates matching path on filesystem on first write' + ); + $this->assertFileExists( + $parentFolder->getFullPath(), + 'Folder record without ParentID creates a folder in the $base_dir on filesystem on first write' + ); + + $childFolder = new Folder(); + $childFolder->ParentID = $parentFolder->ID; + $childFolder->Name = 'child'; + $childFolder->write(); + $this->assertEquals( + $childFolder->getFullPath(), + ASSETS_PATH . '/' . $parentFolder->Name . '/' . $childFolder->Name . '/', + 'Folder record creates matching path on filesystem on first write' + ); + $this->assertFileExists( + $childFolder->getFullPath(), + 'Folder record without ParentID creates a folder on filesystem on first write' + ); + } + + function testFolderNameCantDuplicate() { + $folder = new Folder(); + $folder->Name = 'myfolder'; + $folder->write(); + + $folder2 = new Folder(); + $folder2->Name = 'myfolder'; + $folder2->write(); + $this->assertNotEquals( + $folder->Name, + $folder2->Name, + 'Folder write renames to avoid duplicates on filesystem' + ); + } } \ No newline at end of file diff --git a/tests/model/FolderTest.php b/tests/model/FolderTest.php deleted file mode 100644 index 31711053a..000000000 --- a/tests/model/FolderTest.php +++ /dev/null @@ -1,50 +0,0 @@ -Name = '__FolderTest'; - $parentFolder->write(); - $this->assertEquals( - $parentFolder->getFullPath(), - ASSETS_PATH . '/' . $parentFolder->Name . '/', - 'Folder record creates matching path on filesystem on first write' - ); - $this->assertFileExists( - $parentFolder->getFullPath(), - 'Folder record without ParentID creates a folder in the $base_dir on filesystem on first write' - ); - - $childFolder = new Folder(); - $childFolder->ParentID = $parentFolder->ID; - $childFolder->Name = 'child'; - $childFolder->write(); - $this->assertEquals( - $childFolder->getFullPath(), - ASSETS_PATH . '/' . $parentFolder->Name . '/' . $childFolder->Name . '/', - 'Folder record creates matching path on filesystem on first write' - ); - $this->assertFileExists( - $childFolder->getFullPath(), - 'Folder record without ParentID creates a folder on filesystem on first write' - ); - } - - function testFolderNameCantDuplicate() { - $folder = new Folder(); - $folder->Name = 'myfolder'; - $folder->write(); - - $folder2 = new Folder(); - $folder2->Name = 'myfolder'; - $folder2->write(); - $this->assertNotEquals( - $folder->Name, - $folder2->Name, - 'Folder write renames to avoid duplicates on filesystem' - ); - } -} -?> \ No newline at end of file