当前位置: 首页>>代码示例>>PHP>>正文


PHP Application::init方法代码示例

本文整理汇总了PHP中Library\Application::init方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::init方法的具体用法?PHP Application::init怎么用?PHP Application::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Library\Application的用法示例。


在下文中一共展示了Application::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testMessageTranslated

 public function testMessageTranslated()
 {
     $validator = new LogLevel();
     $validator->setTranslator(\Library\Application::init('Library', true)->getServiceManager()->get('MvcTranslator'));
     $validator->isValid('Error');
     $this->assertEquals(array(LogLevel::LOG_LEVEL => "'Error' ist kein gültiger Loglevel"), $validator->getMessages());
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:7,代码来源:LogLevelTest.php

示例2: testRouter

 /**
  * Test route matches against various URIs
  */
 public function testRouter()
 {
     $application = \Library\Application::init('Console', true);
     $router = $application->getServiceManager()->get('HttpRouter');
     $request = new \Zend\Http\Request();
     $matchDefaultDefault = array('controller' => 'client', 'action' => 'index');
     $matchControllerDefault = array('controller' => 'controllername', 'action' => 'index');
     $matchControllerAction = array('controller' => 'controllername', 'action' => 'actionname');
     $request->setUri('/');
     $this->assertEquals($matchDefaultDefault, $router->match($request)->getParams());
     $request->setUri('/controllername');
     $this->assertEquals($matchControllerDefault, $router->match($request)->getParams());
     $request->setUri('/controllername/');
     $this->assertEquals($matchControllerDefault, $router->match($request)->getParams());
     $request->setUri('/controllername/actionname');
     $this->assertEquals($matchControllerAction, $router->match($request)->getParams());
     $request->setUri('/controllername/actionname/');
     $this->assertEquals($matchControllerAction, $router->match($request)->getParams());
     $request->setUri('/controllername/actionname/invalid');
     $this->assertNull($router->match($request));
     $request->setUri('/console');
     $this->assertEquals($matchDefaultDefault, $router->match($request)->getParams());
     $request->setUri('/console/');
     $this->assertEquals($matchDefaultDefault, $router->match($request)->getParams());
     $request->setUri('/console/controllername');
     $this->assertEquals($matchControllerDefault, $router->match($request)->getParams());
     $request->setUri('/console/controllername/');
     $this->assertEquals($matchControllerDefault, $router->match($request)->getParams());
     $request->setUri('/console/controllername/actionname');
     $this->assertEquals($matchControllerAction, $router->match($request)->getParams());
     $request->setUri('/console/controllername/actionname/');
     $this->assertEquals($matchControllerAction, $router->match($request)->getParams());
     $request->setUri('/console/controllername/actionname/invalid');
     $this->assertNull($router->match($request));
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:38,代码来源:RouterTest.php

示例3: testMissingTranslationDoesNotTriggerNoticeWhenDisabled

 /**
  * @dataProvider missingTranslationProvider
  */
 public function testMissingTranslationDoesNotTriggerNoticeWhenDisabled($locale)
 {
     \Locale::setDefault($locale);
     $application = \Library\Application::init('Library', true, array('Library\\UserConfig' => array('debug' => array('report missing translations' => false))));
     $translator = $application->getServiceManager()->get('MvcTranslator');
     $this->assertEquals('this_string_is_not_translated', $translator->translate('this_string_is_not_translated'));
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:10,代码来源:TranslatorTest.php

示例4: _createView

 /**
  * Create a new view renderer
  *
  * @return \Zend\View\Renderer\PhpRenderer
  */
 protected function _createView()
 {
     $application = \Library\Application::init('Console', true);
     $view = new \Zend\View\Renderer\PhpRenderer();
     $view->setHelperPluginManager($application->getServiceManager()->get('ViewHelperManager'));
     return $view;
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:12,代码来源:AbstractFormTest.php

示例5: testMessageTranslated

 public function testMessageTranslated()
 {
     $validator = new ProductKey();
     $validator->setTranslator(\Library\Application::init('Library', true)->getServiceManager()->get('MvcTranslator'));
     $validator->isValid('invalid');
     $this->assertEquals(array(ProductKey::PRODUCT_KEY => "'invalid' ist kein gültiger Lizenzschlüssel"), $validator->getMessages());
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:7,代码来源:ProductKeyTest.php

示例6: testNoTranslatorForEnglishLocale

 public function testNoTranslatorForEnglishLocale()
 {
     // Preserve state
     if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $language = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
     }
     // Repeat application initialization with english locale
     $_SERVER['HTTP_ACCEPT_LANGUAGE'] = 'en_UK';
     \Library\Application::init('Library', false);
     // Invoke translator with untranslatable string - must not trigger notice
     $translator = \Library\Application::getService('MvcTranslator')->getTranslator();
     $message = $translator->translate('this_string_is_not_translated');
     // Reset application state ASAP.
     if (isset($language)) {
         $_SERVER['HTTP_ACCEPT_LANGUAGE'] = $language;
     } else {
         unset($_SERVER['HTTP_ACCEPT_LANGUAGE']);
     }
     \Library\Application::init('Library', false);
     $this->assertEquals('this_string_is_not_translated', $message);
     // No translations should be loaded
     $reflectionObject = new \ReflectionObject($translator);
     $reflectionProperty = $reflectionObject->getProperty('files');
     $reflectionProperty->setAccessible(true);
     $this->assertSame(array(), $reflectionProperty->getValue($translator));
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:26,代码来源:TranslatorTest.php

示例7: testLoggerService

 /**
  * Test service
  */
 public function testLoggerService()
 {
     $application = \Library\Application::init('Library', true);
     $logger = $application->getServiceManager()->get('Library\\Logger');
     $this->assertInstanceOf('\\Zend\\Log\\Logger', $logger);
     // Log a message. The NULL writer should be attached so that no
     // exception should be thrown.
     $logger->debug('test');
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:12,代码来源:LoggerServiceFactoryTest.php

示例8: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $helperClass = static::_getHelperClass();
     $moduleName = substr($helperClass, 0, strpos($helperClass, '\\'));
     $application = \Library\Application::init($moduleName, true);
     static::$_serviceManager = $application->getServiceManager();
     static::$_helperManager = static::$_serviceManager->get('ViewHelperManager');
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:9,代码来源:AbstractTest.php

示例9: setUp

 public function setUp()
 {
     $this->_authService = $this->createMock('Model\\Operator\\AuthenticationService');
     $application = \Library\Application::init('Console', true);
     $serviceManager = $application->getServiceManager();
     $serviceManager->setService('Zend\\Authentication\\AuthenticationService', $this->_authService);
     $this->_view = new \Zend\View\Renderer\PhpRenderer();
     $this->_view->setHelperPluginManager($serviceManager->get('ViewHelperManager'));
     $this->_view->setResolver(new \Zend\View\Resolver\TemplateMapResolver(array('layout' => \Console\Module::getPath('views/layout/layout.php'))));
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:10,代码来源:LayoutTest.php

示例10: testService

 public function testService()
 {
     $application = \Library\Application::init('Library', true);
     $serviceManager = $application->getServiceManager();
     // Service must not be shared so that a different result is returned
     // each time.
     $now1 = $serviceManager->get('Library\\Now');
     sleep(1);
     $now2 = $serviceManager->get('Library\\Now');
     $this->assertGreaterThan($now1->getTimestamp(), $now2->getTimestamp());
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:11,代码来源:NowTest.php

示例11: testDefaultTranslator

 public function testDefaultTranslator()
 {
     $translator = $this->createMock('Zend\\Mvc\\I18n\\Translator');
     $application = \Library\Application::init('Console', true);
     // Run test initializion after application initialization because it
     // would be overwritten otherwise
     \Zend\Validator\AbstractValidator::setDefaultTranslator(null);
     $serviceManager = $application->getServiceManager();
     $serviceManager->setAllowOverride(true);
     $serviceManager->setService('MvcTranslator', $translator);
     // Invoke bootstrap event handler manually. It has already been run
     // during application initialization, but we changed the default
     // translator in the meantime.
     (new \Console\Module())->onBootstrap($application->getMvcEvent());
     $this->assertSame($translator, \Zend\Validator\AbstractValidator::getDefaultTranslator());
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:16,代码来源:LocalizationTest.php

示例12: testInvokeWithConsoleForm

 public function testInvokeWithConsoleForm()
 {
     $plugin = $this->_getPlugin(false);
     // Set up \Console\Form\Form using default renderer
     $form = $this->createMock('Console\\Form\\Form');
     $form->expects($this->once())->method('render')->will($this->returnValue('\\Console\\Form\\Form default renderer'));
     // Evaluate plugin return value
     $viewModel = $plugin($form);
     $this->assertInstanceOf('Zend\\View\\Model\\ViewModel', $viewModel);
     $this->assertEquals('plugin/PrintForm.php', $viewModel->getTemplate());
     $this->assertEquals($form, $viewModel->form);
     // Invoke template and test output
     $application = \Library\Application::init('Console', true);
     $renderer = $application->getServiceManager()->get('ViewRenderer');
     $output = $renderer->render($viewModel);
     $this->assertEquals('\\Console\\Form\\Form default renderer', $output);
 }
开发者ID:hschletz,项目名称:braintacle,代码行数:17,代码来源:PrintFormTest.php

示例13: error_reporting

<?php

/**
 * Bootstrap for unit tests
 *
 * Copyright (C) 2011-2016 Holger Schletz <holger.schletz@web.de>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
error_reporting(-1);
date_default_timezone_set('Europe/Berlin');
\Library\Application::init('Protocol', true);
开发者ID:hschletz,项目名称:braintacle,代码行数:24,代码来源:bootstrap.php

示例14: error_reporting

<?php

/**
 * Bootstrap for unit tests
 *
 * Copyright (C) 2011-2015 Holger Schletz <holger.schletz@web.de>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
error_reporting(-1);
date_default_timezone_set('Europe/Berlin');
require_once __DIR__ . '/../../Library/Application.php';
\Library\Application::init('Protocol', false);
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:25,代码来源:bootstrap.php

示例15: error_reporting

 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
namespace Library;

error_reporting(-1);
date_default_timezone_set('Europe/Berlin');
\Locale::setDefault('de');
/**
 * A minimal stream wrapper to simulate I/O errors
 *
 * No stream methods are implemented except stream_open() (so that a stream can
 * be opened) and stream_eof() (which always returns FALSE to distinct a read
 * error from a normal EOF). Every other method will cause the calling stream
 * function to fail, allowing testing the error handling in the application.
 */
// @codingStandardsIgnoreStart
class StreamWrapperFail
{
    public function stream_open($path, $mode, $options, &$openedPath)
    {
        return true;
    }
    public function stream_eof()
    {
        return false;
    }
}
// @codingStandardsIgnoreEnd
stream_wrapper_register('fail', 'Library\\StreamWrapperFail');
\Library\Application::init('Library', true);
开发者ID:hschletz,项目名称:braintacle,代码行数:30,代码来源:bootstrap.php


注:本文中的Library\Application::init方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。