本文整理汇总了PHP中Piwik\Tests\Framework\Fixture类的典型用法代码示例。如果您正苦于以下问题:PHP Fixture类的具体用法?PHP Fixture怎么用?PHP Fixture使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fixture类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getApiForTesting
public function getApiForTesting()
{
// we will test all segments from all plugins
Fixture::loadAllPlugins();
$apiToCall = array('VisitsSummary.get', 'CustomVariables.getCustomVariables');
return array(array($apiToCall, array('idSite' => 'all', 'date' => self::$fixture->dateTime, 'periods' => array('day', 'week'), 'setDateLastN' => true, 'segment' => $this->getSegmentToTest())));
}
示例2: setUp
public function setUp()
{
// add one site
Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #0", $siteUrl = "http://whatever.com/");
// add two goals
$goals = API::getInstance();
$goals->addGoal($this->idSite, 'all', 'url', 'http', 'contains', false, 5);
$goals->addGoal($this->idSite, 'all', 'url', 'thing2', 'contains');
$start = Date::factory($this->date);
$dates = array();
for ($day = 0; $day != 31; ++$day) {
$dates[] = $start->addDay($day);
}
$t = BenchmarkTestCase::getLocalTracker($this->idSite);
$actionNum = 0;
foreach ($dates as $date) {
for ($visitNum = 0; $visitNum != 1000; ++$visitNum) {
if ($visitNum % 2 == 0) {
$url = "http://whatever.com/{$actionNum}/0/1/2/3/4/5/6/7/8/9";
$referrerUrl = "http://google.com/?q={$actionNum}";
} else {
$url = "http://whatever.com/thing2/{$actionNum}/0/1/2/3/4/5/6/7/8/9";
$referrerUrl = "http://";
}
$title = "A page title / {$actionNum} / 0 / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8 /9";
$t->setNewVisitorId();
$t->setForceVisitDateTime($date);
$t->setUrl($url);
$t->setUrlReferrer($referrerUrl);
Fixture::checkResponse($t->doTrackPageView($title));
++$actionNum;
}
}
}
示例3: setUp
public function setUp()
{
parent::setUp();
$this->idSite = Fixture::createWebsite('2012-01-01 00:00:00');
$this->formatter = new SegmentFormatter(new SegmentList());
Translate::loadAllTranslations();
}
示例4: testUpdateWorksAfterPiwikIsAlreadyUpToDate
public function testUpdateWorksAfterPiwikIsAlreadyUpToDate()
{
$result = Fixture::updateDatabase($force = true);
if ($result === false) {
throw new \Exception("Failed to force update (nothing to update).");
}
}
示例5: test_filterDataTable_MatchesExactlyIntegration
public function test_filterDataTable_MatchesExactlyIntegration()
{
$date = Date::today()->addHour(10);
$t = Fixture::getTracker($this->idSite, $date->getDatetime(), $defaultInit = true);
$t->setUrlReferrer('http://www.google.com.vn/url?sa=t&rct=j&q=%3C%3E%26%5C%22the%20pdo%20extension%20is%20required%20for%20this%20adapter%20but%20the%20extension%20is%20not%20loaded&source=web&cd=4&ved=0FjAD&url=http%3A%2F%2Fforum.piwik.org%2Fread.php%3F2%2C1011&ei=y-HHAQ&usg=AFQjCN2-nt5_GgDeg&cad=rja');
$t->setUrl('http://example.org/%C3%A9%C3%A9%C3%A9%22%27...%20%3Cthis%20is%20cool%3E!');
$t->setGenerationTime(523);
$t->doTrackPageView('incredible title! <>,;');
$t->setForceVisitDateTime($date->addHour(0.1)->getDatetime());
$t->setUrl('http://example.org/dir/file.php?foo=bar&foo2=bar');
$t->setGenerationTime(123);
$t->doTrackPageView('incredible title! <>,;');
$t->setForceVisitDateTime($date->addHour(0.2)->getDatetime());
$t->setUrl('http://example.org/dir/file/xyz.php?foo=bar&foo2=bar');
$t->setGenerationTime(231);
$t->doTrackPageView('incredible title! <>,;');
$t->setForceVisitDateTime($date->addHour(0.2)->getDatetime());
$t->setUrl('http://example.org/what-is-piwik');
$t->setGenerationTime(231);
$t->doTrackPageView('incredible title! <>,;');
$t->setForceVisitDateTime($date->addHour(0.3)->getDatetime());
$t->setUrl('http://example.org/dir/file.php?foo=bar&foo2=bar');
$t->setGenerationTime(147);
$t->doTrackPageView('incredible title! <>,;');
// for some reasons @dataProvider results in an "Mysql::getProfiler() undefined method" error
$assertions = array(array('nb_hits', 'what-is-piwik', 1), array('nb_hits', '/what-is-piwik', null), array('nb_hits', 'foo', 3), array('nb_visits', 'foo', 2), array('nb_hits', 'i', 5), array('nb_hits', 'foo2=bar', 3), array('nb_hits', '/', 3), array('nb_hits', 'foo=bar&foo2=bar', 3), array('nb_hits', 'php?foo=bar&foo2=bar', 3), array('nb_hits', 'file.php?foo=bar&foo2=bar', 2), array('nb_hits', 'dir/file.php?foo=bar&foo2=bar', 2), array('nb_hits', 'dir', 3), array('avg_time_generation', 'dir/file.php?foo=bar&foo2=bar', 0.135), array('bounce_rate', 'php?foo=bar', 0));
foreach ($assertions as $assert) {
$alert = array('report' => 'Actions_getPageUrls', 'metric' => $assert[0], 'period' => 'day', 'report_condition' => 'contains', 'report_matched' => Common::sanitizeInputValue($assert[1]));
$value = $this->processor->getValueForAlertInPast($alert, $this->idSite, 0);
$this->assertEquals($assert[2], $value, $assert[0] . ':' . $assert[1] . ' should return value ' . $assert[2] . ' but returns ' . $value);
}
}
示例6: setUp
public function setUp()
{
// add one thousand sites
$allIdSites = array();
for ($i = 0; $i < 1000; ++$i) {
$allIdSites[] = Fixture::createWebsite($this->date, $ecommerce = 1, $siteName = "Site #{$i}");
}
$urls = array();
for ($i = 0; $i != 3; ++$i) {
$url = "http://whatever.com/" . ($i - 1) . "/" . ($i + 1);
$title = "page view " . ($i - 1) . " / " . ($i + 1);
$urls[$url] = $title;
}
$visitTimes = array();
$date = Date::factory($this->date);
for ($i = 0; $i != 4; ++$i) {
$visitTimes[] = $date->addHour($i)->getDatetime();
}
// add 12000 visits (3 visitors with 4 visits each for each site) w/ 3 pageviews each on one day
foreach ($visitTimes as $visitTime) {
foreach ($allIdSites as $idSite) {
for ($visitor = 0; $visitor != 3; ++$visitor) {
$t = BenchmarkTestCase::getLocalTracker($idSite);
$ip = "157.5.6." . ($visitor + 1);
$t->setIp($ip);
$t->setNewVisitorId();
$t->setForceVisitDateTime($visitTime);
foreach ($urls as $url => $title) {
$t->setUrl($url);
$t->doTrackPageView($title);
}
}
}
}
}
示例7: 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);
}
示例8: setUp
public function setUp()
{
parent::setUp();
FakeAccess::$superUser = true;
$idSite = Fixture::createWebsite('2014-01-01 00:00:00');
$this->builder = $this->makeBuilder(array('method' => 'MultiSites_getAll', 'idSite' => $idSite));
}
示例9: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
FakeAccess::$superUser = true;
Fixture::createWebsite('2015-01-01 00:00:00');
}
示例10: setUpBeforeClass
public static function setUpBeforeClass()
{
parent::setUpBeforeClass();
Fixture::createWebsite('2012-01-01 00:00:00');
Fixture::createWebsite('2012-01-01 00:00:00');
Fixture::createWebsite('2012-01-01 00:00:00');
}
示例11: setUp
public function setUp()
{
parent::setUp();
if (!Fixture::siteCreated(1)) {
Fixture::createWebsite('2014-01-01 00:00:00');
}
}
示例12: setUp
public function setUp()
{
parent::setUp();
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createWebsite('2014-01-01 00:00:00');
Cache::deleteTrackerCache();
$_SERVER['HTTP_USER_AGENT'] = '';
}
示例13: setUp
public function setUp()
{
parent::setUp();
for ($i = 1; $i <= $this->numSitesToCreate; $i++) {
Fixture::createWebsite('2012-12-12 00:00:00', $ecommerce = 0, 'Site ' . $i);
}
$this->dashboard = $this->getMockBuilder('Piwik\\Plugins\\MultiSites\\Dashboard')->setMethods(null)->disableOriginalConstructor()->getMock();
}
示例14: setUp
public function setUp()
{
parent::setUp();
if (!Fixture::siteCreated($this->idSite)) {
Fixture::createWebsite('2014-01-01 00:00:00');
}
$this->settings = new SystemSettings();
}
示例15: setUp
public function setUp()
{
parent::setUp();
$this->tracker = new TestIntegrationTracker();
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createWebsite('2014-01-01 00:00:00');
$this->injectRawDataToBulk($this->getDummyRequest());
}