当前位置: 首页>>代码示例>>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;未经允许,请勿转载。