當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Dir::rename方法代碼示例

本文整理匯總了PHP中Dir::rename方法的典型用法代碼示例。如果您正苦於以下問題:PHP Dir::rename方法的具體用法?PHP Dir::rename怎麽用?PHP Dir::rename使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Dir的用法示例。


在下文中一共展示了Dir::rename方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testRenameDirs

 function testRenameDirs()
 {
     $d = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/dir/");
     $d->touch();
     $this->assertTrue($d->exists(), "La directory non e' stata creata!!");
     $f1 = $d->newFile("my_file.txt");
     $f1->setContent("Ciao!!");
     $this->assertTrue($f1->exists(), "Il file non e' stato creato nella cartella!!");
     $d2 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/target/");
     $d2->delete(true);
     $this->assertFalse($d2->exists(), "La directory esiste gia'!!");
     $this->assertTrue($d->rename("target"));
     $this->assertFalse($d->exists(), "La directory non e' stata rinominata con successo!!");
     $this->assertTrue($d2->exists(), "La directory non e' stata rinominata con successo!!");
     $f2 = new File("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/target/my_file.txt");
     $this->assertTrue($f2->exists(), "Il file non e' stato spostato insieme alla directory!!");
     $d3 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/existing_dir/");
     $this->assertFalse($d2->rename("existing_dir"), "Il rename e' stato effettuato su una directory che gia' esiste!!");
     $this->assertFalse($d2->isEmpty(), "La directory non spostata non contiene piu' il suo file!!");
     $this->assertTrue($d3->isEmpty(), "La directory gia' esistente e' stata riempita con pattume!!");
     $this->expectException("InvalidParameterException");
     $d4 = new Dir("/" . FRAMEWORK_CORE_PATH . "tests/io/rename_test/another_target/buh/");
     $this->assertFalse($d2->rename("another_target/buh"), "Rename con spostamento andato a buon fine!!");
     $d2->delete(true);
 }
開發者ID:mbcraft,項目名稱:frozen,代碼行數:25,代碼來源:plain_dir_test.php


注:本文中的Dir::rename方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。