當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HookRegistry::resetCalledHooks方法代碼示例

本文整理匯總了PHP中HookRegistry::resetCalledHooks方法的典型用法代碼示例。如果您正苦於以下問題:PHP HookRegistry::resetCalledHooks方法的具體用法?PHP HookRegistry::resetCalledHooks怎麽用?PHP HookRegistry::resetCalledHooks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在HookRegistry的用法示例。


在下文中一共展示了HookRegistry::resetCalledHooks方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: tearDown

 /**
  * @see PKPTestCase::tearDown()
  */
 protected function tearDown()
 {
     HookRegistry::resetCalledHooks();
     parent::tearDown();
 }
開發者ID:mosvits,項目名稱:ojs,代碼行數:8,代碼來源:ArticleSearchIndexTest.php

示例2: testGetProtocolNoHttpsVariable

 /**
  * @covers PKPRequest::getProtocol
  */
 public function testGetProtocolNoHttpsVariable()
 {
     $_SERVER = array();
     self::assertEquals('http', $this->request->getProtocol());
     // The hook should have been triggered once.
     self::assertEquals(array(array('Request::getProtocol', array('http'))), HookRegistry::getCalledHooks());
     // Calling getProtocol() twice should return the same
     // result without triggering the hook again.
     HookRegistry::resetCalledHooks();
     self::assertEquals('http', $this->request->getProtocol());
     self::assertEquals(array(), HookRegistry::getCalledHooks());
 }
開發者ID:PublishingWithoutWalls,項目名稱:pkp-lib,代碼行數:15,代碼來源:PKPRequestTest.php

示例3: testRetrieveResultsViaPluginHook

 /**
  * @covers ArticleSearch
  */
 public function testRetrieveResultsViaPluginHook()
 {
     // Diverting a search to the search plugin hook.
     HookRegistry::register('SubmissionSearch::retrieveResults', array($this, 'callbackRetrieveResults'));
     $testCases = array(array(null => 'query'), array('1' => 'author'), array('2' => 'title'), array(null => 'query', 1 => 'author', 2 => 'title'));
     $testFromDate = date('Y-m-d H:i:s', strtotime('2011-03-15 00:00:00'));
     $testToDate = date('Y-m-d H:i:s', strtotime('2012-03-15 18:30:00'));
     $error = '';
     foreach ($testCases as $testCase) {
         // Test a simple search with the simulated callback.
         $journal = new Journal();
         $keywords = $testCase;
         $articleSearch = new ArticleSearch();
         $searchResult = $articleSearch->retrieveResults($journal, $keywords, $error, $testFromDate, $testToDate);
         // Check the parameters passed into the callback.
         $expectedPage = 1;
         $expectedItemsPerPage = 20;
         $expectedTotalResults = 3;
         $expectedError = '';
         $expectedParams = array($journal, $testCase, $testFromDate, $testToDate, $expectedPage, $expectedItemsPerPage, $expectedTotalResults, $expectedError);
         self::assertEquals($expectedParams, $this->_retrieveResultsParams);
         // Test and clear the call history of the hook registry.
         $calledHooks = HookRegistry::getCalledHooks();
         self::assertEquals('SubmissionSearch::retrieveResults', $calledHooks[0][0]);
         HookRegistry::resetCalledHooks(true);
         // Test whether the result from the hook is being returned.
         self::assertInstanceOf('VirtualArrayIterator', $searchResult);
         // Test the total count.
         self::assertEquals(3, $searchResult->getCount());
         // Test the search result.
         $firstResult = $searchResult->next();
         self::assertArrayHasKey('article', $firstResult);
         self::assertEquals(SUBMISSION_SEARCH_TEST_ARTICLE_FROM_PLUGIN, $firstResult['article']->getId());
         self::assertEquals('', $error);
     }
     // Remove the test hook.
     HookRegistry::clear('SubmissionSearch::retrieveResults');
 }
開發者ID:jalperin,項目名稱:ojs,代碼行數:41,代碼來源:ArticleSearchTest.php

示例4: testGetIndexUrl

 /**
  * @covers PKPRouter::getIndexUrl
  */
 public function testGetIndexUrl()
 {
     $this->_setUpMockEnvironment();
     $this->setTestConfiguration('request1', 'classes/core/config', false);
     // no restful URLs
     $_SERVER = array('HOSTNAME' => 'mydomain.org', 'SCRIPT_NAME' => '/base/index.php');
     HookRegistry::resetCalledHooks();
     self::assertEquals('http://mydomain.org/base/index.php', $this->router->getIndexUrl($this->request));
     // Several hooks should have been triggered.
     self::assertEquals(array(array('Request::getServerHost', array('mydomain.org')), array('Request::getProtocol', array('http')), array('Request::getBasePath', array('/base')), array('Request::getBaseUrl', array('http://mydomain.org/base')), array('Router::getIndexUrl', array('http://mydomain.org/base/index.php'))), HookRegistry::getCalledHooks());
     // Calling getIndexUrl() twice should return the same
     // result without triggering the hooks again.
     HookRegistry::resetCalledHooks();
     self::assertEquals('http://mydomain.org/base/index.php', $this->router->getIndexUrl($this->request));
     self::assertEquals(array(), HookRegistry::getCalledHooks());
 }
開發者ID:anorton,項目名稱:pkp-lib,代碼行數:19,代碼來源:PKPRouterTest.inc.php


注:本文中的HookRegistry::resetCalledHooks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。