コード例 #1
0
 /**
  * Sets up test case - initializes directory in %TEMP
  *
  */
 public function setUp()
 {
     $this->temp = $this->normalize(realpath(System::tempDir())) . md5(uniqid()) . '.xp' . DIRECTORY_SEPARATOR;
     if (is_dir($this->temp) && !rmdir($this->temp)) {
         throw new PrerequisitesNotMetError('Fixture directory exists, but cannot remove', NULL, $this->temp);
     }
 }
コード例 #2
0
 public function setUp()
 {
     $tempDir = realpath(System::tempDir());
     $this->fixture = new FilesystemPropertySource($tempDir);
     // Create a temporary ini file
     $this->tempFile = new File($tempDir, 'temp.ini');
     FileUtil::setContents($this->tempFile, "[section]\nkey=value\n");
 }
コード例 #3
0
 public static function verifyTempDir()
 {
     self::$temp = System::tempDir();
     if (!is_writeable(self::$temp)) {
         throw new PrerequisitesNotMetError('$TEMP is not writeable', null, [self::$temp . ' +w']);
     }
     if (($df = disk_free_space(self::$temp)) < 10240) {
         throw new PrerequisitesNotMetError('Not enough space available in $TEMP', null, [sprintf('df %s = %.0fk > 10k', self::$temp, $df / 1024)]);
     }
 }
コード例 #4
0
 public function runningDirectory()
 {
     new Process(System::tempDir());
 }
コード例 #5
0
ファイル: Runner.class.php プロジェクト: Gamepay/xp-framework
 /**
  * Main runner method
  *
  * @param   string[] args
  */
 public static function main(array $args)
 {
     if (!$args) {
         self::usage();
     }
     // Parse arguments
     $output = '-';
     for ($i = 0, $s = sizeof($args); $i < $s; $i++) {
         if ('-O' == $args[$i]) {
             $output = $args[++$i];
         } else {
             if ('-?' == $args[$i] || '--help' == $args[$i]) {
                 self::usage();
             } else {
                 $package = $args[$i];
                 break;
             }
         }
     }
     // Load generator class
     try {
         $class = Package::forName('xp.codegen')->getPackage($package)->loadClass('Generator');
     } catch (ElementNotFoundException $e) {
         Console::$err->writeLine('*** No generator named "' . $package . '"');
         exit(2);
     }
     $params = new ParamString(array_slice($args, $i + 1));
     if ($params->exists('help', '?')) {
         Console::$err->writeLine(self::textOf($class->getComment()));
         exit(1);
     }
     // Instantiate generator
     $generator = $class->newInstance($params);
     $generator->storage = new FileSystemStorage(System::tempDir());
     // Output
     if ('-' === $output) {
         $generator->output = new ConsoleOutput(Console::$err);
     } else {
         if (strstr($output, '.xar')) {
             $generator->output = new ArchiveOutput($output);
         } else {
             $generator->output = new FileSystemOutput($output);
         }
     }
     $generator->output->addObserver(newinstance('util.Observer', array(), '{
     public function update($obs, $arg= NULL) { Console::writeLine("     >> ", $arg); }
   }'));
     Console::writeLine('===> Starting ', $generator);
     // Compile target chain
     $empty = new ArrayList();
     $targets = create('new util.collections.HashTable<lang.reflect.Method, util.collections.HashTable<string, lang.Generic>>()');
     foreach ($class->getMethods() as $method) {
         if (!$method->hasAnnotation('target')) {
             continue;
         }
         $target = create('new util.collections.HashTable<string, lang.Generic>()');
         // Fetch dependencies
         if ($method->hasAnnotation('target', 'depends')) {
             $depends = create('new util.collections.Vector<lang.reflect.Method>()');
             foreach ((array) $method->getAnnotation('target', 'depends') as $dependency) {
                 $depends[] = $class->getMethod($dependency);
             }
             $target['depends'] = $depends;
         }
         // Fetch input
         if ($method->hasAnnotation('target', 'input')) {
             $arguments = create('new util.collections.Vector<lang.reflect.Method>()');
             foreach ((array) $method->getAnnotation('target', 'input') as $input) {
                 $arguments[] = $class->getMethod($input);
             }
             $target['arguments'] = $arguments;
         }
         $targets->put($method, $target);
     }
     // Invoke
     try {
         foreach ($targets->keys() as $method) {
             self::invoke($generator, $method, $targets);
         }
     } catch (TargetInvocationException $e) {
         Console::$err->writeLine('*** ', $e->getCause());
         exit(3);
     }
     $generator->output->commit();
     Console::writeLine('===> Done');
 }
コード例 #6
0
ファイル: PathTest.class.php プロジェクト: xp-framework/core
 public function links_resolved_in_realpath()
 {
     $temp = System::tempDir();
     $link = new Path($temp, 'link-to-temp');
     if (false === symlink($temp, $link)) {
         $this->skip('Cannot create ' . $link . ' -> ' . $temp);
     }
     $resolved = (new Path($link))->asRealpath()->toString();
     unlink($link);
     $this->assertEquals($temp, $resolved);
 }
コード例 #7
0
 /**
  * Sets up test case - initializes temp directory in %TEMP%
  *
  * @return void
  */
 public function setUp()
 {
     $this->folder = new Folder(System::tempDir(), md5(uniqid()) . '.xp');
     $this->folder->exists() && $this->folder->unlink();
     $this->folder->create();
 }
コード例 #8
0
 /**
  * Constructor
  *
  * @param   string prefix default "tmp"
  */
 public function __construct($prefix = 'tmp')
 {
     parent::__construct(tempnam(System::tempDir(), $prefix . uniqid((double) microtime())));
 }
コード例 #9
0
 public static function prepareTempDir()
 {
     self::$temp = new Folder(System::tempDir(), md5(uniqid()));
     self::$temp->create();
     session_save_path(self::$temp->getURI());
 }
コード例 #10
0
 public function callingMain()
 {
     $temp = System::tempDir();
     // Create web.ini in system's temp dir
     $ini = new File($temp, 'web.ini');
     $ini->open(FILE_MODE_WRITE);
     $ini->write("[app]\n" . "mappings=\"/:welcome\"\n" . "[app::welcome]\n" . "class=undefined\n" . "[app::welcome@dev]\n" . "class=\"" . self::$welcomeScriptlet->getName() . "\"\n");
     $ini->close();
     // Run
     ob_start();
     xp新criptlet愛unner::main(array($temp, $temp, 'dev', '/'));
     $content = ob_get_contents();
     ob_end_clean();
     $ini->unlink();
     // Assert
     $this->assertEquals('<h1>Welcome, we are open</h1>', $content);
 }