1
0
قرینه از https://github.com/matomo-org/matomo.git synced 2025-08-22 06:57:53 +00:00
Files
matomo/tests/PHPUnit/System/AllWebsitesTest.php
Michal Kleiner 9a3ef94df6 [Coding Style] Enable rule PSR12.Files.FileHeader + unify file headers (#22132)
* [Coding Style] Enable rule PSR12.Files.FileHeader

* Apply CS

* Replace Piwik with Matomo in file headers

* Unify file headers (position, no. of lines, https links)

* Rebuild dist files

* Apply CS

* Fix system test that relies on line numbers in a file that had the file header updated

---------

Co-authored-by: Stefan Giehl <stefan@matomo.org>
2024-04-20 20:50:47 +02:00

78 خطوط
2.5 KiB
PHP

<?php
/**
* 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\Plugins\UsersManager\API as UsersManagerAPI;
use Piwik\Plugins\UsersManager\Model as UsersManagerModel;
use Piwik\Tests\Fixtures\ThreeSitesWithSharedVisitors;
use Piwik\Tests\Framework\TestCase\SystemTestCase;
/**
* @group Core
* @group AllWebsitesTest
*/
class AllWebsitesTest extends SystemTestCase
{
public static $fixture = null; // initialized below class definition
protected static $userTokenAuth = '34bcc4d2c330259d6f37bc3d98d425f4';
public static function setUpBeforeClass(): void
{
parent::setUpBeforeClass();
self::createUser();
}
private static function createUser()
{
if (!UsersManagerAPI::getInstance()->userExists('limitedUser')) {
// create non super user
UsersManagerAPI::getInstance()->addUser('limitedUser', 'smartypants', 'user@limited.com');
UsersManagerAPI::getInstance()->setUserAccess('limitedUser', 'view', array(2, 3));
$userModel = new UsersManagerModel();
$userModel->addTokenAuth('limitedUser', self::$userTokenAuth, 'desc', '2020-01-02 03:04:05');
}
}
public function getApiForTesting()
{
$dateTime = substr(self::$fixture->dateTime, 0, 10);
return [
// should return all websites as super user has access to all
['VisitsSummary.get', ['idSite' => 'all',
'date' => $dateTime,
'period' => 'day',
'format' => 'csv'], [
'testSuffix' => 'superuser']
],
// should only return results for sites the user has access to (2,3)
['VisitsSummary.get', ['idSite' => 'all',
'date' => $dateTime,
'period' => 'day',
'format' => 'csv',
'token_auth' => self::$userTokenAuth], [
'testSuffix' => 'user']
],
];
}
/**
* @dataProvider getApiForTesting
*/
public function testApi($api, $params, $options)
{
$this->runAnyApiTest($api, '', $params, $options);
}
}
AllWebsitesTest::$fixture = new ThreeSitesWithSharedVisitors();