コード例 #1
0
ファイル: bootstrapTest.php プロジェクト: rouffj/Sismo
 public function tearDown()
 {
     parent::tearDown();
     $this->app['storage']->close();
     $fs = new Filesystem();
     $fs->remove($this->baseDir);
 }
コード例 #2
0
 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->writeSection($output, '[Propel] You are running the command: propel:build-sql');
     if ($input->getOption('verbose')) {
         $this->additionalPhingArgs[] = 'verbose';
     }
     $finder = new Finder();
     $filesystem = new Filesystem();
     $sqlDir = $this->getApplication()->getKernel()->getRootDir() . DIRECTORY_SEPARATOR . 'propel' . DIRECTORY_SEPARATOR . 'sql';
     $filesystem->remove($sqlDir);
     $filesystem->mkdir($sqlDir);
     // Execute the task
     $ret = $this->callPhing('build-sql', array('propel.sql.dir' => $sqlDir));
     if (true === $ret) {
         $files = $finder->name('*')->in($sqlDir);
         $nbFiles = 0;
         foreach ($files as $file) {
             $this->writeNewFile($output, (string) $file);
             if ('sql' === pathinfo($file->getFilename(), PATHINFO_EXTENSION)) {
                 $nbFiles++;
             }
         }
         $this->writeSection($output, sprintf('<comment>%d</comment> <info>SQL file%s ha%s been generated.</info>', $nbFiles, $nbFiles > 1 ? 's' : '', $nbFiles > 1 ? 've' : 's'), 'bg=black');
     } else {
         $this->writeSection($output, array('[Propel] Error', '', 'An error has occured during the "build-sql" task process. To get more details, run the command with the "--verbose" option.'), 'fg=white;bg=red');
     }
 }
コード例 #3
0
    protected function tearDown()
    {
        $filesystem = new Filesystem();
        $filesystem->remove($this->dir);

        $this->dir = null;
    }
コード例 #4
0
ファイル: WikiCommand.php プロジェクト: hotfics/lichess-old
 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $fs = new Filesystem();
     $repoUrl = 'git://github.com/ornicar/lichess.wiki.git';
     //$repoUrl = '/home/thib/lichess.wiki/';
     $repoName = 'lichess_wiki';
     $repoDir = '/tmp';
     $repo = $repoDir . '/' . $repoName;
     $fs->remove($repo);
     $command = sprintf('cd %s && git clone %s %s', $repoDir, $repoUrl, $repoName);
     system($command);
     $finder = new Finder();
     $mdFiles = $finder->files()->depth(0)->name('*.md')->in($repo);
     $pages = array();
     foreach ($mdFiles as $mdFile) {
         $name = preg_replace('/^(.+)\\.md$/', '$1', $mdFile->getFileName());
         if ($name == "Home") {
             continue;
         }
         $output->writeLn('* ' . $name);
         $command = sprintf('sundown %s/%s', $repo, $mdFile->getFileName());
         exec($command, $out);
         $body = implode($out, "\n");
         unset($out);
         $pages[] = new WikiPage($name, $body);
     }
     if (empty($pages)) {
         throw new \Exception('No pages to save');
     }
     $this->getContainer()->get('lichess.repository.wiki_page')->replaceWith($pages);
     $this->getContainer()->get('doctrine.odm.mongodb.document_manager')->flush();
     $output->writeLn('Flushed');
 }
コード例 #5
0
ファイル: TranslatorTest.php プロジェクト: novaki/symfony
 protected function deleteTmpDir()
 {
     if (!file_exists($dir = $this->tmpDir)) {
         return;
     }
     $fs = new Filesystem();
     $fs->remove($dir);
 }
コード例 #6
0
 /**
  * Shuts the kernel down if it was used in the test
  * and remove temp files.
  */
 protected function tearDown()
 {
     if (null !== static::$kernel) {
         static::$kernel->shutdown();
         $fs = new Filesystem();
         $fs->remove(static::$tmpPath);
     }
 }
コード例 #7
0
ファイル: WebTestCase.php プロジェクト: usefulthink/symfony
 protected function deleteTmpDir($testCase)
 {
     if (!file_exists($dir = sys_get_temp_dir() . '/' . Kernel::VERSION . '/' . $testCase)) {
         return;
     }
     $fs = new Filesystem();
     $fs->remove($dir);
 }
コード例 #8
0
 /**
  * Prepare the cache directory
  *
  * @param string $tmpdir    The temporary directory path.
  */
 protected function prepareCache($tmpdir)
 {
     // Recreate a propel directory in cache
     $this->filesystem->remove($tmpdir);
     $this->filesystem->mkdir($tmpdir);
     $fixturesdir = $tmpdir . '/fixtures/';
     $this->filesystem->remove($fixturesdir);
     $this->filesystem->mkdir($fixturesdir);
 }
コード例 #9
0
 protected function setUp()
 {
     $this->cacheDir = __DIR__ . '/Resources/cache';
     if (file_exists($this->cacheDir)) {
         $filesystem = new Filesystem();
         $filesystem->remove($this->cacheDir);
     }
     mkdir($this->cacheDir, 0777, true);
 }
コード例 #10
0
 /**
  * Call a Phing task.
  *
  * @param string $taskName  A Propel task name.
  * @param array $properties An array of properties to pass to Phing.
  */
 protected function callPhing($taskName, $properties = array())
 {
     $kernel = $this->getApplication()->getKernel();
     if (isset($properties['propel.schema.dir'])) {
         $this->cacheDir = $properties['propel.schema.dir'];
     } else {
         $this->cacheDir = $kernel->getRootDir() . '/cache/' . $kernel->getEnvironment() . '/propel';
         $filesystem = new Filesystem();
         $filesystem->remove($this->cacheDir);
         $filesystem->mkdir($this->cacheDir);
     }
     $this->copySchemas($kernel, $this->cacheDir);
     // build.properties
     $this->createBuildPropertiesFile($kernel, $this->cacheDir . '/build.properties');
     // buidtime-conf.xml
     $this->createBuildTimeFile($this->cacheDir . '/buildtime-conf.xml');
     // Verbosity
     $bufferPhingOutput = $this->getContainer()->getParameter('kernel.debug');
     // Phing arguments
     $args = $this->getPhingArguments($kernel, $this->cacheDir, $properties);
     // Add any arbitrary arguments last
     foreach ($this->additionalPhingArgs as $arg) {
         if (in_array($arg, array('verbose', 'debug'))) {
             $bufferPhingOutput = false;
         }
         $args[] = '-' . $arg;
     }
     $args[] = $taskName;
     // Enable output buffering
     Phing::setOutputStream(new \OutputStream(fopen('php://output', 'w')));
     Phing::setErrorStream(new \OutputStream(fopen('php://output', 'w')));
     Phing::startup();
     Phing::setProperty('phing.home', getenv('PHING_HOME'));
     ob_start();
     $phing = new Phing();
     $returnStatus = true;
     // optimistic way
     try {
         $phing->execute($args);
         $phing->runBuild();
         $this->buffer = ob_get_contents();
         // Guess errors
         if (strstr($this->buffer, 'failed. Aborting.') || strstr($this->buffer, 'Failed to execute') || strstr($this->buffer, 'failed for the following reason:')) {
             $returnStatus = false;
         }
     } catch (\Exception $e) {
         $returnStatus = false;
     }
     if ($bufferPhingOutput) {
         ob_end_clean();
     } else {
         ob_end_flush();
     }
     return $returnStatus;
 }
コード例 #11
0
 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->callPhing('sql', array('propel.packageObjectModel' => false));
     $filesystem = new Filesystem();
     $basePath = $this->getApplication()->getKernel()->getRootDir() . DIRECTORY_SEPARATOR . 'propel' . DIRECTORY_SEPARATOR . 'sql';
     $sqlMap = file_get_contents($basePath . DIRECTORY_SEPARATOR . 'sqldb.map');
     foreach ($this->tempSchemas as $schemaFile => $schemaDetails) {
         $sqlFile = str_replace('.xml', '.sql', $schemaFile);
         $targetSqlFile = $schemaDetails['bundle'] . '-' . str_replace('.xml', '.sql', $schemaDetails['basename']);
         $targetSqlFilePath = $basePath . DIRECTORY_SEPARATOR . $targetSqlFile;
         $sqlMap = str_replace($sqlFile, $targetSqlFile, $sqlMap);
         $filesystem->remove($targetSqlFilePath);
         $filesystem->rename($basePath . DIRECTORY_SEPARATOR . $sqlFile, $targetSqlFilePath);
         $output->writeln(sprintf('Wrote SQL file for bundle "<info>%s</info>" in "<info>%s</info>"', $schemaDetails['bundle'], $targetSqlFilePath));
     }
     file_put_contents($basePath . DIRECTORY_SEPARATOR . 'sqldb.map', $sqlMap);
 }
コード例 #12
0
 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     list($name, $defaultConfig) = $this->getConnection($input, $output);
     $this->callPhing('datadump', array('propel.database.url' => $defaultConfig['connection']['dsn'], 'propel.database.database' => $defaultConfig['adapter'], 'propel.database.user' => $defaultConfig['connection']['user'], 'propel.database.password' => $defaultConfig['connection']['password'], 'propel.schema.dir' => $this->getApplication()->getKernel()->getRootDir() . '/propel/schema/'));
     $finder = new Finder();
     $filesystem = new Filesystem();
     $datas = $finder->name('*_data.xml')->in($this->getTmpDir());
     foreach ($datas as $data) {
         $dest = $this->getApplication()->getKernel()->getRootDir() . self::$destPath . '/xml/' . $data->getFilename();
         $filesystem->copy((string) $data, $dest);
         $filesystem->remove($data);
         $output->writeln(sprintf('Wrote dumped data in "<info>%s</info>".', $dest));
     }
     if (count($datas) <= 0) {
         $output->writeln('No new dumped files.');
     }
 }
コード例 #13
0
 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $rootDir = $this->getApplication()->getKernel()->getRootDir();
     $schemaDir = $rootDir . '/propel/schema/';
     $sqlDir = $rootDir . '/propel/sql/';
     $xmlDumpDir = $rootDir . '/propel/dump/xml/';
     $filesystem = new Filesystem();
     $finder = new Finder();
     foreach ($finder->name('*_data.xml')->in($xmlDumpDir) as $data) {
         $filesystem->copy((string) $data, $schemaDir . $data->getFilename());
     }
     $this->callPhing('datasql', array('propel.sql.dir' => $sqlDir, 'propel.schema.dir' => $schemaDir));
     $finder = new Finder();
     foreach ($finder->name('*_data.xml')->in($schemaDir) as $data) {
         $filesystem->remove($data);
     }
     $this->summary($output, 'propel-data-sql');
     $output->writeln(sprintf('SQL from XML data dump file is in <comment>%s</comment>.', $sqlDir));
 }
コード例 #14
0
 /**
  * @see Command
  *
  * @throws \InvalidArgumentException When the target directory does not exist
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('verbose')) {
         $this->additionalPhingArgs[] = 'verbose';
     }
     if (true === $this->callPhing('sql', array('propel.packageObjectModel' => false))) {
         $this->writeSection($output, '[Propel] You are running the command: propel:build-sql');
         $filesystem = new Filesystem();
         $basePath = $this->getApplication()->getKernel()->getRootDir() . DIRECTORY_SEPARATOR . 'propel' . DIRECTORY_SEPARATOR . 'sql';
         $sqlMap = file_get_contents($basePath . DIRECTORY_SEPARATOR . 'sqldb.map');
         foreach ($this->tempSchemas as $schemaFile => $schemaDetails) {
             $sqlFile = str_replace('.xml', '.sql', $schemaFile);
             $targetSqlFile = $schemaDetails['bundle'] . '-' . str_replace('.xml', '.sql', $schemaDetails['basename']);
             $targetSqlFilePath = $basePath . DIRECTORY_SEPARATOR . $targetSqlFile;
             $sqlMap = str_replace($sqlFile, $targetSqlFile, $sqlMap);
             $filesystem->remove($targetSqlFilePath);
             $filesystem->rename($basePath . DIRECTORY_SEPARATOR . $sqlFile, $targetSqlFilePath);
             $output->writeln(sprintf('Wrote SQL file for bundle <info>%s</info> in <comment>%s</comment>.', $schemaDetails['bundle'], $targetSqlFilePath));
         }
         file_put_contents($basePath . DIRECTORY_SEPARATOR . 'sqldb.map', $sqlMap);
     } else {
         $output->writeln('<error>WARNING ! An error has occured.</error>');
     }
 }
コード例 #15
0
ファイル: Kernel.php プロジェクト: tarjei/statsdbundle
 public function __destruct()
 {
     $fs = new Filesystem();
     $fs->remove($this->tmpDir);
 }
コード例 #16
0
 protected function tearDown()
 {
     parent::tearDown();
     $fs = new Filesystem();
     $fs->remove(sys_get_temp_dir() . '/JMSI18nRoutingBundle');
 }
コード例 #17
0
<?php

require_once __DIR__ . '/../app/bootstrap.php.cache';
require '../app/autoload.php';
use Symfony\Component\HttpKernel\Util\Filesystem;
$file = new Filesystem();
$file->remove(sys_get_temp_dir() . '/sf2standard');
コード例 #18
0
ファイル: BaseTestCase.php プロジェクト: nicolaschenet/testdd
 protected function tearDown()
 {
     parent::tearDown();
     $fs = new Filesystem();
     $fs->remove(sys_get_temp_dir() . '/JMSSecurityExtraBundle');
 }
コード例 #19
0
ファイル: PhingCommand.php プロジェクト: rozwell/PropelBundle
 /**
  * Call a Phing task.
  *
  * @param string $taskName  A Propel task name.
  * @param array $properties An array of properties to pass to Phing.
  */
 protected function callPhing($taskName, $properties = array())
 {
     $kernel = $this->getApplication()->getKernel();
     $filesystem = new Filesystem();
     if (isset($properties['propel.schema.dir'])) {
         $this->tmpDir = $properties['propel.schema.dir'];
     } else {
         $this->tmpDir = sys_get_temp_dir() . '/propel-gen';
         $filesystem->remove($this->tmpDir);
         $filesystem->mkdir($this->tmpDir);
     }
     foreach ($kernel->getBundles() as $bundle) {
         if (is_dir($dir = $bundle->getPath() . '/Resources/config')) {
             $finder = new Finder();
             $schemas = $finder->files()->name('*schema.xml')->followLinks()->in($dir);
             $parts = explode(DIRECTORY_SEPARATOR, realpath($bundle->getPath()));
             $length = count(explode('\\', $bundle->getNamespace())) * -1;
             $prefix = implode('.', array_slice($parts, 1, $length));
             foreach ($schemas as $schema) {
                 $tempSchema = md5($schema) . '_' . $schema->getBaseName();
                 $this->tempSchemas[$tempSchema] = array('bundle' => $bundle->getName(), 'basename' => $schema->getBaseName(), 'path' => $schema->getPathname());
                 $file = $this->tmpDir . DIRECTORY_SEPARATOR . $tempSchema;
                 $filesystem->copy((string) $schema, $file);
                 // the package needs to be set absolute
                 // besides, the automated namespace to package conversion has not taken place yet
                 // so it needs to be done manually
                 $database = simplexml_load_file($file);
                 if (isset($database['package'])) {
                     $database['package'] = $prefix . '.' . $database['package'];
                 } elseif (isset($database['namespace'])) {
                     $database['package'] = $prefix . '.' . str_replace('\\', '.', $database['namespace']);
                 } else {
                     throw new \RuntimeException(sprintf('Please define a `package` attribute or a `namespace` attribute for schema `%s`', $schema->getBaseName()));
                 }
                 foreach ($database->table as $table) {
                     if (isset($table['package'])) {
                         $table['package'] = $prefix . '.' . $table['package'];
                     } elseif (isset($table['namespace'])) {
                         $table['package'] = $prefix . '.' . str_replace('\\', '.', $table['namespace']);
                     } else {
                         $table['package'] = $database['package'];
                     }
                 }
                 file_put_contents($file, $database->asXML());
             }
         }
     }
     // build.properties
     $this->buildPropertiesFile = $kernel->getRootDir() . '/config/propel.ini';
     $filesystem->touch($this->buildPropertiesFile);
     $filesystem->copy($this->buildPropertiesFile, $this->tmpDir . '/build.properties');
     // Required by the Phing task
     $this->createBuildTimeFile($this->tmpDir . '/buildtime-conf.xml');
     $args = array();
     $properties = array_merge(array('propel.database' => 'mysql', 'project.dir' => $this->tmpDir, 'propel.output.dir' => $kernel->getRootDir() . '/propel', 'propel.php.dir' => '/', 'propel.packageObjectModel' => true), $properties);
     $properties = array_merge($properties, $this->getContainer()->get('propel.build_properties')->getProperties());
     foreach ($properties as $key => $value) {
         $args[] = "-D{$key}={$value}";
     }
     // Build file
     $args[] = '-f';
     $args[] = realpath($this->getContainer()->getParameter('propel.path') . '/generator/build.xml');
     $bufferPhingOutput = !$this->getContainer()->getParameter('kernel.debug');
     // Add any arbitrary arguments last
     foreach ($this->additionalPhingArgs as $arg) {
         if (in_array($arg, array('verbose', 'debug'))) {
             $bufferPhingOutput = false;
         }
         $args[] = '-' . $arg;
     }
     $args[] = $taskName;
     // enable output buffering
     Phing::setOutputStream(new \OutputStream(fopen('php://output', 'w')));
     Phing::setErrorStream(new \OutputStream(fopen('php://output', 'w')));
     Phing::startup();
     Phing::setProperty('phing.home', getenv('PHING_HOME'));
     ob_start();
     $phing = new Phing();
     $returnStatus = true;
     // optimistic way
     try {
         $phing->execute($args);
         $phing->runBuild();
         $this->buffer = ob_get_contents();
         $returnStatus = false !== preg_match('#failed. Aborting.#', $this->buffer);
     } catch (Exception $e) {
         $returnStatus = false;
     }
     if ($bufferPhingOutput) {
         ob_end_clean();
     } else {
         ob_end_flush();
     }
     chdir($kernel->getRootDir());
     return $returnStatus;
 }
コード例 #20
0
ファイル: BaseTestCase.php プロジェクト: almaaro/Ilmokilke
 private function cleanTmpDir()
 {
     $fs = new Filesystem();
     $fs->remove(sys_get_temp_dir() . '/JMSDiExtraBundle');
 }
コード例 #21
0
 protected function tearDown()
 {
     $filesystem = new Filesystem();
     $filesystem->remove($this->cacheDir);
 }
コード例 #22
0
ファイル: Application.php プロジェクト: rafalp/Miblo
 /**
  * Prune existing pages
  *  
  */
 protected function _pruneExistingPages()
 {
     // Start helper
     $Filesystem = new Filesystem();
     echo "\nPruning existing entries... ";
     foreach (new \DirectoryIterator($this->_makeDirPath('site')) as $dir) {
         if ($dir->isDir() && is_numeric($dir->getFilename())) {
             $Filesystem->remove($this->_makeDirPath('site/' . $dir->getFilename()));
         }
     }
     echo "done.";
 }