function restoreDBFromBackup() { makeRed("Restore Database? WARNING: This will drop all tables and restore data to last backup!"); echo "(Y/N): "; $data = FOPEN("php://stdin", "rb"); $input = ''; while (1 == 1) { $chunk = FREAD($data, 1); if ($chunk == "\n" || $chunk == "\r") { break; } $input .= $chunk; } FCLOSE($data); if (strtolower(@$input) == 'y') { echo "Getting Credentials from application.ini...\n"; $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $bootstrap = $application->getBootstrap(); $options = $bootstrap->getOptions(); $db = $options['resources']['db']['params']; echo "Database Restoring. Please be patient, this could take a while..."; sleep(1); echo "."; sleep(1); echo "."; sleep(1); echo "."; echo "\n"; exec("mysql -u " . $db['username'] . " -p" . $db['password'] . " " . $db['dbname'] . " < " . APPLICATION_PATH . "/../data/dbbackup.sql", $output); makeGreen("DONE!"); echo "\n\n"; } else { echo "Operation Cancelled.\n"; } }
public function doRequest($request) { // redirector should not exit $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->setExit(false); // json helper should not exit $json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $zendRequest = new \Zend_Controller_Request_HttpTestCase(); $zendRequest->setMethod($request->getMethod()); $zendRequest->setCookies($request->getCookies()); $zendRequest->setParams($request->getParameters()); $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri())); $zendRequest->setHeaders($request->getServer()); $_FILES = $request->getFiles(); $_SERVER = array_merge($_SERVER, $request->getServer()); $zendResponse = new \Zend_Controller_Response_HttpTestCase(); $this->front->setRequest($zendRequest)->setResponse($zendResponse); ob_start(); $this->bootstrap->run(); ob_end_clean(); $this->zendRequest = $zendRequest; $response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $zendResponse->getHeaders()); return $response; }
protected function setUp() { parent::setUp(); $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $application->getBootstrap()->bootstrap(); $this->_form = new Student_Form_CreateStudentProfile(); }
/** * Prepares the environment before running ALL tests. */ public static function setUpBeforeClass() { // Inicializa o ZF $inifile = getenv('TRAVIS') !== false ? 'application.travis.ini' : 'application.ini'; $bootstrap = new Zend_Application('testing', TEST_ROOT . '/assets/application/configs/' . $inifile); $bootstrap->bootstrap(); }
public function setUp() { $application = new Zend_Application('testing', APPLICATION_PATH . '/configs/application.ini'); $bootstrap = $application->bootstrap()->getBootstrap(); $this->em = $bootstrap->getResource('entityManager'); parent::setUp(); }
public function testBootstrap() { $application = new Zend_Application('tests', dirname(__FILE__) . '/application.ini'); $rediska = $application->bootstrap()->getBootstrap()->getResource('rediska'); $this->assertType('Rediska', $rediska); $this->assertEquals('Rediska_Test_', $rediska->getOption('namespace')); }
public function doRequest($request) { // redirector should not exit $redirector = \Zend_Controller_Action_HelperBroker::getStaticHelper('redirector'); $redirector->setExit(false); // json helper should not exit $json = \Zend_Controller_Action_HelperBroker::getStaticHelper('json'); $json->suppressExit = true; $zendRequest = new \Zend_Controller_Request_HttpTestCase(); $zendRequest->setMethod($request->getMethod()); $zendRequest->setCookies($request->getCookies()); $zendRequest->setParams($request->getParameters()); // Sf2's BrowserKit does not distinguish between GET, POST, PUT etc., // so we set all parameters in ZF's request here to not break apps // relying on $request->getPost() $zendRequest->setPost($request->getParameters()); $zendRequest->setRawBody($request->getContent()); $zendRequest->setRequestUri(str_replace('http://localhost', '', $request->getUri())); $zendRequest->setHeaders($this->extractHeaders($request)); $_FILES = $this->remapFiles($request->getFiles()); $_SERVER = array_merge($_SERVER, $request->getServer()); $zendResponse = new \Zend_Controller_Response_HttpTestCase(); $this->front->setRequest($zendRequest)->setResponse($zendResponse); ob_start(); try { $this->bootstrap->run(); } catch (\Exception $e) { ob_end_clean(); throw $e; } ob_end_clean(); $this->zendRequest = $zendRequest; $response = new Response($zendResponse->getBody(), $zendResponse->getHttpResponseCode(), $this->formatResponseHeaders($zendResponse)); return $response; }
public function testBootstrap() { $application = new Zend_Application('tests', REDISKA_TESTS_PATH . '/Test/Zend/Application/application.ini'); $rediska = $application->bootstrap()->getBootstrap()->getResource('rediska'); $this->assertType('Rediska', $rediska); $this->assertEquals('Rediska_Test_', $rediska->getOption('namespace')); }
/** * * @return Zend_Application */ public static function getApplication() { $application = new Zend_Application(APPLICATION_ENV); $applicationini = new Zend_Config_Ini(APPLICATION_PATH . "/configs/application.ini", APPLICATION_ENV); $options = $applicationini->toArray(); foreach (self::$_ini as $value) { $iniFile = APPLICATION_PATH . self::$_pathConfig . $value; if (is_readable($iniFile)) { $config = new Zend_Config_Ini($iniFile); $options = $application->mergeOptions($options, $config->toArray()); } else { throw new Zend_Exception('error en la configuracion de los .ini'); } } // foreach (self::$_ini as $value) { // $iniFile = APPLICATION_PATH . self::$_pathConfig . $value; // // if (is_readable($iniFile)) { // $config = new Zend_Config_Ini($iniFile); // $options = $application->mergeOptions($options, // $config->toArray()); // } else { // throw new Zend_Exception('error en la configuracion de los .ini'); // } // } Zend_Registry::set('config', $options); $a = $application->setOptions($options); return $application; }
public function init() { // Define some CLI options $getopt = new Zend_Console_Getopt(array('withdata|w' => 'Load database with sample data', 'env|e-s' => 'Application environment for which to create database (defaults to development)', 'help|h' => 'Help -- usage message')); try { $getopt->parse(); } catch (Zend_Console_Getopt_Exception $e) { // Bad options passed: report usage echo $e->getUsageMessage(); return false; } // Initialize Zend_Application $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); // Initialize and retrieve DB resource $bootstrap = $application->getBootstrap(); $bootstrap->bootstrap('db'); $dbAdapter = $bootstrap->getResource('db'); // let the user know whats going on (we are actually creating a // database here) if ('testing' != APPLICATION_ENV) { echo 'Writing Database Guestbook in (control-c to cancel): ' . PHP_EOL; for ($x = 5; $x > 0; $x--) { echo $x . "\r"; sleep(1); } } vd(1); }
public static function bootstrap() { // // set the include_path set_include_path(implode(PATH_SEPARATOR, array('/usr/share/php/libzend-framework-php', realpath(APPLICATION_PATH . '/../glo-framework/library'), realpath(APPLICATION_PATH . '/../glo-generated'), realpath(APPLICATION_PATH . '/../library'), realpath(APPLICATION_PATH . '/../vendor'), get_include_path()))); // // set up the autoloader require_once 'Zend/Loader/Autoloader.php'; require_once 'Glo/Loader.php'; $autoLoader = Zend_Loader_Autoloader::getInstance(); $autoLoader->pushAutoloader(array('Glo_Loader', 'loadClass')); $autoLoader->setFallbackAutoloader(true); // // register the config $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', Glo_Environment::get(), array('allowModifications' => TRUE)); $registry = Zend_Registry::getInstance(); $registry->set('config', $config); // // initialize the Zend Application require_once 'Zend/Application.php'; $application = new Zend_Application(Glo_Environment::get(), APPLICATION_PATH . '/configs/application.ini'); // // register the database configuration $bootstrap = $application->getBootstrap(); $bootstrap->bootstrap('multidb'); $resource = $bootstrap->getResource('multidb'); Zend_Registry::set("conn_read", $resource->getDb('read')); Zend_Registry::set("conn_read_volatile", $resource->getDb('read_volatile')); Zend_Registry::set("conn_write", $resource->getDb('write')); return $application; }
public function setUp() { parent::setUp(); $app = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $app->getBootstrap()->bootstrap(); $this->_form = new Student_Form_UpdateProfile(); }
protected function setUp() { parent::setUp(); $app = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . "/configs/application.ini"); $app->bootstrap('translate'); $this->translate = $app->getBootstrap()->getResource('translate'); $this->translate->setLocale(new Zend_Locale('vi_VN')); }
public static function bootstrap($resource = null) { include_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('Saffron_'); $application = new Zend_Application(self::_getEnv(), self::_getConfig()); return $application->getBootstrap()->bootstrap($resource); }
public function testNewInstance() { $application = new Zend_Application('tests', dirname(__FILE__) . '/application4.ini'); $application->bootstrap()->getBootstrap()->getResource('session'); $rediska = Zend_Session::getSaveHandler()->getRediska(); $this->assertEquals('default', $rediska->getOption('name')); $this->assertEquals(array(), Rediska_Manager::getAll()); }
/** * Overwrite standard setUp method, no database connection needed. Will * create a file listing of class files instead. * * @return void */ public function setUp() { require_once 'Zend/Application.php'; set_include_path('../modules' . PATH_SEPARATOR . get_include_path()); // Do test environment initializiation. $application = new Zend_Application(APPLICATION_ENV, array("config" => array(APPLICATION_PATH . '/application/configs/application.ini', APPLICATION_PATH . '/tests/config.ini'))); $application->bootstrap(); }
/** * Constructor * * Invoke setContainerFactory, set _coantainerFactory if factory is configurated * Ensure FrontController resource is registered * * @param Zend_Application|Zend_Application_Bootstrap_Bootstrapper $application * @return void */ public function __construct($application) { $this->setContainerFactory($application->getOptions()); parent::__construct($application); if (!$this->hasPluginResource('FrontController')) { $this->registerPluginResource('FrontController'); } }
public function testCleanWithNoIdsToClean() { $application = new Zend_Application('tests', dirname(__FILE__) . '/application5.ini'); /* @var Zend_Cache_Manager $manager */ $manager = $application->bootstrap()->getBootstrap()->getResource('cachemanager'); $actual = $manager->getCache('test')->clean(Zend_Cache::CLEANING_MODE_ALL); $this->assertFalse($actual); }
public function setUp() { include APPLICATION_PATH . '/../scripts/load.sqlite.php'; $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $this->bootstrap = array($application->getBootstrap(), 'bootstrap'); return parent::setUp(); }
public function setUp() { include APPLICATION_PATH . '/../scripts/load.sqlite.php'; $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $bootstrap = $application->getBootstrap(); $bootstrap->bootstrap('autoload'); $bootstrap->bootstrap('db'); $this->guestbook = new Model_Guestbook(); }
public function testNewInstance() { $application = new Zend_Application('tests', dirname(__FILE__) . '/application4.ini'); $manager = $application->bootstrap()->getBootstrap()->getResource('cachemanager'); $manager->getCache('test')->save('1', 'test'); $rediska = new Rediska(array('redisVersion' => '2.0', 'addToManager' => false)); $one = $rediska->get('test'); $this->assertEquals('1', $one[0]); $this->assertEquals(array(), Rediska_Manager::getAll()); }
public function qsBootstrap() { $this->application->bootstrap(); $bootstrap = $this->application->getBootstrap(); $frontController = $bootstrap->getResource('FrontController'); $frontController->setParam('bootstrap', $bootstrap); $configApplication = $this->application->bootstrap('config'); $requestConfig = $configApplication->getOption('request'); $this->requestParameterName = $requestConfig['parameter']; }
public function __construct(\Zend_Application $application) { parent::__construct(); $this->_application = $application; $this->_bootstrap = $application->getBootstrap(); $this->_angel_bootstrap = $this->_bootstrap->getResource('modules')->offsetGet('angel'); $this->_container = $this->_bootstrap->getResource('serviceContainer'); $this->_documentManager = $this->_angel_bootstrap->getResource('mongoDocumentManager'); $this->_logger = $this->_bootstrap->getResource('logger'); }
public function testNewInstance() { $application = new Zend_Application('tests', dirname(__FILE__) . '/application4.ini'); $log = $application->bootstrap()->getBootstrap()->getResource('log'); $log->err('123'); $log->info('123'); $rediska = new Rediska(array('redisVersion' => '2.0', 'addToManager' => false)); $count = $rediska->getListLength('log'); $this->assertEquals(2, $count); $this->assertEquals(array(), Rediska_Manager::getAll()); }
public static function getOption($key) { $front = Zend_Controller_Front::getInstance(); $boot = $front->getParam('bootstrap'); if (empty($boot)) { $application = new Zend_Application(APPLICATION_ENV, CONFIG_PATH . '/' . APPLICATION_CONFIG_FILENAME); return $application->getOption($key); } else { return $front->getParam('bootstrap')->getOption($key); } }
public function testDefaultAndAnother() { $application = new Zend_Application('tests', dirname(__FILE__) . '/application4.ini'); $application->bootstrap()->getBootstrap()->getResource('rediska'); $default = Rediska_Manager::get('default'); $this->assertEquals('defaultInstance', $default->getOption('namespace')); $another = Rediska_Manager::get('another'); $this->assertEquals('anotherInstance', $another->getOption('namespace')); $this->assertEquals(2, count(Rediska_Manager::getAll())); $this->assertEquals($default, Zend_Registry::get('rediska')); }
public static function bootstrap() { // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing'); !defined('UPLOAD_PATH') ? define('UPLOAD_PATH', realpath(dirname(__FILE__) . '/../public/upload')) : null; defined('HTTP_PATH') || define('HTTP_PATH', realpath(dirname(__FILE__)) . '/../public'); require_once 'Zend/Application.php'; $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $application->bootstrap(); }
/** * Init Application */ public static function appInit() { $config = APPLICATION_PATH . '/configs/application.yaml'; $result = new Core_Config_Yaml($config, APPLICATION_ENV); $result = $result->toArray(); // Create application, bootstrap, and run $application = new Zend_Application(APPLICATION_ENV, $result); // $application->bootstrap(); // $application->bootstrap('Frontcontroller'); $application->bootstrap(); $acl = new Core_Controller_Plugin_Acl(); $acl->getAcl(); self::migrationUp(); }
public static function bootstrap($resource = null) { include_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->registerNamespace('Vslice_'); $autoloader->registerNamespace('ZFDebug'); // $autoloader->registerNamespace('Bvb'); $autoloader->registerNamespace('My'); $autoloader->registerNamespace('F5'); $autoloader->registerNamespace('Zendx'); $options = array('jquery_path' => 'http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js', 'plugins' => array('Variables', 'Html', 'File' => array('base_path' => '/Library/WebServer/Documents/'), 'Memory', 'Time', 'Exception')); $debug = new ZFDebug_Controller_Plugin_Debug($options); $application = new Zend_Application(self::_getEnv(), self::_getConfig()); return $application->getBootstrap()->bootstrap($resource); }
/** * bootstrap application */ public function appBootstrap() { $this->_application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $this->_application->bootstrap(); /* * Fix for ZF-8193 * http://framework.zend.com/issues/browse/ZF-8193 * Zend_Controller_Action->getInvokeArg('bootstrap') doesn't work * under the unit testing environment. */ $front = Zend_Controller_Front::getInstance(); if ($front->getParam('bootstrap') === null) { $front->setParam('bootstrap', $this->_application->getBootstrap()); } }