$form->bind(array('name' => $f2->name)); $t->ok(!$form->isValid(), 'The form is not valid'); $t->comment('Submit form with bad name'); $form->bind(array('name' => '£/')); $t->ok(!$form->isValid(), 'The form is not valid'); $t->comment('Submit form with good name'); $form->bind(array('name' => 'f1bis')); $t->ok($form->isValid(), 'The form is valid'); $t->comment('Save changed form'); $form->save(); $t->is($f1->name, 'f1bis', $f1->name); $t->is($f1->fullPath, $parent->fullPath . '/f1bis', $f1->fullPath); $t->is($f1->exists(), true, 'Folder f1bis exists'); $t->ok(!is_dir($f1FullPath), 'Folder f1 does no more exist'); $t->comment('Renaming a folder which has children'); $form = new DmAdminRenameMediaFolderForm($parent); $parentFullPath = $parent->fullPath; $f1bisFullPath = $f1->fullPath; $f2FullPath = $f2->fullPath; $form->bind(array('name' => 'parentbis')); $t->ok($form->isValid(), 'form is valid'); $form->save(); $t->is($parent->name, 'parentbis', $parent->name); $t->is($parent->fullPath, $grandParent->fullPath . '/parentbis', $parent->fullPath); $t->is($parent->exists(), true, 'Folder parentbis exists'); $t->ok(!is_dir($parentFullPath), 'Folder parent does no more exist'); $t->ok(!is_dir($f1bisFullPath), 'Folder f1bis does no more exist'); $t->is($f1->fullPath, $parent->fullPath . '/f1bis', 'f1bis full path is ' . $f1->fullPath); $t->ok($f1->exists(), 'Moved folder f1bis exists'); $t->ok(!is_dir($f2FullPath), 'Folder f2 does no more exist'); $t->is($f2->fullPath, $parent->fullPath . '/f2', 'f2 full path is ' . $f2->fullPath);
public function executeRenameFolder(sfWebRequest $request) { $this->forward404Unless($folder = dmDb::table('DmMediaFolder')->find($request->getParameter('id')), 'can not find folder'); if (!$folder->isWritable()) { $this->getUser()->logAlert($this->getI18n()->__('Folder %1% is not writable', array('%1%' => $folder->getRelPath()))); return $this->renderPartial('dmInterface/flash'); } $form = new DmAdminRenameMediaFolderForm($folder); if ($request->isMethod('post') && $form->bindAndValid($request)) { return $this->renderText($this->getRouting()->getMediaUrl($form->save())); } return $this->renderText($form->render('.dm_form.list.little action="dmMediaLibrary/renameFolder?id=' . $folder->id . '"')); }