/**
  * @param array $args
  * @param array $opts
  *
  * @return void
  */
 public function execute($args = array(), $opts = array())
 {
     /* Validate incoming parameters. */
     if (!$this->_importParams($this->_consolidateInput($args, $opts))) {
         return;
     }
     $state = new Test_State($this->configuration);
     if ($this->_rebuild) {
         $state->flushDatabase();
         $this->logSection('rebuild', 'Database rebuilt.');
     }
     $loader = new Test_FixtureLoader($this->configuration);
     foreach ($this->_fixtures as $fixture) {
         $desc = sprintf('fixture "%s" from %s', $fixture['path'], $fixture['plugin'] ? "plugin {$fixture['plugin']}" : 'project');
         $this->logSection('fixture', sprintf('Loading %s...', $desc));
         $loader->loadFixture($fixture['path'], false, $fixture['plugin']);
         $this->logSection('fixture', sprintf('Loaded %s.', $desc));
     }
 }
Ejemplo n.º 2
0
 /** Loads a production fixture into the database.
  *
  * Production fixtures are identical to YAML test fixtures, except they are
  *  located in `sf_data_dir`.
  *
  * @param string  $fixture  The name of the fixture file (e.g., users.yml).
  * @param bool    $force    If true, the fixture will be loaded even if it has
  *  already been loaded during this test.
  * @param string|bool $plugin   Determines where to load the fixture file:
  *  - (bool) false: Look in `sf_data_dir/fixtures`.
  *  - (bool) true:  Look in `sf_plugin_dir/$this->_plugin/data/fixtures`.
  *  - (string):     Look in `sf_plugin_dir/$plugin/data/fixtures`.
  *
  * If $plugin is true, but $this->_plugin is not set, the result is the same
  *  as if $plugin is false.
  *
  * @return mixed
  */
 protected function loadProductionFixture($fixture, $force = false, $plugin = true)
 {
     /* Shortcut:  Allow calling loadProductionFixture($fixture, $plugin). */
     if (is_string($force)) {
         $plugin = $force;
         $force = false;
     } elseif ($plugin === true) {
         $plugin = $this->_plugin;
     }
     return $this->_fixtureLoader->loadFixture($fixture, true, $plugin, $force);
 }