本文整理汇总了PHP中Zend\Console\Console::overrideIsConsole方法的典型用法代码示例。如果您正苦于以下问题:PHP Console::overrideIsConsole方法的具体用法?PHP Console::overrideIsConsole怎么用?PHP Console::overrideIsConsole使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Console\Console
的用法示例。
在下文中一共展示了Console::overrideIsConsole方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initialize
public function _initialize()
{
require Configuration::projectDir() . 'init_autoloader.php';
$this->applicationConfig = (require Configuration::projectDir() . $this->config['config']);
if (isset($applicationConfig['module_listener_options']['config_cache_enabled'])) {
$applicationConfig['module_listener_options']['config_cache_enabled'] = false;
}
Console::overrideIsConsole(false);
}
示例2: it_aborts_bootstrap_on_console
public function it_aborts_bootstrap_on_console(MvcEvent $event, Application $application, ServiceLocatorInterface $serviceLocator, AccessListener $listener, EventManager $eventManager)
{
Console::overrideIsConsole(true);
$application->getEventManager()->willReturn($eventManager);
$serviceLocator->get(AccessListener::class)->willReturn($listener);
$application->getServiceManager()->willReturn($serviceLocator);
$event->getApplication()->willReturn($application);
$listener->attach($eventManager)->shouldNotBeCalled();
$this->onBootstrap($event);
}
示例3: testCanForceInstance
public function testCanForceInstance()
{
$console = Console::getInstance('Posix');
$this->assertTrue($console instanceof Adapter\AdapterInterface);
$this->assertTrue($console instanceof Adapter\Posix);
Console::overrideIsConsole(null);
Console::resetInstance();
$console = Console::getInstance('Windows');
$this->assertTrue($console instanceof Adapter\AdapterInterface);
$this->assertTrue($console instanceof Adapter\Windows);
}
示例4: testUrlHelperUnderConsoleParadigmShouldReturnHttpRoutes
public function testUrlHelperUnderConsoleParadigmShouldReturnHttpRoutes()
{
Console::overrideIsConsole(true);
$this->serviceManager->get('Application')->bootstrap();
$request = $this->serviceManager->get('Request');
$this->assertInstanceOf('Zend\\Console\\Request', $request);
$viewHelpers = $this->serviceManager->get('ViewHelperManager');
$urlHelper = $viewHelpers->get('url');
$test = $urlHelper('test');
$this->assertEquals('/test', $test);
}
示例5: getApplication
/**
* @return \Zend\Mvc\Application
*/
public function getApplication()
{
if ($this->spiffyApplication) {
return $this->spiffyApplication;
}
Console::overrideIsConsole($this->getUseConsoleRequest());
$this->spiffyApplication = SpiffyTest::getInstance()->getApplication();
$events = $this->spiffyApplication->getEventManager();
$events->detach($this->spiffyApplication->getServiceManager()->get('SendResponseListener'));
return $this->spiffyApplication;
}
示例6: bootstrap
public function bootstrap()
{
// mark the MVC doesn't use console
Console::overrideIsConsole(false);
// bootstrap application
$application = $this->getServiceManager()->get('Application')->bootstrap();
// set service manager
self::$serviceManager = $application->getServiceManager();
self::$documentManager = $this->getServiceManager()->get('doctrine.odm.documentmanager.default');
self::$dbName = $this->getServiceManager()->get('config')['doctrine']['odm']['connection']['default']['dbname'];
}
示例7: _initialize
public function _initialize()
{
require Configuration::projectDir() . 'init_autoloader.php';
$this->applicationConfig = (require Configuration::projectDir() . $this->config['config']);
if (isset($this->applicationConfig['module_listener_options']['config_cache_enabled'])) {
$this->applicationConfig['module_listener_options']['config_cache_enabled'] = false;
}
Console::overrideIsConsole(false);
//grabServiceFromContainer may need client in beforeClass hooks of modules or helpers
$this->client = new ZF2Connector();
$this->client->setApplicationConfig($this->applicationConfig);
}
示例8: _before
public function _before(\Codeception\TestCase $test)
{
$applicationConfig = (require \Codeception\Configuration::projectDir() . $this->config['config']);
if (isset($applicationConfig['module_listener_options']['config_cache_enabled'])) {
$applicationConfig['module_listener_options']['config_cache_enabled'] = false;
}
Console::overrideIsConsole(false);
$this->application = Application::init($applicationConfig);
$events = $this->application->getEventManager();
$events->detach($this->application->getServiceManager()->get('SendResponseListener'));
$this->client->setApplication($this->application);
}
示例9: testOnBootstrap
public function testOnBootstrap()
{
$event = new MvcEvent();
$application = new Application([], Bootstrap::getServiceManager());
$em = new EventManager();
$application->setEventManager($em);
$event->setApplication($application);
$isConsole = Console::isConsole();
Console::overrideIsConsole(false);
$this->module->onBootstrap($event);
Console::overrideIsConsole($isConsole);
$this->assertCount(1, $em->getListeners(MvcEvent::EVENT_DISPATCH));
$this->assertCount(1, $em->getListeners(MvcEvent::EVENT_RENDER));
}
示例10: testApplicationClassAndTestRestoredConsoleFlag
public function testApplicationClassAndTestRestoredConsoleFlag()
{
$this->assertTrue(Console::isConsole(), '1. Console::isConsole returned false in initial test');
$this->getApplication();
$this->assertFalse(Console::isConsole(), '2. Console::isConsole returned true after retrieving application');
$this->tearDown();
$this->assertTrue(Console::isConsole(), '3. Console::isConsole returned false after tearDown');
Console::overrideIsConsole(false);
parent::setUp();
$this->assertFalse(Console::isConsole(), '4. Console::isConsole returned true after parent::setUp');
$this->getApplication();
$this->assertFalse(Console::isConsole(), '5. Console::isConsole returned true after retrieving application');
parent::tearDown();
$this->assertFalse(Console::isConsole(), '6. Console.isConsole returned true after parent::tearDown');
}
示例11: createServer
public function createServer($name = 'default')
{
Console::overrideIsConsole(false);
$configuration = $this->configuration;
$smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array();
$serviceManager = new ServiceManager(new ServiceManagerConfig($smConfig));
$serviceManager->setService('ApplicationConfig', $configuration);
$serviceManager->get('ModuleManager')->loadModules();
$application = new Application($configuration, $serviceManager);
$application->setServerOptions($this->options->getServer($name));
$allow = $serviceManager->getAllowOverride();
$serviceManager->setAllowOverride(true);
$serviceManager->setService('application', $application);
$serviceManager->setAllowOverride($allow);
return $application->bootstrap();
}
示例12: setUp
public function setUp()
{
// Used by \KJSencha\Service\ApiFactory::createService
\Zend\Console\Console::overrideIsConsole(false);
$sl = ServiceManagerFactory::getServiceManager();
/* @var $manager DirectManager */
$manager = $sl->get('kjsencha.direct.manager');
/* @var $apiFactory \KJSencha\Direct\Remoting\Api\Api */
$api = $sl->get('kjsencha.api');
$this->controller = new DirectController($manager, $api);
$this->request = new Request();
$this->routeMatch = new RouteMatch(array('controller' => 'kjsencha_direct'));
$this->event = new MvcEvent();
$this->event->setRouteMatch($this->routeMatch);
$this->controller->setEvent($this->event);
}
示例13: testClosureThisIsControllerInstance
/**
* @requires PHP 5.4
*/
public function testClosureThisIsControllerInstance()
{
Console::overrideIsConsole(false);
$app = App::init();
$test = $this;
$appRequest = new Request();
$appRequest->setUri('http://localhost/test/blah');
$app->getMvcEvent()->setRequest($appRequest);
$app->route('/test/:param1', function () use($test) {
$test->assertInstanceOf('ZeffMu\\ClosureController', $this);
return 'test';
});
// overriding send response listener
$app->getEventManager()->attach(MvcEvent::EVENT_FINISH, function (EventInterface $e) {
$e->stopPropagation();
}, 1000);
$app->run();
}
示例14: testApplicationClassAndTestRestoredConsoleFlag
public function testApplicationClassAndTestRestoredConsoleFlag()
{
$this->assertTrue(Console::isConsole());
$this->getApplication();
$this->assertFalse(Console::isConsole());
$this->tearDown();
$this->assertTrue(Console::isConsole());
Console::overrideIsConsole(false);
parent::setUp();
$this->assertFalse(Console::isConsole());
$this->getApplication();
$this->assertFalse(Console::isConsole());
parent::tearDown();
$this->assertFalse(Console::isConsole());
}
示例15: setUp
public function setUp()
{
Console::overrideIsConsole(false);
parent::setUp();
$this->request = new Request();
$this->request->setHeaders(new Headers());
$this->routeMatch = new RouteMatch(array('controller' => $this->controllerName));
$this->event = $this->getApplication()->getMvcEvent();
$this->event->setRequest($this->request);
$this->event->setRouteMatch($this->routeMatch);
$this->event->getRouter()->setRequestUri(new HttpUri('http://localhost'));
if (null === $this->controller) {
if (null === $this->controllerName) {
throw new PHPUnit_Framework_Exception('No controller name was specified in the test');
}
$this->controller = $this->getServiceManager()->get('ControllerLoader')->get($this->controllerName);
}
$this->controller->setEvent($this->event);
}