예제 #1
0
 function __construct(File $f)
 {
     $this->name = $f->getName();
     $file_php_content = $f->getContent();
     $pure_php_content = str_replace("<?php", "", $file_php_content);
     $this->data = eval($pure_php_content);
     $this->flattened = LangGeneratorHelper::flattenKeys($this->data);
 }
예제 #2
0
 /**
     @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!!");
 }
예제 #3
0
파일: DirTest.php 프로젝트: mbcraft/piol
 function testCopy()
 {
     $source_dir = new Dir("/test/copy_source/");
     $target_dir = new Dir("/test/copy_target/");
     //pulisco la cartella di destinazione
     $results = $target_dir->listElements();
     $all_results = array_merge($results[0], $results[1]);
     foreach ($all_results as $f) {
         $f->delete(true);
     }
     $results = $source_dir->listElements();
     $source_dir_elems = array_merge($results[0], $results[1]);
     foreach ($source_dir_elems as $elem) {
         $elem->copy($target_dir);
     }
     $tiny_file = new File("/test/copy_target/my_tiny_file.txt");
     $this->assertTrue($tiny_file->exists(), "Il file non è stato copiato!!");
     $this->assertEquals($tiny_file->getContent(), "TINY TINY TINY", "Il contenuto del file non corrisponde!!");
     $my_subdir = new Dir("/test/copy_target/my_subdir");
     $this->assertTrue($my_subdir->exists(), "La sottocartella non è stata copiata!!");
     $another_file = new File("/test/copy_target/my_subdir/another_file.txt");
     $this->assertTrue($another_file->exists(), "Il file non è stato copiato!!");
     $this->assertEquals($another_file->getContent(), "BLA BLA BLA", "Il contenuto del file non corrisponde!!");
     $results = $target_dir->listElements();
     $all_results = array_merge($results[0], $results[1]);
     foreach ($all_results as $f) {
         $f->delete(true);
     }
 }
예제 #4
0
파일: FileTest.php 프로젝트: mbcraft/piol
 function testIncludeAndDelete()
 {
     $f = new File("/test/files_to_include/include_and_delete_me.php.inc");
     $this->assertTrue($f->exists(), "Il file da includere e cancellare non esiste!!");
     $this->assertFalse(class_exists("IncludeDeletedClass"), "La classe IncludeDeletedClass esiste prima dell'inclusione del file.");
     $f->requireFileOnce();
     $this->assertTrue(class_exists("IncludeDeletedClass"), "La classe IncludeDeletedClass non e' stata caricata dopo l'inclusione del file.");
     $content = $f->getContent();
     $f->delete();
     $this->assertFalse($f->exists(), "Il file da includere e cancellare non e' stato eliminato!!");
     $f->touch();
     $f->setContent($content);
     $this->assertTrue($f->exists(), "Il file da includere e cancellare non e' stato rigenerato!!");
 }