/**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $databaseManager = new sfDatabaseManager($this->configuration);
     $buildAll = new sfDoctrineBuildAllTask($this->dispatcher, $this->formatter);
     $buildAll->setCommandApplication($this->commandApplication);
     $buildAllOptions = array();
     if ($options['skip-forms']) {
         $buildAllOptions[] = '--skip-forms';
     }
     if ($options['no-confirmation']) {
         $buildAllOptions[] = '--no-confirmation';
     }
     if (isset($options['application']) && $options['application']) {
         $buildAllOptions[] = '--application=' . $options['application'];
     }
     $ret = $buildAll->run(array(), $buildAllOptions);
     if (0 == $ret) {
         $loadData = new sfDoctrineLoadDataTask($this->dispatcher, $this->formatter);
         $loadData->setCommandApplication($this->commandApplication);
         $loadDataOptions = array('--env=' . $options['env'], '--connection=' . $options['connection']);
         if (isset($options['application'])) {
             $loadDataOptions[] = '--application=' . $options['application'];
         }
         if (!empty($options['dir'])) {
             $loadDataOptions[] = '--dir=' . implode(' --dir=', $options['dir']);
         }
         $loadData->run(array(), $loadDataOptions);
     }
     return $ret;
 }
 public function loadFixtures($fixtures)
 {
     $path = sfConfig::get('sf_data_dir') . '/' . $fixtures;
     if (!file_exists($path)) {
         throw new sfException('Invalid data fixtures file');
     }
     chdir(sfConfig::get('sf_root_dir'));
     $task = new sfDoctrineLoadDataTask($this->dispatcher, new sfFormatter());
     $task->run(array(), array('--env=test', '--dir=' . $path));
 }
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $buildAll = new sfDoctrineBuildAllTask($this->dispatcher, $this->formatter);
     $buildAll->setCommandApplication($this->commandApplication);
     $buildAll->run(array('application' => $arguments['application']), array('--env=' . $options['env']));
     $loadData = new sfDoctrineLoadDataTask($this->dispatcher, $this->formatter);
     $loadData->setCommandApplication($this->commandApplication);
     $loadDataOptions = array();
     $loadDataOptions[] = '--env=' . $options['env'];
     if (!empty($options['dir'])) {
         $loadDataOptions[] = '--dir=' . implode(' --dir=', $options['dir']);
     }
     if (isset($options['append']) && $options['append']) {
         $loadDataOptions[] = '--append';
     }
     $loadData->run(array('application' => $arguments['application']), $loadDataOptions);
 }
Esempio n. 4
0
<?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */
$configuration = ProjectConfiguration::getApplicationConfiguration('pc_frontend', 'test', true);
new sfDatabaseManager($configuration);
$task = new sfDoctrineLoadDataTask($configuration->getEventDispatcher(), new sfFormatter());
$task->run();
$task->run(array('--dir=' . dirname(__FILE__) . '/../fixtures'));
Esempio n. 5
0
<?php

/**
 * This file is part of the OpenPNE package.
 * (c) OpenPNE Project (http://www.openpne.jp/)
 *
 * For the full copyright and license information, please view the LICENSE
 * file and the NOTICE file that were distributed with this source code.
 */
// guess current application
if (!isset($app)) {
    $traces = debug_backtrace();
    $caller = $traces[0];
    $dirPieces = explode(DIRECTORY_SEPARATOR, dirname($caller['file']));
    $app = array_pop($dirPieces);
}
$configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', true);
new sfDatabaseManager($configuration);
$task = new sfDoctrineBuildAllReloadTask($configuration->getEventDispatcher(), new sfFormatter());
$task->run(array('--no-confirmation', '--dir=' . sfConfig::get('sf_root_dir') . '/data/fixtures', '--skip-forms'));
$loadData = new sfDoctrineLoadDataTask($configuration->getEventDispatcher(), new sfFormatter());
$loadData->run(array('--dir=' . dirname(__FILE__) . '/../fixtures'));