本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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]);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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)));
}
示例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);
}