作者:rkepli
项目:zf
public function setUp()
{
date_default_timezone_set('America/Los_Angeles');
// Reset front controller to reset registered plugins and
// registered request/response objects
\Zend\Controller\Front::getInstance()->resetInstance();
$this->_request = new FirePhpHeader();
$this->_response = new MockHttpResponse();
$channel = Channel\HttpHeaders::getInstance();
$channel->setRequest($this->_request);
$channel->setResponse($this->_response);
$this->_writer = new FirebugWriter();
// Explicitly enable writer as it is disabled by default
// when running from the command line.
$this->_writer->setEnabled(true);
$this->_logger = new Logger($this->_writer);
FirePhp::getInstance()->setOption('includeLineNumbers', false);
}
作者:bradley-hol
项目:zf
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @return void
*/
public function setUp()
{
$this->front = \Zend\Controller\Front::getInstance();
$this->front->resetInstance();
$this->request = new Request\Http();
$this->front->setRequest($this->request);
}
作者:niallmccrudde
项目:zf
protected function setUp()
{
if (!extension_loaded('pdo_sqlite')) {
$this->markTestSkipped('Pdo_Sqlite extension is not loaded');
}
$this->_adapter = new \Zend\Db\Adapter\Pdo\Sqlite(array(
'dbname' => __DIR__ . '/_files/test.sqlite'
));
$this->_query = $this->_adapter->select()->from('test');
$this->_testCollection = range(1, 101);
$this->_paginator = Paginator\Paginator::factory($this->_testCollection);
$this->_config = new Config\Xml(__DIR__ . '/_files/config.xml');
// get a fresh new copy of ViewRenderer in each tests
$this->front = FrontController::getInstance();
$this->front->resetInstance();
$this->broker = $this->front->getHelperBroker();
$fO = array('lifetime' => 3600, 'automatic_serialization' => true);
$bO = array('cache_dir'=> $this->_getTmpDir());
$this->_cache = \Zend\Cache\Cache::factory('Core', 'File', $fO, $bO);
Paginator\Paginator::setCache($this->_cache);
$this->_restorePaginatorDefaults();
}
作者:zendmaniac
项目:zly-template
public function init()
{
$this->_front = \Zend\Controller\Front::getInstance();
if ($this->_front->hasPlugin('Zend\\Layout\\Controller\\Plugin\\Layout')) {
$this->_layout = $this->_front->getPlugin('Zend\\Layout\\Controller\\Plugin\\Layout')->getLayout();
}
}
作者:alab100110
项目:zf
protected function setUp()
{
$this->_originaltimezone = date_default_timezone_get();
date_default_timezone_set('Europe/Berlin');
if (isset($_SERVER['SERVER_NAME'])) {
$this->_oldServer['SERVER_NAME'] = $_SERVER['SERVER_NAME'];
}
if (isset($_SERVER['SERVER_PORT'])) {
$this->_oldServer['SERVER_PORT'] = $_SERVER['SERVER_PORT'];
}
if (isset($_SERVER['REQUEST_URI'])) {
$this->_oldServer['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
}
$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['SERVER_PORT'] = 80;
$_SERVER['REQUEST_URI'] = '/';
$this->_front = \Zend\Controller\Front::getInstance();
$this->_oldRequest = $this->_front->getRequest();
$this->_oldRouter = $this->_front->getRouter();
$this->_front->resetInstance();
$this->_front->setRequest(new Request\Http());
$this->_front->getRouter()->addDefaultRoutes();
parent::setUp();
$this->_helper->setFormatOutput(true);
}
作者:niallmccrudde
项目:zf
/**
* Encode data as JSON, disable layouts, and set response header
*
* If $keepLayouts is true, does not disable layouts.
*
* @param mixed $data
* @param bool $keepLayouts
* NOTE: if boolean, establish $keepLayouts to true|false
* if array, admit params for Zend_Json::encode as enableJsonExprFinder=>true|false
* this array can contains a 'keepLayout'=>true|false
* that will not be passed to Zend_Json::encode method but will be used here
* @return string|void
*/
public function direct($data = null, $keepLayouts = false)
{
if ($data == null) {
throw new \InvalidArgumentException('JSON: missing argument. $data is required in json($data, $keepLayouts = false)');
}
$options = array();
if (is_array($keepLayouts))
{
$options = $keepLayouts;
$keepLayouts = (array_key_exists('keepLayouts', $keepLayouts))
? $keepLayouts['keepLayouts']
: false;
unset($options['keepLayouts']);
}
$data = \Zend\Json\Json::encode($data, null, $options);
if (!$keepLayouts) {
$layout = LayoutManager::getMvcInstance();
if ($layout instanceof LayoutManager) {
$layout->disableLayout();
}
}
$response = \Zend\Controller\Front::getInstance()->getResponse();
$response->setHeader('Content-Type', 'application/json');
return $data;
}
作者:niallmccrudde
项目:zf
public function setUp()
{
$front = \Zend\Controller\Front::getInstance();
$front->resetInstance();
$front->setParam('noErrorHandler', true)
->setParam('noViewRenderer', true);
$this->_dispatcher = $front->getDispatcher();
$this->_dispatcher->setControllerDirectory(array(
'default' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files',
'mod' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Admin',
));
$defaults = array(
'controller' => 'defctrl',
'action' => 'defact',
'module' => 'default'
);
$this->_request = new \Zend\Controller\Request\Http();
$front->setRequest($this->_request);
$this->route = new Route\Module($defaults, $this->_dispatcher, $this->_request);
}
作者:nevvermin
项目:zf
/**
* Renders a template fragment within a variable scope distinct from the
* calling View object.
*
* If no arguments are passed, returns the helper instance.
*
* If the $model is an array, it is passed to the view object's assign()
* method.
*
* If the $model is an object, it first checks to see if the object
* implements a 'toArray' method; if so, it passes the result of that
* method to to the view object's assign() method. Otherwise, the result of
* get_object_vars() is passed.
*
* @param string $name Name of view script
* @param string|array $module If $model is empty, and $module is an array,
* these are the variables to populate in the
* view. Otherwise, the module in which the
* partial resides
* @param array $model Variables to populate in the view
* @return string|\Zend\View\Helper\Partial\Partial
* @throws Exception\RuntimeException
*/
public function __invoke($name = null, $module = null, $model = null)
{
if (0 == func_num_args()) {
return $this;
}
$view = $this->cloneView();
if (isset($this->partialCounter)) {
$view->partialCounter = $this->partialCounter;
}
if (null !== $module && is_string($module)) {
$moduleDir = \Zend\Controller\Front::getInstance()->getControllerDirectory($module);
if (null === $moduleDir) {
throw new Exception\RuntimeException('Cannot render partial; module does not exist');
}
$viewsDir = dirname($moduleDir) . '/views';
$view->resolver()->addPath($viewsDir . '/scripts');
} elseif (null == $model && null !== $module && (is_array($module) || is_object($module))) {
$model = $module;
}
if (!empty($model)) {
if (is_array($model)) {
$view->vars()->assign($model);
} elseif (is_object($model)) {
if (null !== ($objectKey = $this->getObjectKey())) {
$view->vars()->offsetSet($objectKey, $model);
} elseif (method_exists($model, 'toArray')) {
$view->vars()->assign($model->toArray());
} else {
$view->vars()->assign(get_object_vars($model));
}
}
}
return $view->render($name);
}
作者:bradley-hol
项目:zf
public function setUp()
{
$this->application = new Application('testing');
$this->bootstrap = new ZfAppBootstrap($this->application);
$this->front = FrontController::getInstance();
$this->front->resetInstance();
}
作者:niallmccrudde
项目:zf
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @return void
*/
public function setUp()
{
\Zend\Layout\Layout::resetMvcInstance();
$this->front = Controller\Front::getInstance();
$this->front->resetInstance();
$this->front->addModuleDirectory(__DIR__ . '/../../_files/modules');
$this->broker = $this->front->getHelperBroker();
$this->layout = Layout\Layout::startMvc();
$this->helper = new Helper\ContextSwitch();
$this->broker->register('contextswitch', $this->helper);
$this->request = new \Zend\Controller\Request\Http();
$this->response = new \Zend\Controller\Response\Cli();
$this->front->setRequest($this->request)
->setResponse($this->response)
->addControllerDirectory(__DIR__);
$this->view = new \Zend\View\PhpRenderer();
$this->viewRenderer = $this->broker->load('viewRenderer');
$this->viewRenderer->setView($this->view);
$this->controller = new ContextSwitchTestController(
$this->request,
$this->response,
array()
);
$this->controller->setHelperBroker($this->broker);
$this->controller->setupContexts();
$this->helper->setActionController($this->controller);
}
作者:bradley-hol
项目:zf
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @return void
*/
public function setUp()
{
$this->front = \Zend\Controller\Front::getInstance();
$this->front->resetInstance();
$this->front->setRequest(new \Zend\Controller\Request\Http());
$this->helper = new \Zend\Controller\Action\Helper\Url();
}
作者:bradley-hol
项目:zf
public function setUp()
{
$this->application = new Application\Application('testing');
$this->bootstrap = new Application\Bootstrap($this->application);
$this->bootstrap->getBroker()->registerSpec('view');
FrontController::getInstance()->resetInstance();
}
作者:bradley-hol
项目:zf
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
\Zend\Controller\Front::getInstance()->resetInstance();
$this->request = new \Zend\Controller\Request\HttpTestCase();
$this->plugin = new \Zend\Controller\Plugin\PutHandler();
$this->plugin->setRequest($this->request);
}
作者:heiglandrea
项目:zf
public function setUp()
{
$this->_front = FrontController::getInstance();
$this->_front->resetInstance();
$this->_front->setParam('noErrorHandler', true)->setParam('noViewRenderer', true);
$this->_dispatcher = $this->_front->getDispatcher();
$this->_dispatcher->setControllerDirectory(array('default' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . '_files', 'mod' => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Controller' . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'Admin'));
}
作者:RomanShumko
项目:zf
public function setUp()
{
$this->application = new Application('testing', array('resources' => array('frontcontroller' => array())));
$this->bootstrap = new ZfAppBootstrap($this->application);
$this->front = FrontController::getInstance();
$this->front->resetInstance();
$this->broker = $this->front->getHelperBroker();
}
作者:rexma
项目:zf
/**
* Test Function for replaceAction
*
* @return void
*/
public function replaceAction()
{
$request = new \Zend\Controller\Request\Http();
$request->setControllerName('index')->setActionName('reset')->setDispatched(false);
$response = new \Zend\Controller\Response\Http();
$front = \Zend\Controller\Front::getInstance();
$front->setRequest($request)->setResponse($response);
}
作者:jsugg
项目:BBM_ol
public function _initRoutes()
{
$this->bootstrap('FrontController');
$front = Front::getInstance();
$router = new RouterRewrite();
$router->addRoute('game-view', new Route('game/view/:game_id/:game_name', array('module' => 'default', 'controller' => 'game', 'action' => 'view')));
$front->setRouter($router);
}
作者:alab100110
项目:zf
/**
* Instantiates route based on passed Zend_Config structure
*/
public static function getInstance(Config\Config $config)
{
$frontController = \Zend\Controller\Front::getInstance();
$defs = $config->defaults instanceof Config\Config ? $config->defaults->toArray() : array();
$dispatcher = $frontController->getDispatcher();
$request = $frontController->getRequest();
return new self($defs, $dispatcher, $request);
}
作者:alab100110
项目:zf
/**
* Sets up the fixture, for example, open a network connection.
* This method is called before a test is executed.
*
* @access protected
*/
protected function setUp()
{
$this->front = \Zend\Controller\Front::getInstance();
$this->front->getRouter()->addDefaultRoutes();
// $this->view = new Zend_View();
$this->helper = new \Zend\View\Helper\Url();
// $this->helper->setView($this->view);
}
作者:rafec
项目:ZFDebug-for-ZF
/**
* Get the ZFDebug logger
*
* @return Zend_Log
*/
public function getLogger()
{
if (!$this->_logger) {
$this->_logger = FrontController::getInstance()->getPlugin('\\ZFDebug\\Controller\\Plugin\\Debug')->getPlugin('Log');
$this->_logger->getLog()->addPriority('Memory', 8);
}
return $this->_logger;
}