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


PHP Application::getService方法代码示例

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


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

示例1: testRouter

 /**
  * Test route matches against various URIs
  */
 public function testRouter()
 {
     $router = \Library\Application::getService('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:patrickpreuss,项目名称:Braintacle,代码行数:37,代码来源:RouterTest.php

示例2: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     // GroupInfo initialization depends on Config table
     $config = \Library\Application::getService('Database\\Table\\Config');
     $config->setSchema();
     parent::setUpBeforeClass();
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:7,代码来源:GroupInfoTest.php

示例3: testHelperInterface

 /**
  * Test if the helper is properly registered with the service manager
  */
 public function testHelperInterface()
 {
     // Test if the helper is registered with the application's service manager
     $this->assertTrue(\Library\Application::getService('ViewHelperManager')->has($this->_getHelperName()));
     // Get helper instance through service manager and test for required interface
     $this->assertInstanceOf('Zend\\View\\Helper\\HelperInterface', $this->_getHelper());
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:10,代码来源:AbstractTest.php

示例4: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     // These tables must exist before the view can be created
     \Library\Application::getService('Database\\Table\\ClientsAndGroups')->setSchema();
     \Library\Application::getService('Database\\Table\\ClientSystemInfo')->setSchema();
     parent::setUpBeforeClass();
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:7,代码来源:ClientsTest.php

示例5: 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

示例6: testFind

 /**
  * @dataProvider findProvider
  */
 public function testFind($criteria, $order, $direction, $clearBlacklist, $expectedOrder, $expectedResult)
 {
     if ($clearBlacklist) {
         \Library\Application::getService('Database\\Table\\DuplicateMacAddresses')->delete(true);
         \Library\Application::getService('Database\\Table\\DuplicateSerials')->delete(true);
         \Library\Application::getService('Database\\Table\\DuplicateAssetTags')->delete(true);
     }
     $ordercolumns = array('Id' => 'clients.id', 'Name' => 'clients.name', 'NetworkInterface.MacAddress' => 'networkinterface_macaddr');
     $sql = new \Zend\Db\Sql\Sql(\Library\Application::getService('Db'), 'clients');
     $select = $sql->select()->columns(array('id', 'name', 'lastcome', 'ssn', 'assettag'))->order(array($ordercolumns[$order] => $direction));
     $clientManager = $this->getMockBuilder('Model\\Client\\ClientManager')->disableOriginalConstructor()->getMock();
     $clientManager->method('getClients')->with(array('Id', 'Name', 'LastContactDate', 'Serial', 'AssetTag'), $order, $direction, null, null, null, null, false, false, false)->willReturn($select);
     $clients = $this->getMockBuilder('Database\\Table\\Clients')->disableOriginalConstructor()->setMethods(array('getSql', 'selectWith'))->getMock();
     $clients->method('getSql')->willReturn($sql);
     $clients->method('selectWith')->with($this->callback(function ($select) use($expectedOrder) {
         return $select->getRawState($select::ORDER) == $expectedOrder;
     }))->willReturnCallback(function ($select) use($sql) {
         // Build simple result set to bypass hydrator
         $resultSet = new \Zend\Db\ResultSet\ResultSet();
         $resultSet->initialize($sql->prepareStatementForSqlObject($select)->execute());
         return $resultSet;
     });
     $duplicates = $this->_getModel(array('Database\\Table\\Clients' => $clients, 'Model\\Client\\ClientManager' => $clientManager));
     $resultSet = $duplicates->find($criteria, $order, $direction);
     $this->assertInstanceOf('Zend\\Db\\ResultSet\\AbstractResultSet', $resultSet);
     $this->assertEquals($expectedResult, $resultSet->toArray());
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:30,代码来源:DuplicatesManagerTest.php

示例7: testLoggerService

 /**
  * Test service
  */
 public function testLoggerService()
 {
     $logger = \Library\Application::getService('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:patrickpreuss,项目名称:Braintacle,代码行数:11,代码来源:LoggerServiceFactoryTest.php

示例8: getConnection

 public function getConnection()
 {
     if (!$this->_db) {
         $pdo = \Library\Application::getService('Db')->getDriver()->getConnection()->getResource();
         $this->_db = $this->createDefaultDBConnection($pdo, ':memory:');
     }
     return $this->_db;
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:8,代码来源:AbstractTableTest.php

示例9: _createView

 /**
  * Create a new view renderer
  *
  * @return \Zend\View\Renderer\PhpRenderer
  */
 protected function _createView()
 {
     // Clone helper plugin manager to prevent state changes leaking into other tests
     $plugins = clone \Library\Application::getService('ViewHelperManager');
     $view = new \Zend\View\Renderer\PhpRenderer();
     $view->setHelperPluginManager($plugins);
     return $view;
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:13,代码来源:AbstractFormTest.php

示例10: testService

 public function testService()
 {
     $serviceManager = \Library\Application::getService('serviceManager');
     // 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:patrickpreuss,项目名称:Braintacle,代码行数:10,代码来源:NowTest.php

示例11: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // Add columns to CustomFields table
     static::$_customFields = \Library\Application::getService('Database\\Nada')->getTable('accountinfo');
     static::$_customFields->addColumn('col_text', \Nada::DATATYPE_VARCHAR, 255);
     static::$_customFields->addColumn('col_clob', \Nada::DATATYPE_CLOB);
     static::$_customFields->addColumn('col_integer', \Nada::DATATYPE_INTEGER, 32);
     static::$_customFields->addColumn('col_float', \Nada::DATATYPE_FLOAT);
     static::$_customFields->addColumn('col_date', \Nada::DATATYPE_DATE);
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:11,代码来源:ClientManagerTest.php

示例12: testDeleteItems

 public function testDeleteItems()
 {
     $model = $this->_getModel();
     $model->deleteItems(1);
     $dataSet = new \PHPUnit_Extensions_Database_DataSet_QueryDataSet($this->getConnection());
     foreach (static::$_tables as $table) {
         if ($table == 'ClientsAndGroups' or $table == 'DuplicateMacAddresses' or $table == 'SoftwareDefinitions') {
             continue;
         }
         $table = \Library\Application::getService("Database\\Table\\{$table}")->table;
         $dataSet->addTable($table, "SELECT hardware_id FROM {$table}");
     }
     $this->assertDataSetsEqual($this->_loadDataSet('DeleteItems'), $dataSet);
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:14,代码来源:ItemManagerTest.php

示例13: testFormElementHelperIntegration

    public function testFormElementHelperIntegration()
    {
        $element = new \Zend\Form\Element\Select('test');
        $element->setAttribute('type', 'select_untranslated')->setValueOptions(array('Yes<b>', 'No'));
        $expected = <<<EOT
<select name="test"><option value="0">Yes&lt;b&gt;</option>
<option value="1">No</option></select>
EOT;
        $plugins = clone \Library\Application::getService('ViewHelperManager');
        $view = new \Zend\View\Renderer\PhpRenderer();
        $view->setHelperPluginManager($plugins);
        $helper = $plugins->get('formElement');
        $helper->setView($view);
        $this->assertEquals($expected, $helper($element));
    }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:15,代码来源:FormSelectUntranslatedTest.php

示例14: testInvokeWithConsoleForm

 public function testInvokeWithConsoleForm()
 {
     $plugin = $this->_getPlugin(false);
     // Set up \Console\Form\Form using default renderer
     $form = $this->getMock('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
     $renderer = \Library\Application::getService('ViewRenderer');
     $output = $renderer->render($viewModel);
     $this->assertEquals('\\Console\\Form\\Form default renderer', $output);
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:16,代码来源:PrintFormTest.php

示例15: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     static::$_nada = \Library\Application::getService('Database\\Nada');
     // Add columns to CustomFields table, matching config from fixture
     $customFields = \Library\Application::getService('Database\\Table\\CustomFields');
     $customFields->setSchema();
     $fields = static::$_nada->getTable('accountinfo');
     $fields->addColumn('fields_3', \Nada::DATATYPE_VARCHAR, 255);
     $fields->addColumn('fields_4', \Nada::DATATYPE_INTEGER, 32);
     $fields->addColumn('fields_5', \Nada::DATATYPE_FLOAT);
     $fields->addColumn('fields_6', \Nada::DATATYPE_CLOB);
     $fields->addColumn('fields_7', \Nada::DATATYPE_DATE);
     $fields->addColumn('fields_8', \Nada::DATATYPE_VARCHAR, 255);
     $fields->addColumn('fields_9', \Nada::DATATYPE_VARCHAR, 255);
 }
开发者ID:patrickpreuss,项目名称:Braintacle,代码行数:16,代码来源:CustomFieldConfigTest.php


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