public function __construct(array $options = array())
 {
     $this->_timer = new sfTimer();
     $this->_timer->startTimer();
     $options = array_intersect_key($options, $this->_options);
     $this->_options = array_merge($this->_options, $options);
     $this->_initialize();
 }
 protected function showTime(sfTimer $timer, $message = 'Time : ', $afterMessage = "\n\n")
 {
     $timer->addTime();
     $this->log('');
     $this->logSection($message, date('i:s', (int) $timer->getElapsedTime()));
     $this->log('');
     $this->log('');
 }
 public function runTest($methodName, $nbTest = self::NB_TEST)
 {
     $this->clearCache();
     $timer = new sfTimer();
     $this->beginTransaction();
     for ($i = 0; $i < $nbTest; $i++) {
         $this->{$methodName}($i);
     }
     $this->commit();
     $t = $timer->getElapsedTime();
     return $t * 1000;
 }
Exemplo n.º 4
0
 protected function execute($arguments = array(), $options = array())
 {
     $definitions = $this->getDefinition();
     $timer = new sfTimer();
     $succeeded = array();
     $targets = $this->getOption('targets', array_keys($definitions));
     foreach ((array) $definitions as $k => $v) {
         if (!in_array($k, $targets)) {
             continue;
         }
         $timer->startTimer();
         $defaultOptions = array_merge($this->options, array('name' => $k, 'dir' => $this->basePath, 'required_rules' => array(), 'configuration' => $this->configuration, 'dispatcher' => new sfEventDispatcher(), 'formatter' => $this->formatter));
         $v = array_merge(array('options' => $defaultOptions), $v);
         if (!isset($v['options']['required_rules'])) {
             $v['options']['required_rules'] = array();
         }
         $requiredRules = (array) $v['options']['required_rules'];
         if (!empty($requiredRules) && array_diff($requiredRules, $succeeded)) {
             $this->logSection('upgrade', 'Passed ' . $k, null, 'ERROR');
             continue;
         }
         $this->logSection('upgrade', 'Processing ' . $k);
         if (isset($v['file']) && is_file($v['file'])) {
             require_once $v['file'];
         }
         if (class_exists($v['strategy'])) {
             $className = $v['strategy'];
         } else {
             $className = 'opUpgrade' . $v['strategy'] . 'Strategy';
         }
         opApplicationConfiguration::registerZend();
         try {
             // disable Doctrine profiling
             sfConfig::set('sf_debug', false);
             $strategy = new $className($v['options']);
             $strategy->run();
             $succeeded[] = $k;
         } catch (Exception $e) {
             $this->logBlock($e->getMessage(), 'ERROR');
         }
         opApplicationConfiguration::unregisterZend();
         $this->logSection('upgrade', sprintf('Processed %s (%.2f sec)', $k, $timer->addTime()));
     }
     $this->logSection('upgrade', sprintf('Completed Upgrading (%.2f sec)', $timer->getElapsedTime()));
     $this->logSection('upgrade', sprintf('The %.2f MB memory allocated', round(memory_get_peak_usage(true) / 1048576, 2)));
 }
Exemplo n.º 5
0
 /**
  * Executes list action
  */
 public function executeList()
 {
     parent::executeList();
     $nb_results = $this->nb_results;
     if ($nb_results == 0) {
         return;
     }
     $timer = new sfTimer();
     $products = $this->query->execute(array(), Doctrine::FETCH_ARRAY);
     c2cActions::statsdTiming('pager.getResults', $timer->getElapsedTime());
     $timer = new sfTimer();
     Parking::addAssociatedParkings($products, 'pf');
     // add associated parkings infos to $products
     c2cActions::statsdTiming('parking.addAssociatedParkings', $timer->getElapsedTime());
     Area::sortAssociatedAreas($products);
     $this->items = Language::parseListItems($products, 'Product');
 }
Exemplo n.º 6
0
 /**
  * Compiles LESS file to CSS
  *
  * @param string $lessFile a LESS file
  * @return boolean true if succesfully compiled & false in other way
  */
 public function compile($lessFile)
 {
     // Creates timer
     $timer = new sfTimer();
     // Gets CSS file path
     $cssFile = self::getCssPathOfLess($lessFile);
     // Checks if path exists & create if not
     if (!is_dir(dirname($cssFile))) {
         mkdir(dirname($cssFile), 0777, true);
     }
     // Is file compiled
     $isCompiled = false;
     // If we check dates - recompile only really old CSS
     if ($this->isCheckDates()) {
         if (!is_file($cssFile) || filemtime($lessFile) > filemtime($cssFile)) {
             $isCompiled = $this->callCompiler($lessFile, $cssFile);
         }
     } else {
         $isCompiled = $this->callCompiler($lessFile, $cssFile);
     }
     // Adds debug info to debug array
     self::$results[] = array('lessFile' => $lessFile, 'cssFile' => $cssFile, 'compTime' => $timer->getElapsedTime(), 'isCompiled' => $isCompiled);
     return $isCompiled;
 }
Exemplo n.º 7
0
 /**
  * Executes list action, adding parkings linked to routes
  */
 public function executeList()
 {
     parent::executeList();
     $nb_results = $this->nb_results;
     if ($nb_results == 0) {
         return;
     }
     $timer = new sfTimer();
     $routes = $this->query->execute(array(), Doctrine::FETCH_ARRAY);
     c2cActions::statsdTiming('pager.getResults', $timer->getElapsedTime());
     // if they are criterias on the summit (snam, srnam, salt, styp)
     // we might have only some of the associated summits and not the 'best one' (ticket #337)
     // so we must add a new request to get the summits, display the best one and add a note to explain that the
     // other summit is associated
     // FIXME would be nice to put all in a single request (before), but I didn't manage to do it
     // TODO not working right now
     //if ($this->hasRequestParameter('snam') || $this->hasRequestParameter('srnam') ||
     //    $this->hasRequestParameter('salt') || $this->hasRequestParameter('styp'))
     //{
     // $routes = Route::addBestSummitName($routes, '');
     //}
     $timer = new sfTimer();
     Parking::addAssociatedParkings($routes, 'pr');
     // add associated parkings infos to $routes
     c2cActions::statsdTiming('parking.addAssociatedParkings', $timer->getElapsedTime());
     $timer = new sfTimer();
     Document::countAssociatedDocuments($routes, 'ro', true);
     // number of associated outings
     c2cActions::statsdTiming('document.countAssociatedDocuments', $timer->getElapsedTime());
     Area::sortAssociatedAreas($routes);
     $this->items = Language::parseListItems($routes, 'Route');
 }
 /**
  * Compiles LESS file to CSS
  *
  * @param   string  $lessFile a LESS file
  * 
  * @return  boolean           true if succesfully compiled & false in other way
  */
 public function compile($lessFile)
 {
     // Creates timer
     $timer = new sfTimer();
     // Gets CSS file path
     $cssFile = $this->getCssPathOfLess($lessFile);
     sfLESSUtils::createFolderIfNeeded($cssFile);
     // Is file compiled
     $isCompiled = false;
     // If we check dates - recompile only really old CSS
     if (self::getConfig()->isCheckDates()) {
         try {
             $d = new sfLESSDependency(sfConfig::get('sf_web_dir'), sfConfig::get('app_sf_less_plugin_check_dependencies', false));
             $shouldCompile = !is_file($cssFile) || $d->getMtime($lessFile) > filemtime($cssFile);
         } catch (Exception $e) {
             $shouldCompile = false;
         }
     } else {
         $shouldCompile = true;
     }
     if ($shouldCompile) {
         $buffer = $this->callLesscCompiler($lessFile, $cssFile);
         if ($buffer !== false) {
             $isCompiled = $this->writeCssFile($cssFile, $buffer) !== false;
         }
     }
     // Adds debug info to debug array
     self::$results[] = array('lessFile' => $lessFile, 'cssFile' => $cssFile, 'compTime' => $timer->getElapsedTime(), 'isCompiled' => $isCompiled);
     return $isCompiled;
 }
Doctrine_Query::create()->from('ioDoctrineMenuItem')->delete()->execute();
Doctrine_Query::create()->from('sfGuardPermission')->delete()->execute();
// create the tree and make its vars accessible
extract(create_doctrine_test_tree($t));
print_test_tree($t);
$t->info('  3.1 - Adding some Permissions for testing');
$c1 = new sfGuardPermission();
$c1->name = 'c1';
$c1->save();
$c2 = new sfGuardPermission();
$c2->name = 'c2';
$c2->save();
$rt->link('Permissions', array($c1->id, $c2->id));
$rt->save();
$t->info('  3.2 - Creating the menu object.');
$timer = new sfTimer();
$menu = $rt->createMenu();
$timer->addTime();
$t->info(sprintf('### Menu created from db in %s sec (%s nodes/min)', round($timer->getElapsedTime(), 4), floor(8 * 60 / $timer->getElapsedTime())));
$t->info('  3.3 - Running tests on the created menu object');
$t->is(get_class($menu), 'ioMenuItem', 'The menu rt has the correct class');
$t->is(count($menu->getChildren()), 2, 'The menu rt has 2 children');
$t->is(array_keys($menu->getChildren()), array('Parent 1', 'Parent 2'));
$t->is($menu->getAttributes(), array('class' => 'root'), 'The menu rt has the correct attributes array');
$t->is($menu->getCredentials(), array('c1', 'c2'), 'The menu rt has the correct credentials array');
$t->is(count($menu['Parent 1']->getChildren()), 3, 'pt1 has 3 children.');
$t->is(array_keys($menu['Parent 1']->getChildren()), array('Child 1', 'Child 2', 'Child 3'), 'pt1\'s children are array(Child 1, Child 2, Child 3)');
$t->is(count($menu['Parent 2']->getChildren()), 1, 'pt2 has 1 child.');
$t->is(array_keys($menu['Parent 2']->getChildren()), array('Child 4'), 'pt2\'s children are array(Child 4)');
$t->info('  3.4 - Compare the created meno to that of the menu from create_test_tree(). They should be identical.');
$arr = create_test_tree($t);
Exemplo n.º 10
0
 /**
  * @see Connection::executeQuery()
  */
 public function executeQuery($sql, $fetchmode = null)
 {
     $this->lastExecutedQuery = $sql;
     $this->numQueriesExecuted++;
     $elapsedTime = 0;
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $sqlTimer = sfTimerManager::getTimer('Database');
         $timer = new sfTimer();
     }
     $retval = $this->childConnection->executeQuery($sql, $fetchmode);
     if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
         $sqlTimer->addTime();
         $elapsedTime = $timer->getElapsedTime();
     }
     $this->log(sprintf("executeQuery(): [%.2f ms] %s", $elapsedTime * 1000, $sql));
     return $retval;
 }
Exemplo n.º 11
0
 /**
  * RSS list of latest created documents.
  */
 public function executeLatest()
 {
     $timer = new sfTimer('executeLatest');
     $this->documents = Document::getLastDocs($this->__(' :') . ' ');
     $this->setLayout(false);
     $this->setCacheControl(3600);
     c2cActions::statsdTiming('document.executeLatest', $timer->getElapsedTime('executeLatest'));
 }
 /**
  * Executes this filter.
  *
  * @param sfFilterChain The filter chain
  *
  * @throws <b>sfInitializeException</b> If an error occurs during view initialization.
  * @throws <b>sfViewException</b>       If an error occurs while executing the view.
  */
 public function execute($filterChain)
 {
     // get the context and controller
     $context = $this->getContext();
     $controller = $context->getController();
     // get the current action instance
     $actionEntry = $controller->getActionStack()->getLastEntry();
     $actionInstance = $actionEntry->getActionInstance();
     // get the current action information
     $moduleName = $context->getModuleName();
     $actionName = $context->getActionName();
     // get the request method
     $method = $context->getRequest()->getMethod();
     $viewName = null;
     $statsdPrefix = c2cActions::statsdPrefix($moduleName, $actionName);
     if (sfConfig::get('sf_cache')) {
         // get current uri adapted for cache
         $uri = MyCacheFilter::getCurrentCacheUri();
         // best way would be to modify uri (and not the whole cache management system)
         // but we have no way to extend getCurrentInternalUri method in sfRouting class just for cache
         if (null !== $context->getResponse()->getParameter($uri . '_action', null, 'symfony/cache')) {
             // action in cache, so go to the view
             $viewName = sfView::SUCCESS;
         }
     }
     if (!$viewName) {
         if (($actionInstance->getRequestMethods() & $method) != $method) {
             // this action will skip validation/execution for this method
             // get the default view
             $viewName = $actionInstance->getDefaultView();
         } else {
             // set default validated status
             $validated = true;
             // get the current action validation configuration
             $validationConfig = $moduleName . '/' . sfConfig::get('sf_app_module_validate_dir_name') . '/' . $actionName . '.yml';
             // load validation configuration
             // do NOT use require_once
             if (null !== ($validateFile = sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_module_dir_name') . '/' . $validationConfig, true))) {
                 // create validator manager
                 $validatorManager = new sfValidatorManager();
                 $validatorManager->initialize($context);
                 require $validateFile;
                 // process validators
                 $validated = $validatorManager->execute();
             }
             // process manual validation
             $validateToRun = 'validate' . ucfirst($actionName);
             $manualValidated = method_exists($actionInstance, $validateToRun) ? $actionInstance->{$validateToRun}() : $actionInstance->validate();
             // action is validated if:
             // - all validation methods (manual and automatic) return true
             // - or automatic validation returns false but errors have been 'removed' by manual validation
             $validated = $manualValidated && $validated || $manualValidated && !$validated && !$context->getRequest()->hasErrors();
             // register fill-in filter
             if (null !== ($parameters = $context->getRequest()->getAttribute('fillin', null, 'symfony/filter'))) {
                 $this->registerFillInFilter($filterChain, $parameters);
             }
             if ($validated) {
                 if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
                     $timer = sfTimerManager::getTimer(sprintf('Action "%s/%s"', $moduleName, $actionName));
                 }
                 // execute the action
                 $statsdTimer = new sfTimer();
                 $actionInstance->preExecute();
                 c2cActions::statsdTiming('execution.action.preExecute', $statsdTimer->getElapsedTime(), $statsdPrefix);
                 $statsdTimer = new sfTimer();
                 $viewName = $actionInstance->execute();
                 c2cActions::statsdTiming('execution.action.execute', $statsdTimer->getElapsedTime(), $statsdPrefix);
                 if ($viewName == '') {
                     $viewName = sfView::SUCCESS;
                 }
                 $statsdTimer = new sfTimer();
                 $actionInstance->postExecute();
                 c2cActions::statsdTiming('execution.action.postExecute', $statsdTimer->getElapsedTime(), $statsdPrefix);
                 if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
                     $timer->addTime();
                 }
             } else {
                 if (sfConfig::get('sf_logging_enabled')) {
                     $this->context->getLogger()->info('{sfFilter} action validation failed');
                 }
                 // validation failed
                 $handleErrorToRun = 'handleError' . ucfirst($actionName);
                 $viewName = method_exists($actionInstance, $handleErrorToRun) ? $actionInstance->{$handleErrorToRun}() : $actionInstance->handleError();
                 if ($viewName == '') {
                     $viewName = sfView::ERROR;
                 }
             }
         }
     }
     if ($viewName == sfView::HEADER_ONLY) {
         $context->getResponse()->setHeaderOnly(true);
         // execute next filter
         $filterChain->execute();
     } else {
         if ($viewName != sfView::NONE) {
             if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
                 $timer = sfTimerManager::getTimer(sprintf('View "%s" for "%s/%s"', $viewName, $moduleName, $actionName));
             }
             // get the view instance
             $statsdTimer = new sfTimer();
             $viewInstance = $controller->getView($moduleName, $actionName, $viewName);
             c2cActions::statsdTiming("execution.view.{$viewName}.getView", $statsdTimer->getElapsedTime(), $statsdPrefix);
             $statsdTimer = new sfTimer();
             $viewInstance->initialize($context, $moduleName, $actionName, $viewName);
             c2cActions::statsdTiming("execution.view.{$viewName}.initialize", $statsdTimer->getElapsedTime(), $statsdPrefix);
             $statsdTimer = new sfTimer();
             $viewInstance->execute();
             c2cActions::statsdTiming("execution.view.{$viewName}.execute", $statsdTimer->getElapsedTime(), $statsdPrefix);
             // render the view and if data is returned, stick it in the
             // action entry which was retrieved from the execution chain
             $statsdTimer = new sfTimer();
             $viewData = $viewInstance->render();
             c2cActions::statsdTiming("execution.view.{$viewName}.render", $statsdTimer->getElapsedTime(), $statsdPrefix);
             if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) {
                 $timer->addTime();
             }
             if ($controller->getRenderMode() == sfView::RENDER_VAR) {
                 $actionEntry->setPresentation($viewData);
             } else {
                 // execute next filter
                 $filterChain->execute();
             }
         }
     }
 }
Exemplo n.º 13
0
  public function parseFiles($files)
  {
    $this->log('Starting to process '.count($files).' files').PHP_EOL;
    $timer = new sfTimer();

    // if the version has changed and we are not doing a full rebuild; force one
    if (($this->existing_xml)
      && ($this->existing_xml->documentElement->getAttribute('version') != DocBlox_Abstract::VERSION)
      && (!$this->isForced()))
    {
      $this->log('Version of DocBlox has changed since the last build; forcing a full re-build');
      $this->setForced(true);
    }

    // convert patterns to regex's
    foreach($this->ignore_patterns as &$pattern)
    {
      $pattern = $this->convertToPregCompliant($pattern);
    }
//    $this->log('Time1: '.round($timer->getElapsedTime(),4).'s').PHP_EOL;

    $dom = new DOMDocument('1.0', 'utf-8');
    $dom->loadXML('<project version="'.DocBlox_Abstract::VERSION.'"></project>');

    foreach ($files as $file)
    {
      // check if the file is in an ignore pattern, if so, skip it
      foreach($this->ignore_patterns as $pattern)
      {
        if (preg_match('/^'.$pattern.'$/', $file))
        {
          $this->log('-- File "'.$file.'" matches ignore pattern, skipping');
          continue 2;
        }
      }

      $xml = $this->parseFile($file);
      if ($xml === false)
      {
        continue;
      }

      $dom_prop = new DOMDocument();
      $dom_prop->loadXML(trim($xml));

      $xpath = new DOMXPath($dom_prop);
      $qry = $xpath->query('/*');
      for ($i = 0; $i < $qry->length; $i++)
      {
        $dom->documentElement->appendChild($dom->importNode($qry->item($i), true));
      }
    }

    // collect all packages and store them in the XML
    // TODO: the subpackages should be collected and stored as well!
    $this->log('Collecting all packages');
    $xpath = new DOMXPath($dom);
    $packages = array();
    $qry = $xpath->query('//class/docblock/tag[@name="package"]|//file/docblock/tag[@name="package"]');
    for ($i = 0; $i < $qry->length; $i++)
    {
      $package_name = $qry->item($i)->nodeValue;
      if (isset($packages[$package_name]))
      {
        continue;
      }

      $packages[$package_name] = array();
      $qry2 = $xpath->query('//docblock/tag[@name="package" and .="'.$qry->item($i)->nodeValue.'"]/../tag[@name="subpackage"]');
      for ($i2 = 0; $i2 < $qry2->length; $i2++)
      {
        $packages[$package_name][] = $qry2->item($i2)->nodeValue;
      }
      $packages[$package_name] = array_unique($packages[$package_name]);

      // create package XMl and subpackages
      $node = new DOMElement('package');
      $dom->documentElement->appendChild($node);
      $node->setAttribute('name', $package_name);
      foreach ($packages[$package_name] as $subpackage)
      {
        $node->appendChild(new DOMElement('subpackage', $subpackage));
      }
    }

    $this->log('Collecting all namespaces');
    $xpath = new DOMXPath($dom);
    $namespaces = array();
    $qry = $xpath->query('//@namespace');
    for ($i = 0; $i < $qry->length; $i++)
    {
      if (isset($namespaces[$qry->item($i)->nodeValue]))
      {
        continue;
      }
      $namespaces[$qry->item($i)->nodeValue] = true;
    }

    $namespaces = $this->generateNamespaceTree(array_keys($namespaces));
    $this->generateNamespaceElements($namespaces, $dom->documentElement);

    $this->log('Collecting all marker types');
    foreach ($this->getMarkers() as $marker)
    {
      $node = new DOMElement('marker', strtolower($marker));
      $dom->documentElement->appendChild($node);
    }

    $dom->formatOutput = true;
    $xml = $dom->saveXML();
    $this->log('--');
    $this->log('Elapsed time to parse all files: '.round($timer->getElapsedTime(), 2).'s');
    $this->log('Peak memory usage: '.round(memory_get_peak_usage() / 1024 / 1024, 2).'M');

    return $xml;
  }
Exemplo n.º 14
0
<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
require_once __DIR__ . '/../../bootstrap/unit.php';
$t = new lime_test(6);
$t->diag('sfTimer starting and stopping');
$timer = new sfTimer();
$timer->addTime();
sleep(1);
$timer->addTime();
$t->is($timer->getCalls(), 2, '->getCalls() returns the amount of addTime() calls');
$t->ok($timer->getElapsedTime() > 0, '->getElapsedTime() returns a value greater than zero. No precision is tested by the unit test to avoid false alarms');
$t->diag('sfTimerManager');
$timerA = sfTimerManager::getTimer('timerA');
$timerB = sfTimerManager::getTimer('timerB');
$t->isa_ok($timerA, 'sfTimer', '::getTimer() returns an sfTimer instance');
$timers = sfTimerManager::getTimers();
$t->is(count($timers), 2, '::getTimers() returns an array with the timers created by the timer manager');
$t->is($timers['timerA'], $timerA, '::getTimers() returns an array with keys being the timer name');
sfTimerManager::clearTimers();
$t->is(count(sfTimerManager::getTimers()), 0, '::clearTimers() empties the list of the timer instances');
Exemplo n.º 15
0
 /**
  * Executes list action, adding ratings from routes linked to outings
  */
 public function executeList()
 {
     // redirect to user outings list if connected and if myoutings criteria is set
     if ($this->getUser()->isConnected() && $this->getRequestParameter('myoutings')) {
         sfLoader::loadHelpers(array('Pagination'));
         $user_id = $this->getUser()->getId();
         $this->redirect(_addUrlParameters(_getBaseUri(), array('myoutings'), array('users' => $user_id)));
     }
     // TODO something to do if outings where filtered on route ratings?
     parent::executeList();
     $format = $this->format;
     if (in_array('cond', $format) && !in_array('json', $format)) {
         $this->setTemplate('conditions');
         if (in_array('full', $format)) {
             $this->setPageTitle($this->__('conditions and comments'));
         } else {
             $this->setPageTitle($this->__('recent conditions'));
         }
     }
     $nb_results = $this->nb_results;
     if ($nb_results == 0) {
         return;
     }
     $show_images = $this->show_images;
     $timer = new sfTimer();
     $outings = $this->query->execute(array(), Doctrine::FETCH_ARRAY);
     c2cActions::statsdTiming('pager.getResults', $timer->getElapsedTime());
     $timer = new sfTimer();
     $outings = Outing::getAssociatedCreatorData($outings);
     // retrieve outing creator names
     c2cActions::statsdTiming('outing.getAssociatedCreatorData', $timer->getElapsedTime());
     $timer = new sfTimer();
     $outings = Outing::getAssociatedRoutesData($outings);
     // retrieve associated route ratings
     c2cActions::statsdTiming('outing.getAssociatedRoutesData', $timer->getElapsedTime());
     if (!in_array('list', $format)) {
         $timer = new sfTimer();
         $outings = Language::getTheBestForAssociatedAreas($outings);
         c2cActions::statsdTiming('language.getTheBestForAssociatedAreas', $timer->getElapsedTime());
     }
     // add images infos
     if ($show_images) {
         $timer = new sfTimer();
         Image::addAssociatedImages($outings, 'oi');
         c2cActions::statsdTiming('image.addAssociatedImages', $timer->getElapsedTime());
     }
     Area::sortAssociatedAreas($outings);
     $this->items = Language::parseListItems($outings, 'Outing', !$show_images);
 }
Exemplo n.º 16
0
<?php

require_once dirname(__FILE__) . '/../bootstrap/functional.php';
require_once $_SERVER['SYMFONY'] . '/vendor/lime/lime.php';
require_once sfConfig::get('sf_lib_dir') . '/test/unitHelper.php';
$t = new lime_test(257);
$timer = new sfTimer();
// stub class used for testing
class ioMenuItemTest extends ioMenuItem
{
    // resets the isCurrent property so we can test for current repeatedly.
    public function resetIsCurrent()
    {
        $this->_isCurrent = null;
    }
    // resets the userAccess property so we can test for current repeatedly.
    public function resetUserAccess()
    {
        $this->_userAccess = null;
    }
}
$t->info('1 - Test basic getters, setters and constructor');
$menu = new ioMenuItem('test menu', '@homepage', array('title' => 'my menu'));
$t->is($menu->getName(), 'test menu', '->getName() returns the given name.');
$menu->setName('new menu name');
$t->is($menu->getName(), 'new menu name', '->setName() sets the name correctly.');
$t->is($menu->getLabel(), 'new menu name', '->getLabel() returns the name if the label does not exist.');
$menu->setLabel('menu label');
$t->is($menu->getLabel(), 'menu label', 'Once set, ->getLabel() returns the actual label.');
$t->is($menu->getRoute(), '@homepage', '->getRoute() returns the given route.');
$menu->setRoute('http://www.sympalphp.org');
Exemplo n.º 17
0
 /**
  * Executes list action
  */
 public function executeList()
 {
     parent::executeList();
     $nb_results = $this->nb_results;
     if ($nb_results == 0) {
         return;
     }
     $timer = new sfTimer();
     $summits = $this->query->execute(array(), Doctrine::FETCH_ARRAY);
     c2cActions::statsdTiming('pager.getResults', $timer->getElapsedTime());
     $timer = new sfTimer();
     Document::countAssociatedDocuments($summits, 'sr', true);
     c2cActions::statsdTiming('document.countAssociatedDocuments', $timer->getElapsedTime());
     Area::sortAssociatedAreas($summits);
     $this->items = Language::parseListItems($summits, 'Summit');
 }
function persist_menu(lime_test $t, ioDoctrineMenuItem $rt, ioMenuItem $menu)
{
    $timer = new sfTimer();
    $rt->persistFromMenuArray($menu->toArray());
    $timer->addTime();
    $rt->refresh(true);
    $t->info(sprintf('### Menu took %s to persist (%s nodes/min)', round($timer->getElapsedTime(), 4), floor(8 * 60 / $timer->getElapsedTime())));
}
 /**
  * @see Connection::executeUpdate()
  **/
 public function executeUpdate($sql)
 {
     $this->lastExecutedQuery = $sql;
     $this->numQueriesExecuted++;
     $boolLog = sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled') || nyProfiler::getInstance()->isStarted();
     $elapsedTime = 0;
     if ($boolLog) {
         $sqlTimer = sfTimerManager::getTimer('Database');
         $timer = new sfTimer();
     }
     // endif
     $intResult = $this->childConnection->executeUpdate($sql);
     if ($boolLog) {
         $sqlTimer->addTime();
         $elapsedTime = $timer->getElapsedTime();
     }
     // endif
     $this->log(sprintf("{sfCreole} executeUpdate(): [%.2f ms] %s", $elapsedTime * 1000, $sql), true);
     return $intResult;
 }
Exemplo n.º 20
0
    'theme-s'    => 'name of the theme to use (optional, defaults to "default")',
    'search-s'   => 'type of searchbox to use, may be "None", "XmlJs" or "Ajax"',
    'verbose|v'  => 'Outputs any information collected by this application, may slow down the process slightly',
  ));

  // parse the command line arguments
  $opts->parse();

  // the user has indicated that he would like help
  if ($opts->getOption('h'))
  {
    throw new Zend_Console_Getopt_Exception('');
  }

  // initialize timer
  $timer = new sfTimer();

  if ($opts->getOption('output'))
  {
    $writer = $opts->getOption('output');
  } else
  {
    if (!isset(DocBlox_Abstract::config()->transformation->writer))
    {
      throw new Exception('Unable to find configuration entry for the transformation writer, please check your configuration file.');
    }
    $writer = DocBlox_Abstract::config()->transformation->writer;
  }
  $writer = 'DocBlox_Writer_'.ucfirst($writer);
  $writer = new $writer();