Example #1
0
<?php

try {
    phar::mount(1, 1);
} catch (Exception $e) {
    var_dump($e->getMessage());
}
Example #2
0
 public function version()
 {
     $this->writeInfo(sprintf($this->locale->_('atoum version %s by %s (%s)'), atoum\version, atoum\author, \phar::running()));
     return $this->stopRun();
 }
Example #3
0
 protected static function extractFilesTo(\recursiveDirectoryIterator $fromPharDirectory, $toDirectory)
 {
     $directory = rtrim($directory, DIRECTORY_SEPARATOR);
     $pharName = \phar::running();
     foreach (new \recursiveIteratorIterator($fromPharDirectory) as $pharFile) {
         $pharFilePath = ltrim(str_replace($pharName, '', $pharFile), DIRECTORY_SEPARATOR);
         if (strpos($pharFilePath, $versions['current']) === 0) {
             $path = $directory . '/' . ltrim(substr($pharFilePath, strlen($versions['current'])), DIRECTORY_SEPARATOR);
             $pathDirectory = dirname($path);
             @mkdir($pathDirectory, 0777, true);
             if (is_dir($pathDirectory) === false) {
                 throw new exceptions\runtime('Unable to create directory \'' . $pathDirectory . '\'');
             }
             $data = file_get_contents($pharFile);
             if (file_put_contents($path, $data) != strlen($data)) {
                 throw new exceptions\runtime('Unable to extract file \'' . $pharFilePath . '\' in directory \'' . $pathDirectory . '\'');
             }
         }
     }
     return $this;
 }
Example #4
0
 public function testVersion()
 {
     $this->given($this->newTestedInstance(uniqid()), $writer = new \mock\mageekguy\atoum\writer())->if($this->testedInstance->setInfoWriter($writer))->then->object($this->testedInstance->version())->isTestedInstance->mock($writer)->call('write')->withArguments(sprintf('atoum version %s by %s (%s)', atoum\version, atoum\author, \phar::running()))->once;
 }
Example #5
0
 public function testAddDirectory()
 {
     $this->if($autoloader = new atoum\autoloader())->then->object($autoloader->addDirectory($namespace = uniqid(), $directory = uniqid()))->isIdenticalTo($autoloader)->array($autoloader->getDirectories())->isEqualTo(array('mageekguy\\atoum\\' => array(atoum\directory . (\phar::running() ? '/' : DIRECTORY_SEPARATOR) . 'classes' . DIRECTORY_SEPARATOR), $namespace . '\\' => array($directory . DIRECTORY_SEPARATOR)))->object($autoloader->addDirectory($otherNamespace = uniqid() . '\\', $otherDirectory = uniqid() . DIRECTORY_SEPARATOR))->isIdenticalTo($autoloader)->array($autoloader->getDirectories())->isEqualTo(array('mageekguy\\atoum\\' => array(atoum\directory . (\phar::running() ? '/' : DIRECTORY_SEPARATOR) . 'classes' . DIRECTORY_SEPARATOR), $namespace . '\\' => array($directory . DIRECTORY_SEPARATOR), $otherNamespace => array($otherDirectory)))->object($autoloader->addDirectory($namespace, $secondDirectory = uniqid() . DIRECTORY_SEPARATOR))->isIdenticalTo($autoloader)->array($autoloader->getDirectories())->isEqualTo(array('mageekguy\\atoum\\' => array(atoum\directory . (\phar::running() ? '/' : DIRECTORY_SEPARATOR) . 'classes' . DIRECTORY_SEPARATOR), $namespace . '\\' => array($directory . DIRECTORY_SEPARATOR, $secondDirectory), $otherNamespace => array($otherDirectory)));
 }
Example #6
0
<?php

namespace mageekguy\atoum;

use mageekguy\atoum, mageekguy\atoum\scripts\phar;
if (extension_loaded('phar') === false) {
    throw new \runtimeException('Phar extension is mandatory to use this PHAR');
}
define(__NAMESPACE__ . '\\phar\\name', 'atoum.phar');
\phar::mapPhar(atoum\phar\name);
$versions = unserialize(file_get_contents('phar://' . atoum\phar\name . '/versions'));
require_once 'phar://' . atoum\phar\name . '/' . $versions['current'] . '/classes/autoloader.php';
if (defined(__NAMESPACE__ . '\\scripts\\runner') === false) {
    define(__NAMESPACE__ . '\\scripts\\runner', __FILE__);
}
if (phar\stub::autorunMustBeEnabled() === true) {
    phar\stub::enableAutorun(constant(__NAMESPACE__ . '\\scripts\\runner'));
}
__halt_compiler();
Example #7
0
function gtk_die($message)
{
    $dialog = new GtkMessageDialog(null, 0, Gtk::MESSAGE_ERROR, Gtk::BUTTONS_OK, $message);
    $dialog->set_markup("<b>{$message}</b>\nPlease refer to the future docs for details!");
    $dialog->run();
    $dialog->destroy();
    die($message . "\n");
}
if (!extension_loaded('php-gtk')) {
    die("ERROR: PHP Gtk2 not loaded!\n");
}
if (version_compare('5.3.0', PHP_VERSION, '>')) {
    gtk_die('PHP Explorer requires PHP 5.3.0 or newer.');
}
if (!extension_loaded('phar')) {
    gtk_die('PHAR Extension not loaded! Terminating.');
}
if (!phar::canCompress()) {
    gtk_die('PHAR Extension has no compression support.');
}
if (basename(__FILE__) == 'explorer.php') {
    define('BASEDIR', __DIR__);
} else {
    define('BASEDIR', 'phar://' . __FILE__);
}
ini_set('include_path', BASEDIR . PATH_SEPARATOR . ini_get('include_path'));
include 'Explorer/Application.php';
$app = new Explorer\Application();
$app->run();
__halt_compiler(); ?>