function includeDummyPartial($templateName, $vars = array(), $context = null) { if (is_null($context)) { $context = createContext(); } if (false !== ($sep = strpos($templateName, '/'))) { $moduleName = substr($templateName, 0, $sep); $templateName = substr($templateName, $sep + 1); } else { $moduleName = 'module'; // current module name } $actionName = '_' . $templateName; $view = new sfTemplatingComponentPartialView($context, $moduleName, $actionName, ''); $view->setPartialVars($vars); try { return $view->render(); } catch (Exception $e) { return false; } }
} public function doLoad($template, $renderer = 'php') { $this->loaded = true; if ('invalidBool' === $template) { return false; } elseif ('invalidInt' === $template) { return 0; } elseif ('invalidString' === $template) { return ''; } return 'valid'; } } } $context = createContext(); $view = new sfTemplatingComponentView($context, 'module', 'action', ''); $loader = new myLoader($view, $context, array('key' => 'value')); $t->diag('->configure()'); $t->is($loader->configured, true, '->configure() is executed in the constructor'); $t->diag('->getParameter()'); $t->is($loader->getParameter('key'), 'value', '->getParameter() returns the value of the specified parameter'); $t->is($loader->getParameter('unknown-key'), null, '->getParameter() returns null if the specified parameter does not exist'); $t->is($loader->getParameter('unknown-key', 'default'), 'default', '->getParameter() returns the specified default value'); $t->diag('->doLoad()'); $t->is($loader->loaded, false, '->doLoad() is not executed in the constructor'); $loader->load('test'); $t->is($loader->loaded, true, '->doLoad() is executed in the load() method'); $t->ok($loader->load('invalidBool') === false, '->laod() returns false if the doLoad() method returns false'); $t->ok($loader->load('invalidInt') === false, '->laod() returns false if the doLoad() method returns 0'); $t->ok($loader->load('invalidString') === false, '->laod() returns false if the doLoad() method returns empty string');
$stmt->execute(); $agencyArray = $stmt->fetchAll(); $agencyId = $agencyArray[0]['agencyId']; // Change '/' to '-' in name, otherwise problem with filename $agencyId = preg_replace('/\\//', '-', $agencyId); $arrivalsFilename = 'dist/arrivals-' . $agencyId . '.jsonldstream'; $departuresFilename = 'dist/departures-' . $agencyId . '.jsonldstream'; // delete previous files if (file_exists($arrivalsFilename)) { unlink($arrivalsFilename); } if (file_exists($departuresFilename)) { unlink($departuresFilename); } // Write context to the files $context = createContext($agencyId); writeToFile($arrivalsFilename, $context); writeToFile($departuresFilename, $context); // This holds array of dates with corresponding serviceIds // We need serviceIds per day to query ordered arrivals/departures $date_serviceIdsArray = []; $arrivalNr = 1; // counter for arrival @id $departureNr = 1; // counter for departure @id // Let's generate list of dates with corresponding serviceId from calendars first $sql = "\n SELECT *\n FROM calendars\n "; $stmt = $entityManager->getConnection()->prepare($sql); $stmt->execute(); $calendars = $stmt->fetchAll(); // When there are calendars