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


PHP Fixture::getTokenAuth方法代码示例

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


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

示例1: testWebArchiving

 public function testWebArchiving()
 {
     if (self::isMysqli() && self::isTravisCI()) {
         $this->markTestSkipped('Skipping on Mysqli as it randomly fails.');
     }
     $host = Fixture::getRootUrl();
     $token = Fixture::getTokenAuth();
     $urlTmp = Option::get('piwikUrl');
     Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php');
     $url = $host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token;
     $output = Http::sendHttpRequest($url, 600);
     // ignore random build issues
     if (empty($output) || strpos($output, \Piwik\CronArchive::NO_ERROR) === false) {
         $message = "This test has failed. Because it sometimes randomly fails, we skip the test, and ignore this failure.\n";
         $message .= "If you see this message often, or in every build, please investigate as this should only be a random and rare occurence!\n";
         $message .= "\n\narchive web failed: " . $output . "\n\nurl used: {$url}";
         $this->markTestSkipped($message);
     }
     if (!empty($urlTmp)) {
         Option::set('piwikUrl', $urlTmp);
     } else {
         Option::delete('piwikUrl');
     }
     $this->assertContains('Starting Piwik reports archiving...', $output);
     $this->assertContains('Archived website id = 1', $output);
     $this->assertContains('Done archiving!', $output);
     $this->compareArchivePhpOutputAgainstExpected($output);
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:28,代码来源:ArchiveWebTest.php

示例2: buildTracker

 private function buildTracker()
 {
     $t = Fixture::getTracker($this->idSite, Date::factory('2014-01-05 00:01:01')->getDatetime());
     $t->setDebugStringAppend('debug=1');
     $t->setTokenAuth(Fixture::getTokenAuth());
     $t->setUrl('http://example.org/index1.htm');
     return $t;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:8,代码来源:TrackerLoggingTest.php

示例3: setUp

 public function setUp()
 {
     parent::setUp();
     $this->cliMulti = new CliMulti();
     $this->authToken = Fixture::getTokenAuth();
     $this->urls = array('getAnswerToLife' => $this->completeUrl('?module=API&method=ExampleAPI.getAnswerToLife&format=JSON'), 'getPiwikVersion' => $this->completeUrl('?module=API&method=API.getPiwikVersion&format=JSON'));
     $this->responses = array('getAnswerToLife' => '{"value":42}', 'getPiwikVersion' => '{"value":"' . Version::VERSION . '"}');
     \Piwik\Common::$isCliMode = true;
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:9,代码来源:CliMultiTest.php

示例4: test_getBulkRequest_IsAbleToHandleManyDifferentRequests

 public function test_getBulkRequest_IsAbleToHandleManyDifferentRequests()
 {
     $token = Fixture::getTokenAuth();
     $urls = array("method%3dVisitsSummary.get%26idSite%3d1%26date%3d2015-01-26%26period%3dday", "method%3dVisitsSummary.get%26token_auth%3d{$token}%26idSite%3d1%26date%3d2015-01-26%26period%3dday", "method%3dVisitsSummary.get%26idSite%3d1%26date%3d2015-01-26%26period%3dday", "method%3dVisitsSummary.get%26idSite%3d1%26token_auth%3danonymous%26date%3d2015-01-26%26period%3dday");
     $response = $this->api->getBulkRequest($urls);
     $this->assertResponseIsPermissionError($response[0]);
     $this->assertResponseIsSuccess($response[1]);
     $this->assertSame(0, $response[1]['nb_visits']);
     $this->assertResponseIsPermissionError($response[2]);
     $this->assertResponseIsPermissionError($response[3]);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:11,代码来源:APITest.php

示例5: getLocalTracker

 /**
  * Creates a tracking object that invokes the tracker directly (w/o going through HTTP).
  */
 public static function getLocalTracker($idSite)
 {
     require_once PIWIK_INCLUDE_PATH . '/tests/LocalTracker.php';
     $t = new \Piwik_LocalTracker($idSite, Fixture::getTrackerUrl());
     $t->setUserAgent("Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 (.NET CLR 3.5.30729)");
     $t->setBrowserLanguage('fr');
     $t->setLocalTime('12:34:06');
     $t->setResolution(1024, 768);
     $t->setBrowserHasCookies(true);
     $t->setPlugins($flash = true, $java = true, $director = false);
     $t->setTokenAuth(Fixture::getTokenAuth());
     return $t;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:16,代码来源:BenchmarkTestCase.php

示例6: test_LogImporter_RetriesWhenServerFails

 public function test_LogImporter_RetriesWhenServerFails()
 {
     $this->simulateTrackerFailure();
     $logFile = PIWIK_INCLUDE_PATH . '/tests/resources/access-logs/fake_logs_enable_all.log';
     $options = array('--idsite' => self::$fixture->idSite, '--token-auth' => Fixture::getTokenAuth(), '--retry-max-attempts' => 5, '--retry-delay' => 1);
     $output = Fixture::executeLogImporter($logFile, $options, $allowFailure = true);
     $output = implode("\n", $output);
     for ($i = 2; $i != 6; ++$i) {
         $this->assertContains("Retrying request, attempt number {$i}", $output);
     }
     $this->assertNotContains("Retrying request, attempt number 6", $output);
     $this->assertContains("Max number of attempts reached, server is unreachable!", $output);
 }
开发者ID:ahdinosaur,项目名称:analytics.dinosaur.is,代码行数:13,代码来源:ImportLogsTest.php

示例7: test_WebArchiving

 public function test_WebArchiving()
 {
     if (self::isMysqli() && self::isTravisCI()) {
         $this->markTestSkipped('Skipping on Mysqli as it randomly fails.');
     }
     $host = Fixture::getRootUrl();
     $token = Fixture::getTokenAuth();
     $urlTmp = Option::get('piwikUrl');
     Option::set('piwikUrl', $host . 'tests/PHPUnit/proxy/index.php');
     $url = $host . 'tests/PHPUnit/proxy/archive.php?token_auth=' . $token;
     $output = Http::sendHttpRequest($url, 600);
     // ignore random build issues
     if (empty($output) || strpos($output, \Piwik\CronArchive::NO_ERROR) === false) {
         $this->fail("archive web failed: " . $output . "\n\nurl used: {$url}");
     }
     if (!empty($urlTmp)) {
         Option::set('piwikUrl', $urlTmp);
     } else {
         Option::delete('piwikUrl');
     }
     $this->assertWebArchivingDone($output);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:22,代码来源:ArchiveWebTest.php

示例8: assertRememberedArchivedReportsThatShouldBeInvalidated

 private function assertRememberedArchivedReportsThatShouldBeInvalidated($idsite, $requestDate, $expectedRemeberedArchivedReports)
 {
     /** @var Visit $visit */
     list($visit) = $this->prepareVisitWithRequest(array('idsite' => $idsite, 'rec' => 1, 'cip' => '156.146.156.146', 'token_auth' => Fixture::getTokenAuth()), $requestDate);
     $visit->handle();
     $archive = StaticContainer::get('Piwik\\Archive\\ArchiveInvalidator');
     $remembered = $archive->getRememberedArchivedReportsThatShouldBeInvalidated();
     $this->assertSame($expectedRemeberedArchivedReports, $remembered);
 }
开发者ID:Michael2008S,项目名称:piwik,代码行数:9,代码来源:VisitTest.php

示例9: getTracker

 private function getTracker($hoursOffset = 0)
 {
     $hour = 10;
     if ($hoursOffset) {
         $hour += $hoursOffset;
     }
     $date = sprintf('%s %d:20:01', $this->date, $hour);
     $tracker = Fixture::getTracker(1, $date, true, true);
     $tracker->setTokenAuth(Fixture::getTokenAuth());
     return $tracker;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:11,代码来源:VisitsSummaryTest.php

示例10: test_main_shouldReportInvalidIndices_IfInvalidRequestsIncluded_AndRequestAuthenticated

 public function test_main_shouldReportInvalidIndices_IfInvalidRequestsIncluded_AndRequestAuthenticated()
 {
     $this->injectRawDataToBulk($this->getDummyRequest($token = Fixture::getTokenAuth(), $idSite = array(1, -100)));
     $handler = $this->getHandler();
     $handler->setResponse(new Response());
     $response = $this->tracker->main($handler, $this->getEmptyRequestSet());
     $this->assertEquals('{"status":"success","tracked":1,"invalid":1,"invalid_indices":[1]}', $response);
 }
开发者ID:cemo,项目名称:piwik,代码行数:8,代码来源:TrackerTest.php

示例11: runAnyApiTest

 /**
  * While {@link runApiTests()} lets you run test for many API methods at once this one tests only one specific
  * API method and it goes via HTTP. While the other method lets you test only some methods starting with 'get'
  * this one lets you actually test any API method.
  */
 protected function runAnyApiTest($apiMethod, $apiId, $requestParams, $options = array())
 {
     $requestParams['module'] = 'API';
     $requestParams['format'] = 'XML';
     $requestParams['method'] = $apiMethod;
     $apiId = $apiMethod . '_' . $apiId . '.xml';
     $testName = 'test_' . static::getOutputPrefix();
     list($processedFilePath, $expectedFilePath) = $this->getProcessedAndExpectedPaths($testName, $apiId, $format = null, $compareAgainst = false);
     if (!array_key_exists('token_auth', $requestParams)) {
         $requestParams['token_auth'] = Fixture::getTokenAuth();
     }
     $response = $this->getResponseFromHttpAPI($requestParams);
     $processedResponse = new Response($response, $options, $requestParams);
     if (empty($compareAgainst)) {
         $processedResponse->save($processedFilePath);
     }
     try {
         $expectedResponse = Response::loadFromFile($expectedFilePath, $options, $requestParams);
     } catch (Exception $ex) {
         $this->handleMissingExpectedFile($expectedFilePath, $processedResponse);
         return;
     }
     try {
         $errorMessage = get_class($this) . ": Differences with expected in '{$processedFilePath}'";
         Response::assertEquals($expectedResponse, $processedResponse, $errorMessage);
     } catch (Exception $ex) {
         $this->comparisonFailures[] = $ex;
     }
     $this->printApiTestFailures();
 }
开发者ID:JoeHorn,项目名称:piwik,代码行数:35,代码来源:SystemTestCase.php

示例12: buildRequestSetWithIdSite

 private function buildRequestSetWithIdSite($numRequests, $additionalParams = array())
 {
     $req = new RequestSet();
     $requests = array();
     for ($index = 1; $index <= $numRequests; $index++) {
         $requests[] = array_merge(array('idsite' => 1, 'cip' => '192.168.33.11', 'token_auth' => Fixture::getTokenAuth()), $additionalParams);
     }
     $req->setRequests($requests);
     $req->rememberEnvironment();
     return $req;
 }
开发者ID:ruchitrami,项目名称:plugin-QueuedTracking,代码行数:11,代码来源:ManagerTest.php

示例13: getTracker

 private function getTracker()
 {
     $tracker = Fixture::getTracker(1, self::FIRST_VISIT_TIME, $defaultInit = true, $useLocalTracker = true);
     $tracker->setTokenAuth(Fixture::getTokenAuth());
     // properties that cannot be changed on next action
     $tracker->setUserAgent(self::TEST_USER_AGENT);
     $tracker->setBrowserLanguage(self::TEST_BROWSER_LANGUAGE);
     // properties that can be changed on next action
     $tracker->setCountry(self::TEST_COUNTRY);
     $tracker->setRegion(self::TEST_REGION);
     return $tracker;
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:12,代码来源:PingRequestTest.php

示例14: setDummyRequests

 private function setDummyRequests($useTokenAuth = true)
 {
     if ($useTokenAuth) {
         $useTokenAuth = Fixture::getTokenAuth();
     }
     $this->requestSet->setRequests(array(array('idsite' => 1, 'url' => 'http://localhost/foo?bar', 'cip' => '192.168.33.11', 'token_auth' => $useTokenAuth), array('idsite' => 1, 'url' => 'http://localhost', 'cip' => '192.168.33.11', 'token_auth' => $useTokenAuth)));
 }
开发者ID:ruchitrami,项目名称:plugin-QueuedTracking,代码行数:7,代码来源:HandlerTest.php

示例15: test_authenticateSuperUserOrAdmin_ShouldAlwaysWorkForSuperUser

 public function test_authenticateSuperUserOrAdmin_ShouldAlwaysWorkForSuperUser()
 {
     Fixture::createSuperUser(false);
     $token = Fixture::getTokenAuth();
     $isAuthenticated = Request::authenticateSuperUserOrAdmin($token, 1);
     $this->assertTrue($isAuthenticated);
     $isAuthenticated = Request::authenticateSuperUserOrAdmin($token, 2);
     $this->assertTrue($isAuthenticated);
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:9,代码来源:RequestTest.php


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