mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-09-09 03:01:18 +02:00
ENHANCEMENT Setting default folder title in Folder->populateDefaults() git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92563 467b73ca-7a2a-4603-9d3b-597d59a354a9
50 lines
1.4 KiB
PHP
50 lines
1.4 KiB
PHP
<?php
|
|
class FolderTest extends SapphireTest {
|
|
|
|
protected $orig = array();
|
|
|
|
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'
|
|
);
|
|
}
|
|
}
|
|
?>
|