| @@ 124-141 (lines=18) @@ | ||
| 121 | Config::inst()->update('File', 'allowed_extensions', $orig); |
|
| 122 | } |
|
| 123 | ||
| 124 | public function testSetNameChangesFilesystemOnWrite() { |
|
| 125 | $file = $this->objFromFixture('File', 'asdf'); |
|
| 126 | $oldPath = $file->getFullPath(); |
|
| 127 | ||
| 128 | // Before write() |
|
| 129 | $file->Name = 'renamed.txt'; |
|
| 130 | $this->assertFileExists($oldPath, |
|
| 131 | 'Old path is still present'); |
|
| 132 | $this->assertFileNotExists($file->getFullPath(), |
|
| 133 | 'New path is updated in memory, not written before write() is called'); |
|
| 134 | ||
| 135 | $file->write(); |
|
| 136 | ||
| 137 | // After write() |
|
| 138 | clearstatcache(); |
|
| 139 | $this->assertFileNotExists($oldPath, 'Old path is removed after write()'); |
|
| 140 | $this->assertFileExists($file->getFullPath(), 'New path is created after write()'); |
|
| 141 | } |
|
| 142 | ||
| 143 | public function testSetParentIDChangesFilesystemOnWrite() { |
|
| 144 | $file = $this->objFromFixture('File', 'asdf'); |
|
| @@ 143-165 (lines=23) @@ | ||
| 140 | $this->assertFileExists($file->getFullPath(), 'New path is created after write()'); |
|
| 141 | } |
|
| 142 | ||
| 143 | public function testSetParentIDChangesFilesystemOnWrite() { |
|
| 144 | $file = $this->objFromFixture('File', 'asdf'); |
|
| 145 | $subfolder = $this->objFromFixture('Folder', 'subfolder'); |
|
| 146 | $oldPath = $file->getFullPath(); |
|
| 147 | ||
| 148 | // set ParentID |
|
| 149 | $file->ParentID = $subfolder->ID; |
|
| 150 | ||
| 151 | // Before write() |
|
| 152 | $this->assertFileExists($oldPath, |
|
| 153 | 'Old path is still present'); |
|
| 154 | $this->assertFileNotExists($file->getFullPath(), |
|
| 155 | 'New path is updated in memory, not written before write() is called'); |
|
| 156 | ||
| 157 | $file->write(); |
|
| 158 | ||
| 159 | // After write() |
|
| 160 | clearstatcache(); |
|
| 161 | $this->assertFileNotExists($oldPath, |
|
| 162 | 'Old path is removed after write()'); |
|
| 163 | $this->assertFileExists($file->getFullPath(), |
|
| 164 | 'New path is created after write()'); |
|
| 165 | } |
|
| 166 | ||
| 167 | /** |
|
| 168 | * @see http://open.silverstripe.org/ticket/5693 |
|
| @@ 109-128 (lines=20) @@ | ||
| 106 | /** |
|
| 107 | * @see FileTest->testSetParentIDChangesFilesystemOnWrite() |
|
| 108 | */ |
|
| 109 | public function testSetParentIDChangesFilesystemOnWrite() { |
|
| 110 | $folder1 = $this->objFromFixture('Folder', 'folder1'); |
|
| 111 | $folder2 = $this->objFromFixture('Folder', 'folder2'); |
|
| 112 | $oldPathFolder1 = $folder1->getFullPath(); |
|
| 113 | ||
| 114 | // set ParentID |
|
| 115 | $folder1->ParentID = $folder2->ID; |
|
| 116 | ||
| 117 | // Before write() |
|
| 118 | $this->assertFileExists($oldPathFolder1, 'Old path is still present'); |
|
| 119 | $this->assertFileNotExists($folder1->getFullPath(), |
|
| 120 | 'New path is updated in memory, not written before write() is called'); |
|
| 121 | ||
| 122 | $folder1->write(); |
|
| 123 | ||
| 124 | // After write() |
|
| 125 | clearstatcache(); |
|
| 126 | $this->assertFileNotExists($oldPathFolder1, 'Old path is removed after write()'); |
|
| 127 | $this->assertFileExists($folder1->getFullPath(), 'New path is created after write()'); |
|
| 128 | } |
|
| 129 | ||
| 130 | /** |
|
| 131 | * Tests for the bug #5994 - Moving folder after executing Folder::findOrMake will not set the Filenames properly |
|