Download tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php from Leon4gr45/matomo: direct link, hf CLI and curl.
- Browser
- Download file 3.79 kB
-
https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php
- Command line
-
hf download hf://spaces/Leon4gr45/matomo/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php
-
curl -L -o PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php https://huggingface.co/spaces/Leon4gr45/matomo/resolve/main/tests/PHPUnit/System/PeriodIsRangeDateIsLastNMetadataAndNormalAPITest.php
3.79 kB
| /** | |
| * Matomo - free/libre analytics platform | |
| * | |
| * @link https://matomo.org | |
| * @license https://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later | |
| */ | |
| namespace Piwik\Tests\System; | |
| use Piwik\Date; | |
| use Piwik\Tests\Framework\TestCase\SystemTestCase; | |
| use Piwik\Tests\Fixtures\TwoVisitsWithCustomVariables; | |
| /** | |
| * test Metadata API + period=range&date=lastN | |
| * | |
| * @group PeriodIsRangeDateIsLastNMetadataAndNormalAPITest | |
| * @group Core | |
| */ | |
| class PeriodIsRangeDateIsLastNMetadataAndNormalAPITest extends SystemTestCase | |
| { | |
| public static $fixture = null; | |
| public static function setUpBeforeClass(): void | |
| { | |
| self::$fixture->dateTime = Date::factory('yesterday')->getDateTime(); | |
| parent::setUpBeforeClass(); | |
| } | |
| protected function setUp(): void | |
| { | |
| // test results change based on time of day for some reason | |
| Date::$now = strtotime(date('Y-m-d') . ' 20:00:00'); | |
| parent::setUp(); | |
| } | |
| /** | |
| * @dataProvider getApiForTesting | |
| */ | |
| public function testApi($api, $params) | |
| { | |
| $this->runApiTests($api, $params); | |
| } | |
| public function getApiForTesting() | |
| { | |
| $idSite = self::$fixture->idSite; | |
| $visitorId = self::$fixture->visitorId; | |
| $apiToCall = array( | |
| 'API.getProcessedReport', | |
| 'Actions.getPageUrls', | |
| 'Goals.get', | |
| 'CustomVariables.getCustomVariables', | |
| 'Referrers.getCampaigns', | |
| 'Referrers.getKeywords', | |
| 'VisitsSummary.get', | |
| 'Live'); | |
| $segments = array( | |
| false, | |
| 'daysSinceFirstVisit!=50', | |
| 'visitorId!=33c31e01394bdc63', | |
| 'visitorId!=33c31e01394bdc63;daysSinceFirstVisit!=50', | |
| // testing segment on Actions table | |
| 'pageUrl!=http://unknown/not/viewed', | |
| ); | |
| $dates = array( | |
| 'last7', | |
| Date::factory('now')->subDay(6)->toString() . ',today', | |
| Date::factory('now')->subDay(6)->toString() . ',now', | |
| ); | |
| $result = array(); | |
| foreach ($segments as $segment) { | |
| $testSuffix = ''; | |
| if (!empty($segment) && false !== strpos($segment, 'pageUrl')) { | |
| $testSuffix .= '_pagesegment'; | |
| } | |
| foreach ($dates as $date) { | |
| $result[] = array($apiToCall, array('idSite' => $idSite, 'date' => $date, | |
| 'periods' => array('range'), 'segment' => $segment, | |
| 'testSuffix' => $testSuffix, | |
| 'apiNotToCall' => ['Live.getMostRecentVisitsDateTime'], | |
| 'otherRequestParameters' => array( | |
| 'lastMinutes' => 60 * 24 * 2, | |
| 'visitorId' => $visitorId, | |
| 'hideColumns' => 'serverDate,lastActionTimestamp,lastActionDateTime,serverTimestamp,' . | |
| 'firstActionTimestamp,serverTimePretty,serverDatePretty,' . | |
| 'serverDatePrettyFirstAction,serverTimePrettyFirstAction', | |
| ))); | |
| } | |
| } | |
| return $result; | |
| } | |
| public static function getOutputPrefix() | |
| { | |
| return 'periodIsRange_dateIsLastN_MetadataAndNormalAPI'; | |
| } | |
| } | |
| PeriodIsRangeDateIsLastNMetadataAndNormalAPITest::$fixture = new TwoVisitsWithCustomVariables(); | |
| PeriodIsRangeDateIsLastNMetadataAndNormalAPITest::$fixture->doExtraQuoteTests = false; | |