/** @test */ function testBlackHole() { $f = new File("/test/BlackHoleTest.php"); $this->assertTrue($f->exists(), "Il file del test non esiste!!"); $content = $f->getContent(); $f->delete(); $this->assertFalse($f->exists(), "Il file del test black hole non e' stato eliminato!!"); $f->touch(); $f->setContent($content); $this->assertTrue($f->exists(), "Il file del test black hole non e' stato rigenerato!!"); }
/** * Execute the command. * * @return void */ public function handle() { $f = new File("/storage/logs/laravel.log"); $f->setContent(""); $this->info("Log cleared succesfully! The log is now empty."); }
function testRecursivePermissionsOnDir() { $d = new Dir("/test/permissions_test/rec/"); $d->touch(); $d1 = new Dir("/test/permissions_test/rec/d1/"); $d1->touch(); $d2 = new Dir("/test/permissions_test/rec/d1/d2/"); $d2->touch(); $this->assertTrue($d2->exists(), "La directory interna non è stata creata!!"); $f1 = new File("/test/permissions_test/rec/d1/f1.txt"); $f1->setContent("abc"); $this->assertTrue($f1->exists(), "Il file interno non è stata creato!!"); $f2 = new File("/test/permissions_test/rec/d1/d2/f2.txt"); $f2->setContent("xyz"); $this->assertTrue($f2->exists(), "Il file interno non è stata creato!!"); $p = "rwxr-xr-x"; $do_permissions_tests = $d->setPermissions($p, true); if ($do_permissions_tests) { $this->assertEquals($p, $d->getPermissions(), "I permessi impostati ricorsivamente non corrispondono!"); $this->assertEquals($p, $d1->getPermissions(), "I permessi impostati ricorsivamente non corrispondono!"); $this->assertEquals($p, $f1->getPermissions(), "I permessi impostati ricorsivamente non corrispondono!"); $this->assertEquals($p, $d2->getPermissions(), "I permessi impostati ricorsivamente non corrispondono!"); $this->assertEquals($p, $f2->getPermissions(), "I permessi impostati ricorsivamente non corrispondono!"); $p2 = "rwxr-----"; $d->setPermissions($p2, true); $this->assertEquals($p2, $d->getPermissions(), "I permessi impostati ricorsivamente non corrispondono!"); $this->assertEquals($p2, $d1->getPermissions(), "I permessi impostati ricorsivamente non corrispondono!"); $this->assertEquals($p2, $f1->getPermissions(), "I permessi impostati ricorsivamente non corrispondono!"); $this->assertEquals($p2, $d2->getPermissions(), "I permessi impostati ricorsivamente non corrispondono!"); $this->assertEquals($p2, $f2->getPermissions(), "I permessi impostati ricorsivamente non corrispondono!"); } $d->delete(); }
private function savePHPArrayProperties($target_props, File $target_lang_file) { $header = <<<END_OF_HEADER <?php END_OF_HEADER; $footer = <<<END_OF_FOOTER END_OF_FOOTER; $full_content = $header . "return " . var_export($target_props, true) . ";" . $footer; $target_lang_file->setContent($full_content); }
function testRenameFiles() { $f1 = new File("/test/rename_test/a/my_file.txt"); $this->assertFalse($f1->exists(), "Il file f1 esiste!!"); $f1->setContent("Ciao!!"); $this->assertTrue($f1->exists(), "Il file f1 non esiste!!"); $f3 = new File("/test/rename_test/a/another_name_again.txt"); $this->assertFalse($f3->exists(), "Il file f3 esiste gia'!!"); $f1->rename("another_name_again.txt"); $this->assertFalse($f1->exists(), "Il file f1 esiste ancora!!"); $this->assertTrue($f3->exists(), "Il rename non e' andato a buon fine!!"); $f3->delete(); }