Esempio n. 1
0
 public function test_dnc()
 {
     global $CFG;
     if ($CFG->ostype === 'UNIX') {
         // Try it the faster way.
         $oldcwd = getcwd();
         chdir($CFG->dirroot);
         $output = null;
         $exclude = array();
         foreach ($this->extensions_to_ignore as $ext) {
             $exclude[] = '--exclude="*.' . $ext . '"';
         }
         $exclude = implode(' ', $exclude);
         exec('grep -r ' . $exclude . ' DONOT' . 'COMMIT .', $output, $code);
         chdir($oldcwd);
         // Return code 0 means found, return code 1 means NOT found, 127 is grep not found.
         if ($code == 1) {
             // Executed only if no file failed the test.
             $this->assertTrue(true);
             return;
         }
     }
     $regexp = '/\\.(' . implode('|', $this->extensions_to_ignore) . ')$/';
     $this->badstrings = array();
     $this->badstrings['DONOT' . 'COMMIT'] = 'DONOT' . 'COMMIT';
     // If we put the literal string here, it fails the test!
     $this->badstrings['trailing whitespace'] = "[\t ][\r\n]";
     foreach ($this->badstrings as $description => $ignored) {
         $this->allok[$description] = true;
     }
     $this->recurseFolders($CFG->dirroot, 'search_file_for_dnc', $regexp, true);
     $this->assertTrue(true);
     // Executed only if no file failed the test.
 }
Esempio n. 2
0
 /**
  * Executes Composer and runs a specified command (e.g. install / update)
  */
 public function execute()
 {
     $path = $this->phpci->buildPath;
     $build = $this->build;
     if ($this->directory == $path) {
         return false;
     }
     $filename = str_replace('%build.commit%', $build->getCommitId(), $this->filename);
     $filename = str_replace('%build.id%', $build->getId(), $filename);
     $filename = str_replace('%build.branch%', $build->getBranch(), $filename);
     $filename = str_replace('%project.title%', $build->getProject()->getTitle(), $filename);
     $filename = str_replace('%date%', date('Y-m-d'), $filename);
     $filename = str_replace('%time%', date('Hi'), $filename);
     $filename = preg_replace('/([^a-zA-Z0-9_-]+)/', '', $filename);
     $curdir = getcwd();
     chdir($this->phpci->buildPath);
     if (!is_array($this->format)) {
         $this->format = array($this->format);
     }
     foreach ($this->format as $format) {
         switch ($format) {
             case 'tar':
                 $cmd = 'tar cfz "%s/%s.tar.gz" ./*';
                 break;
             default:
             case 'zip':
                 $cmd = 'zip -rq "%s/%s.zip" ./*';
                 break;
         }
         $success = $this->phpci->executeCommand($cmd, $this->directory, $filename);
     }
     chdir($curdir);
     return $success;
 }
 public function invokeService($source, $method, $data)
 {
     // locate source file
     $classFile = str_replace('.', '/', $source) . '.php';
     try {
         // All class paths will be relative to baseClassPath
         $dirname = realpath("./" . $this->baseClassPath);
         if (is_dir($dirname)) {
             chdir($dirname);
         } else {
             throw new Flex_BasepathNotFoundException($this->baseClassPath);
         }
         // Check to see if the source class it exists
         if (!file_exists($classFile)) {
             throw new SabreAMF_ClassNotFoundException($source);
         }
         $includeFlag = @(include_once $classFile);
         $lastPeriod = strrpos($source, ".");
         if ($lastPeriod > 0) {
             $lastPeriod++;
         }
         $className = substr($source, $lastPeriod, strlen($source) - $lastPeriod);
         //Check if class exists
         if (!class_exists($className)) {
             throw new SabreAMF_ClassNotFoundException($source);
         }
         $serviceInstance = new $className();
     } catch (Exception $e) {
         throw new SabreAMF_ClassNotFoundException($e->getMessage());
     }
     if (!method_exists($serviceInstance, $method)) {
         throw new SabreAMF_UndefinedMethodException($source, $method);
     }
     return call_user_func_array(array($serviceInstance, $method), $data);
 }
 public function run($path = '.')
 {
     chdir($path);
     $command = $this->phpspec . ' ' . $this->phpspec_options;
     exec($command, $return, $status);
     if ($status != 0) {
         $this->expiration_in_secs = 5;
         $this->notify("Error running test", $return[1], $this->fail_image);
     } else {
         $output = join("\n", $return);
         echo $output;
         foreach ($return as $line) {
             if (preg_match('/^([0-9]+) example/', $line, $matches)) {
                 $examples = $matches[1];
                 preg_match('/([0-9]+) failure/', $line, $matches);
                 $failures = $matches[1];
                 preg_match('/([0-9]+) pending/', $line, $matches);
                 $pendings = $matches[1];
             }
         }
         if ($failures > 0) {
             $this->notify("Tests Failed", $failures . "/" . $examples . ($failures == 1 ? " test failed" : " tests failed"), $this->fail_image);
         } elseif ($pendings > 0) {
             $this->notify("Tests Pending", $pendings . "/" . $examples . ($pendings == 1 ? " test is pending" : " tests are pending"), $this->pending_image);
         } else {
             $this->notify("Tests Passed", "All " . $examples . " tests passed", $this->success_image);
         }
     }
 }
 function its_preLoad_throws_when_configuration_file_not_exists(GenericEvent $event, ContainerInterface $container, PhpGuard $guard)
 {
     chdir(static::$tmpDir);
     $container->get('phpguard')->willReturn($guard);
     $guard->setOptions(array())->shouldBeCalled();
     $this->shouldThrow('InvalidArgumentException')->duringPreLoad($event);
 }
Esempio n. 6
0
 /**
  * Initializes git, makes tmp folders writeable, and adds the core submodules (or specified group)
  *
  * @return void
  */
 public function init($working)
 {
     $this->out(__d('baking_plate', "\n<info>Making temp folders writeable...</info>"));
     $tmp = array('tmp' . DS . 'cache', 'tmp' . DS . 'cache' . DS . 'models', 'tmp' . DS . 'cache' . DS . 'persistent', 'tmp' . DS . 'cache' . DS . 'views', 'tmp' . DS . 'logs', 'tmp' . DS . 'sessions', 'tmp' . DS . 'tests', 'webroot' . DS . 'ccss', 'webroot' . DS . 'cjs', 'webroot' . DS . 'uploads');
     foreach ($tmp as $dir) {
         if (!is_dir($working . DS . $dir)) {
             $this->out(__d('baking_plate', "\n<info>Creating Directory %s with permissions 0777</info>", $dir));
             mkdir($working . DS . $dir, 0777);
         } else {
             $this->out(__d('baking_plate', "\n<info>Setting Permissions of %s to 0777</info>", $dir));
             chmod($working . DS . $dir, 0777);
         }
     }
     $this->nl();
     chdir($working);
     $this->out();
     $this->out(passthru('git init'));
     $this->all();
     $this->args = null;
     if (!file_exists($working . 'Config' . DS . 'database.php')) {
         $this->DbConfig->path = $working . 'Config' . DS;
         $this->out();
         $this->out(__d('baking_plate', '<warning>Your database configuration was not found. Take a moment to create one.</warning>'));
         $this->DbConfig->execute();
     }
 }
Esempio n. 7
0
function unpack_zip_inner($zipfile, $clone) {
    global $webDir, $uid;

    require_once 'include/lib/fileUploadLib.inc.php';

    $zip = new pclZip($zipfile);
    if (!$clone) {
        validateUploadedZipFile($zip->listContent(), 3);
    }

    $destdir = $webDir . '/courses/tmpUnzipping/' . $uid;
    if (!is_dir($destdir)) {
        mkdir($destdir, 0755);
    }
    chdir($destdir);
    $zip->extract();

    $retArr = array();
    foreach (find_backup_folders($destdir) as $folder) {
        $retArr[] = array(
            'path' => $folder['path'] . '/' . $folder['dir'],
            'file' => $folder['dir'],
            'course' => preg_replace('|^.*/|', '', $folder['path'])
        );
    }
    
    chdir($webDir);
    return $retArr;
}
Esempio n. 8
0
 /**
  * @beforeScenario
  */
 public function prepWorkingDirectory()
 {
     $this->workingDirectory = tempnam(sys_get_temp_dir(), 'phpspec-behat');
     $this->filesystem->remove($this->workingDirectory);
     $this->filesystem->mkdir($this->workingDirectory);
     chdir($this->workingDirectory);
 }
Esempio n. 9
0
 /**
  * The constructor.
  */
 public function __construct($rootDir, $cwd = NULL, $initialMode = NULL)
 {
     //set the root directory that we'll be using; this is considered just like "/" in
     //	linux.  Directories above it are considered non-existent.
     if (!is_null($rootDir)) {
         parent::__construct(true);
         $this->root = ToolBox::resolve_path_with_dots($rootDir);
         //set the CURRENT working directory... this should be a RELATIVE path to $this->root.
         if (!is_null($cwd) and is_dir($rootDir . '/' . $cwd) and !preg_match('~' . $cwd . '~', $this->root)) {
             //looks good.  Use it.
             $this->cwd = $cwd;
             $this->realcwd = $this->root . '/' . $cwd;
         } else {
             //no dice.  Use the root.
             $this->cwd = '/';
             $this->realcwd = $this->root;
         }
         $this->realcwd = preg_replace('~/{2,}~', '/', $this->realcwd);
         chdir($this->realcwd);
         //check for the initialMode...
         $useableModes = array('r', 'r+', 'w', 'w+', 'a', 'a+', 'x', 'x+', 'c', 'c+');
         if ($initialMode and in_array($initialMode, $useableModes)) {
             //
             $this->mode = $initialMode;
         } else {
             //define the DEFAULT mode.
             $this->mode = "r+";
         }
     } else {
         throw new InvalidArgumentException(__METHOD__ . ": invalid root directory (" . $rootDir . ")");
     }
 }
Esempio n. 10
0
 /** @Given /^I am in a directory "([^"]*)"$/ */
 public function iAmInADirectory($dir)
 {
     if (!file_exists($dir)) {
         mkdir($dir);
     }
     chdir($dir);
 }
Esempio n. 11
0
 public function actionIndex()
 {
     $error = false;
     @chdir(Yii::getAlias('@app'));
     foreach ($this->folders as $folder => $writable) {
         if (!file_exists($folder)) {
             $mode = $writable ? 0777 : 0775;
             if (FileHelper::createDirectory($folder, $mode)) {
                 $this->outputSuccess("{$folder}: successfully created directory");
             } else {
                 $error = true;
                 $this->outputError("{$folder}: unable to create directory");
             }
         } else {
             $this->outputSuccess("{$folder}: directory exists");
         }
         if ($writable) {
             if (!is_writable($folder)) {
                 $error = true;
                 $this->outputError("{$folder}: is not writable, please change permissions.");
             }
         }
     }
     foreach ($this->files as $file) {
         if (file_exists($file)) {
             $this->outputSuccess("{$file}: file exists.");
         } else {
             $error = true;
             $this->outputError("{$file}: file does not exists!");
         }
     }
     return $error ? $this->outputError('Health check found errors!') : $this->outputSuccess('O.K.');
 }
 protected function setUp()
 {
     $this->tikiroot = dirname(__FILE__) . '/../../../';
     $this->lang = 'test_language';
     $this->langDir = $this->tikiroot . 'lang/' . $this->lang;
     chdir($this->tikiroot);
     mkdir($this->langDir);
     $this->obj = new LanguageTranslations($this->lang);
     TikiDb::get()->query('INSERT INTO `tiki_language` (`source`, `lang`, `tran`, `changed`) VALUES (?, ?, ?, ?)', array('Contributions by author', $this->lang, 'Contribuições por autor', 1));
     TikiDb::get()->query('INSERT INTO `tiki_language` (`source`, `lang`, `tran`, `changed`) VALUES (?, ?, ?, ?)', array('Remove', $this->lang, 'Novo remover', 1));
     TikiDb::get()->query('INSERT INTO `tiki_language` (`source`, `lang`, `tran`, `changed`) VALUES (?, ?, ?, ?)', array('Approved Status', $this->lang, 'Aprovado', 1));
     TikiDb::get()->query('INSERT INTO `tiki_language` (`source`, `lang`, `tran`, `changed`) VALUES (?, ?, ?, ?)', array('Something', $this->lang, 'Algo', 1));
     TikiDb::get()->query('INSERT INTO `tiki_language` (`source`, `lang`, `tran`, `changed`) VALUES (?, ?, ?, ?)', array('Trying to insert malicious PHP code back to the language.php file', $this->lang, 'asff"); echo \'teste\'; $dois = array(\'\',"', 1));
     TikiDb::get()->query('INSERT INTO `tiki_language` (`source`, `lang`, `tran`, `changed`) VALUES (?, ?, ?, ?)', array('Should escape "double quotes" in the source string', $this->lang, 'Deve escapar "aspas duplas" na string original', 1));
     TikiDb::get()->query('INSERT INTO `tiki_language` (`source`, `lang`, `tran`) VALUES (?, ?, ?)', array('Not changed', $this->lang, 'Translation not changed'));
     TikiDb::get()->query('INSERT INTO `tiki_untranslated` (`source`, `lang`) VALUES (?, ?)', array('Untranslated string 1', $this->lang));
     TikiDb::get()->query('INSERT INTO `tiki_untranslated` (`source`, `lang`) VALUES (?, ?)', array('Untranslated string 2', $this->lang));
     TikiDb::get()->query('INSERT INTO `tiki_untranslated` (`source`, `lang`) VALUES (?, ?)', array('Untranslated string 3', $this->lang));
     global ${"lang_{$this->lang}"};
     copy(dirname(__FILE__) . '/fixtures/language_orig.php', $this->langDir . '/language.php');
     if (!isset(${"lang_{$this->lang}"})) {
         require_once 'lib/init/tra.php';
         init_language($this->lang);
     }
 }
 public function initializePropel()
 {
     // build Propel om/map/sql/forms
     $files = glob(sfConfig::get('sf_lib_dir') . '/model/om/*.php');
     if (false === $files || !count($files)) {
         chdir(sfConfig::get('sf_root_dir'));
         $task = new sfPropelBuildModelTask($this->dispatcher, new sfFormatter());
         ob_start();
         $task->run();
         $output = ob_get_clean();
     }
     $files = glob(sfConfig::get('sf_data_dir') . '/sql/*.php');
     if (false === $files || !count($files)) {
         chdir(sfConfig::get('sf_root_dir'));
         $task = new sfPropelBuildSqlTask($this->dispatcher, new sfFormatter());
         ob_start();
         $task->run();
         $output = ob_get_clean();
     }
     $files = glob(sfConfig::get('sf_lib_dir') . '/form/base/*.php');
     if (false === $files || !count($files)) {
         chdir(sfConfig::get('sf_root_dir'));
         $task = new sfPropelBuildFormsTask($this->dispatcher, new sfFormatter());
         $task->run();
     }
 }
 public function run()
 {
     DB::table('mst_countries')->truncate();
     $country_name_full = array();
     $country_name_file = app_path() . "/country_name_new.txt";
     $myfile_country_name = fopen($country_name_file, "r") or die("Unable to open file!");
     $read_country_name_file = fread($myfile_country_name, filesize($country_name_file));
     $array_country_names = explode("\n", $read_country_name_file);
     foreach ($array_country_names as $key_country_names) {
         if ($key_country_names != null) {
             $country_name_list = explode(" ", $key_country_names);
             $country_name_full[$country_name_list[0]] = $country_name_list[1];
         }
     }
     $country_name_ja = "";
     $file_folder = public_path() . "/flags/";
     //use the directory class
     $files = dir($file_folder);
     //read all files ;from the  directory
     chdir($file_folder);
     $file_names = glob('*.png');
     $i = 1;
     //$c = 1;
     foreach ($file_names as $file_name) {
         $country_name_en = explode('.', $file_name, -1);
         if (!empty($country_name_full[$country_name_en[0]])) {
             $country_name_ja = $country_name_full[$country_name_en[0]];
         }
         $country = array("country_name" => $country_name_en[0], "flag_url" => "flags/" . $file_name, "country_name_ja" => $country_name_ja);
         Country::create($country);
         $i++;
         echo $i . "\n";
     }
     closedir($files->handle);
 }
 /**
  * @dataProvider getFormat
  * @runInSeparateProcess
  */
 public function testExecution($format)
 {
     $tmpDir = sys_get_temp_dir() . '/sf_hello';
     $filesystem = new Filesystem();
     $filesystem->remove($tmpDir);
     $filesystem->mkdirs($tmpDir);
     chdir($tmpDir);
     $tester = new CommandTester(new InitCommand());
     $tester->execute(array('--name' => 'Hello' . $format, '--app-path' => 'hello' . $format, '--web-path' => 'web', '--src-path' => 'src', '--format' => $format));
     // autoload
     $content = file_get_contents($file = $tmpDir . '/src/autoload.php');
     $content = str_replace("__DIR__.'/vendor", "'" . __DIR__ . "/../../../../src/vendor", $content);
     file_put_contents($file, $content);
     // Kernel
     $class = 'Hello' . $format . 'Kernel';
     $file = $tmpDir . '/hello' . $format . '/' . $class . '.php';
     $this->assertTrue(file_exists($file));
     $content = file_get_contents($file);
     $content = str_replace("__DIR__.'/../src/vendor/Symfony/src/Symfony/Bundle'", "'" . __DIR__ . "/../../../../src/vendor/Symfony/src/Symfony/Bundle'", $content);
     file_put_contents($file, $content);
     require_once $file;
     $kernel = new $class('dev', true);
     $response = $kernel->handle(Request::create('/'));
     $this->assertRegExp('/successfully/', $response->getContent());
     $filesystem->remove($tmpDir);
 }
Esempio n. 16
0
 public function execute()
 {
     global $wgUser;
     # Change to current working directory
     $oldCwd = getcwd();
     chdir($oldCwd);
     # Options processing
     $user = $this->getOption('u', 'Delete page script');
     $reason = $this->getOption('r', '');
     $interval = $this->getOption('i', 0);
     if ($this->hasArg()) {
         $file = fopen($this->getArg(), 'r');
     } else {
         $file = $this->getStdin();
     }
     # Setup
     if (!$file) {
         $this->error("Unable to read file, exiting", true);
     }
     $wgUser = User::newFromName($user);
     $dbw = wfGetDB(DB_MASTER);
     # Handle each entry
     for ($linenum = 1; !feof($file); $linenum++) {
         $line = trim(fgets($file));
         if ($line == '') {
             continue;
         }
         $page = Title::newFromText($line);
         if (is_null($page)) {
             $this->output("Invalid title '{$line}' on line {$linenum}\n");
             continue;
         }
         if (!$page->exists()) {
             $this->output("Skipping nonexistent page '{$line}'\n");
             continue;
         }
         $this->output($page->getPrefixedText());
         $dbw->begin();
         if ($page->getNamespace() == NS_FILE) {
             $art = new ImagePage($page);
             $img = wfFindFile($art->mTitle);
             if (!$img || !$img->isLocal() || !$img->delete($reason)) {
                 $this->output(" FAILED to delete image file... ");
             }
         } else {
             $art = new Article($page);
         }
         $success = $art->doDeleteArticle($reason);
         $dbw->commit();
         if ($success) {
             $this->output(" Deleted!\n");
         } else {
             $this->output(" FAILED to delete article\n");
         }
         if ($interval) {
             sleep($interval);
         }
         wfWaitForSlaves();
     }
 }
Esempio n. 17
0
/**
 * Bootstrap all of Drupal (DRUPAL_BOOTSTRAP_FULL phase) and set the
 * current working directory to the Drupal root path.
 */
function xcvs_bootstrap($xcvs)
{
    chdir($xcvs['drupal_path']);
    // Bootstrap Drupal so we can use Drupal functions to access the databases, etc.
    if (!file_exists('./includes/bootstrap.inc')) {
        fwrite(STDERR, "Error: failed to load Drupal's bootstrap.inc file.\n");
        exit(1);
    }
    // Set up a few variables, Drupal might not bootstrap without those.
    // Copied from scripts/drupal.sh.
    $_SERVER['HTTP_HOST'] = 'default';
    $_SERVER['PHP_SELF'] = '/index.php';
    $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
    $_SERVER['SERVER_SOFTWARE'] = 'PHP CLI';
    $_SERVER['REQUEST_METHOD'] = 'GET';
    $_SERVER['QUERY_STRING'] = '';
    $_SERVER['PHP_SELF'] = $_SERVER['REQUEST_URI'] = '/';
    // Set up the multisite directory if necessary.
    if ($xcvs['multisite_directory']) {
        $_SERVER['HTTP_HOST'] = $xcvs['multisite_directory'];
        // Set a dummy script name, so the multisite configuration
        // file search will always trigger.
        $_SERVER['SCRIPT_NAME'] = '/foo';
    }
    require_once './includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
}
Esempio n. 18
0
 function testDot()
 {
     $dir = new WatchmanDirectoryFixture();
     $root = $dir->getPath();
     try {
         $this->assertEqual(true, chdir($root), "failed to chdir {$root}");
         $this->assertEqual($root, getcwd(), "chdir/getcwd are consistent");
         $is_cli = $this->isUsingCLI();
         if (phutil_is_windows()) {
             $dot = '';
             $err = 'unable to resolve root : path "" must be absolute';
         } else {
             $dot = '.';
             $err = 'unable to resolve root .: path "." must be absolute';
         }
         $res = $this->watch($dot, false);
         if (!$this->isUsingCLI()) {
             $this->assertEqual($err, idx($res, 'error'));
         } else {
             $this->assertEqual(null, idx($res, 'error'));
             $this->assertEqual($root, idx($res, 'watch'));
         }
     } catch (Exception $e) {
         chdir($this->getRoot());
         throw $e;
     }
 }
Esempio n. 19
0
 /**
  * @dataProvider provideInvalidConfiguration
  */
 public function testInvalidConfiguration(array $extras, $exceptionMessage)
 {
     $this->package->getExtra()->willReturn($extras);
     chdir(__DIR__);
     $this->setExpectedException('InvalidArgumentException', $exceptionMessage);
     ScriptHandler::buildParameters($this->event->reveal());
 }
Esempio n. 20
0
 public function run(InputInterface $input, OutputInterface $output)
 {
     // extract real command name
     $tokens = preg_split('{\\s+}', $input->__toString());
     $args = array();
     foreach ($tokens as $token) {
         if ($token && $token[0] !== '-') {
             $args[] = $token;
             if (count($args) >= 2) {
                 break;
             }
         }
     }
     // show help for this command if no command was found
     if (count($args) < 2) {
         return parent::run($input, $output);
     }
     // change to global dir
     $config = Factory::createConfig();
     chdir($config->get('home'));
     $this->getIO()->writeError('<info>Changed current directory to ' . $config->get('home') . '</info>');
     // create new input without "global" command prefix
     $input = new StringInput(preg_replace('{\\bg(?:l(?:o(?:b(?:a(?:l)?)?)?)?)?\\b}', '', $input->__toString(), 1));
     $this->getApplication()->resetComposer();
     return $this->getApplication()->run($input, $output);
 }
Esempio n. 21
0
 /** Resolve full filesystem path of given URL. Returns FALSE if the URL
  * cannot be resolved
  * @param string $url
  * @return string */
 static function url2fullPath($url)
 {
     $url = self::normalize($url);
     $uri = isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : (isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : false);
     $uri = self::normalize($uri);
     if (substr($url, 0, 1) !== "/") {
         if ($uri === false) {
             return false;
         }
         $url = dirname($uri) . "/{$url}";
     }
     if (isset($_SERVER['DOCUMENT_ROOT'])) {
         return self::normalize($_SERVER['DOCUMENT_ROOT'] . "/{$url}");
     } else {
         if ($uri === false) {
             return false;
         }
         if (isset($_SERVER['SCRIPT_FILENAME'])) {
             $scr_filename = self::normalize($_SERVER['SCRIPT_FILENAME']);
             return self::normalize(substr($scr_filename, 0, -strlen($uri)) . "/{$url}");
         }
         $count = count(explode('/', $uri)) - 1;
         for ($i = 0, $chdir = ""; $i < $count; $i++) {
             $chdir .= "../";
         }
         $chdir = self::normalize($chdir);
         $dir = getcwd();
         if ($dir === false || !@chdir($chdir)) {
             return false;
         }
         $rdir = getcwd();
         chdir($dir);
         return $rdir !== false ? self::normalize($rdir . "/{$url}") : false;
     }
 }
Esempio n. 22
0
 protected function setUpEnvironment()
 {
     $kernelRootDir = $this->container->getParameter('kernel.root_dir');
     putenv(sprintf('COMPOSER_HOME=%s', $this->container->getParameter('oro_distribution.composer_cache_home')));
     chdir(realpath($kernelRootDir . '/../'));
     set_time_limit(0);
 }
Esempio n. 23
0
 /**
  * Implements CoreInterface::clearCache().
  */
 public function clearCache()
 {
     // Need to change into the Drupal root directory or the registry explodes.
     $current_path = getcwd();
     chdir(DRUPAL_ROOT);
     drupal_flush_all_caches();
 }
 public function setUp()
 {
     parent::setUp();
     $this->key1 = 'ssh-rsa AAAAYZi1ju3FeZu6EKKltZ0uftOfj6w== marcel@labobine.net';
     $this->key2 = 'ssh-rsa AAAAXYiTICSgWURDPDGW/HeNUYZIRcznQ== marcel@shanon.net';
     chdir('/var');
 }
 /**
  * Execute the command.
  *
  * @param Input $input
  * @param Output $output
  * @return void
  */
 protected function execute(Input $input, Output $output)
 {
     $name = $input->getArgument("name");
     // Validate the name straight away.
     if (count($chunks = explode("/", $name)) != 2) {
         throw new \InvalidArgumentException("Invalid repository name '{$name}'.");
     }
     $output->writeln(sprintf("Cloning <comment>%s</comment> into <info>%s/%s</info>...", $name, getcwd(), end($chunks)));
     // If we're in a test environment, stop executing.
     if (defined("ADVISER_UNDER_TEST")) {
         return null;
     }
     // @codeCoverageIgnoreStart
     if (!$this->git->cloneGithubRepository($name)) {
         throw new \UnexpectedValueException("Repository https://github.com/{$name} doesn't exist.");
     }
     // Change the working directory.
     chdir($path = getcwd() . "/" . end($chunks));
     $output->writeln(sprintf("Changed the current working directory to <comment>%s</comment>.", $path));
     $output->writeln("");
     // Running "AnalyseCommand"...
     $arrayInput = [""];
     if (!is_null($input->getOption("formatter"))) {
         $arrayInput["--formatter"] = $input->getOption("formatter");
     }
     $this->getApplication()->find("analyse")->run(new ArrayInput($arrayInput), $output);
     // Change back, remove the directory.
     chdir(getcwd() . "/..");
     $this->removeDirectory($path);
     $output->writeln("");
     $output->writeln(sprintf("Switching back to <info>%s</info>, removing <comment>%s</comment>...", getcwd(), $path));
     // @codeCoverageIgnoreStop
 }
Esempio n. 26
0
 public function setUp()
 {
     $this->tmpdir = sys_get_temp_dir() . '/' . uniqid('conveyor');
     $this->projectdir = $this->tmpdir . '/project';
     $this->reposdir = $this->tmpdir . '/repos';
     $this->reposurl = 'file:///' . $this->reposdir;
     $this->filesystem = new Filesystem();
     $this->filesystem->mkdir($this->tmpdir);
     $this->filesystem->mkdir($this->projectdir);
     $svnadminbin = getenv('SVNADMIN_BIN') ? getenv('SVNADMIN_BIN') : '/usr/local/bin/svnadmin';
     $svnbin = getenv('SVN_BIN') ? getenv('SVN_BIN') : '/usr/local/bin/svn';
     if (!file_exists($svnadminbin)) {
         $this->markTestSkipped(sprintf('%s not found', $svnadminbin));
     }
     if (!file_exists($svnbin)) {
         $this->markTestSkipped(sprintf('%s not found', $svnbin));
     }
     $svnadmin = new Svnadmin($this->tmpdir, $svnadminbin);
     $svnadmin->create(basename($this->reposdir));
     $svn = new Svn($this->reposurl, new CliAdapter($svnbin, new Cli(), new CliParser()));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/trunk', '/', 'imported skeleton');
     $svn->setHead(new Reference('2.1', Reference::TAG));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/tags/2.1', '/', 'imported skeleton');
     $svn->setHead(new Reference('feature1', Reference::BRANCH));
     $svn->import(__DIR__ . '/../Test/Fixtures/skeleton/svn/branches/feature1', '/', 'imported skeleton');
     $content = file_get_contents(__DIR__ . '/../Test/Fixtures/conveyor.yml.twig');
     $content = str_replace('{{ repository.url }}', $this->reposurl, $content);
     file_put_contents($this->projectdir . '/conveyor.yml', $content);
     chdir($this->projectdir);
 }
 protected function setUp()
 {
     if (defined('ILIAS_PHPUNIT_CONTEXT')) {
         include_once "./Services/PHPUnit/classes/class.ilUnitUtil.php";
         ilUnitUtil::performInitialisation();
     } else {
         chdir(dirname(__FILE__));
         chdir('../../../');
         require_once './Services/UICore/classes/class.ilCtrl.php';
         $ilCtrl_mock = $this->getMock('ilCtrl');
         $ilCtrl_mock->expects($this->any())->method('saveParameter');
         $ilCtrl_mock->expects($this->any())->method('saveParameterByClass');
         global $ilCtrl;
         $ilCtrl = $ilCtrl_mock;
         require_once './Services/Language/classes/class.ilLanguage.php';
         $lng_mock = $this->getMock('ilLanguage', array('txt'), array(), '', false);
         //$lng_mock->expects( $this->once() )->method( 'txt' )->will( $this->returnValue('Test') );
         global $lng;
         $lng = $lng_mock;
         $ilias_mock = new stdClass();
         $ilias_mock->account->id = 6;
         $ilias_mock->account->fullname = 'Esther Tester';
         global $ilias;
         $ilias = $ilias_mock;
     }
 }
Esempio n. 28
0
 /**
  * Packs the current repository + the vendor directory. Returns the filename
  * or null if the file was not generated.
  *
  * @param array $excludePaths Paths to exclude before pack zip file
  * @param array $copyPaths Paths to copy from project before create zip file
  *
  * @return string Filename
  */
 public function pack(array $excludePaths = [], array $copyPaths = [])
 {
     $this->removeTempFolder();
     // Clone the repo into a tmp folder
     $this->output->writeln("Clonning clean repository...");
     exec('git clone . ../.deployment > /dev/null');
     if (false === empty($copyPaths)) {
         $this->copyPaths($copyPaths);
     }
     // Create the zip the file
     $currentDir = getcwd();
     $zipFilename = exec('echo ver_$(git log --format="%H" -n 1).zip');
     chdir("../.deployment");
     if (false === empty($excludePaths)) {
         $this->removePaths($excludePaths);
     }
     $this->output->writeln("Creating zip file...");
     exec('zip -r ' . $zipFilename . ' * > /dev/null');
     exec('mv ' . $zipFilename . ' "' . $currentDir . '/' . $zipFilename . '"');
     chdir($currentDir);
     // Remove tmp folder
     $this->output->writeln("Removing temporary files...");
     $this->removeTempFolder();
     return $zipFilename;
 }
Esempio n. 29
0
 function clear_tmpfiles($cachetime = 1800)
 {
     global $GB_TMP;
     $delfiles = 0;
     $filelist = '';
     if (is_dir("{$this->include_path}/{$GB_TMP}")) {
         chdir("{$this->include_path}/{$GB_TMP}");
         $hnd = opendir(".");
         while ($file = readdir($hnd)) {
             if (is_file($file)) {
                 $filelist[] = $file;
             }
         }
         closedir($hnd);
     }
     if (is_array($filelist)) {
         while (list($key, $file) = each($filelist)) {
             $tmpfile = explode(".", $file);
             $tmpfile[0] = ereg_replace("img-", "", $tmpfile[0]);
             if ($tmpfile[0] < time() - $cachetime) {
                 if (unlink($file)) {
                     $delfiles++;
                 }
             }
         }
     }
     return $delfiles;
 }
 public function Run($app_code, $action)
 {
     if (is_dir("../vendor_core/phing/phing")) {
         // installation from "claromentis/installer" folder
         $phing_path = "../vendor_core/phing/phing";
     } elseif (is_dir("vendor/phing/phing")) {
         // installation from "claromentis" folder (usually, by a developer or Cla 7)
         $phing_path = "vendor/phing/phing";
     } elseif (is_dir("../vendor/phing/phing")) {
         // should not be needed, but still included
         $phing_path = "../vendor/phing/phing";
     } else {
         throw new \Exception("Cannot find phing");
     }
     $phing_path = realpath($phing_path);
     $old_pwd = getcwd();
     chdir($this->base_dir);
     $cmd = PHP_BINARY . ' ' . $phing_path . DIRECTORY_SEPARATOR . "bin" . DIRECTORY_SEPARATOR . "phing -Dapp={$app_code} {$action}";
     $this->io->write("Running command: {$cmd}");
     $ret = -1;
     passthru($cmd, $ret);
     chdir($old_pwd);
     if ($ret !== 0) {
         $msg = "Phing returned non-zero code - {$ret}";
         $this->io->writeError($msg);
         throw new \Exception($msg);
     }
 }