Example #1
0
 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);
 }