قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-24 16:07:37 +00:00

* [Coding Style] Enable rule PSR1.Methods.CamelCapsMethodName.NotCamelCaps * [Coding Style] Use camel case for method names in API plugin tests (#22145) * [Coding Style] Use camel case for method names in Core* plugin tests (#22147) * [Coding Style] Use camel case for method names in core Unit tests (#22149) * [Coding Style] Use camel case for method names in Actions and BulkTracking plugin tests (#22146) * [Coding Style] Use camel case for method names in CustomDimensions and CustomJSTracker plugin tests (#22148) * [Coding Style] Use camel case for method names in core Integration tests (#22151) * [Coding Style] Use camel case for method names in more core plugin tests (#22153) * [Coding Style] Use camel case for method names in more core plugin tests (#22157) * [Coding Style] Use camel case for method names in more core plugin tests * Update plugins/Monolog/tests/Unit/Processor/ExceptionToTextProcessorTest.php Co-authored-by: Michal Kleiner <michal@innocraft.com> --------- Co-authored-by: Michal Kleiner <michal@innocraft.com> * [Coding Style] Use camel case for method names in more core plugin tests (#22159) * [Coding Style] Use camel case for method names in remaining tests (#22160) * [Coding Style] Use camel case for method names in remaining tests * rename expected test files --------- Co-authored-by: Michal Kleiner <michal@innocraft.com>
111 خطوط
3.0 KiB
PHP
111 خطوط
3.0 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\Unit;
|
|
|
|
use Piwik\Context;
|
|
use Piwik\Tracker;
|
|
|
|
class ContextTest extends \PHPUnit\Framework\TestCase
|
|
{
|
|
/**
|
|
* @dataProvider getTestDataForOverwriteIdSiteForCache
|
|
*/
|
|
public function testOverwriteIdSiteForCacheShouldModifySuperGlobalsCorrectly(
|
|
$originalGet,
|
|
$originalPost,
|
|
$inTrackerMode,
|
|
$idSite,
|
|
$expectedChangedGet,
|
|
$expectedChangedPost
|
|
) {
|
|
$originalTrackerMode = Tracker::$initTrackerMode;
|
|
try {
|
|
Tracker::$initTrackerMode = $inTrackerMode;
|
|
|
|
$_GET = $originalGet;
|
|
$_POST = $originalPost;
|
|
|
|
Context::changeIdSite($idSite, function () use ($expectedChangedGet, $expectedChangedPost) {
|
|
$this->assertEquals($expectedChangedGet, $_GET);
|
|
$this->assertEquals($expectedChangedPost, $expectedChangedPost);
|
|
});
|
|
|
|
// make sure GET/POST revert correctly
|
|
$this->assertEquals($originalGet, $_GET);
|
|
$this->assertEquals($originalPost, $_POST);
|
|
} finally {
|
|
Tracker::$initTrackerMode = $originalTrackerMode;
|
|
}
|
|
}
|
|
|
|
public function getTestDataForOverwriteIdSiteForCache()
|
|
{
|
|
return [
|
|
// all get, no post
|
|
[
|
|
['idSite' => '1', 'idSites' => '2,3', 'idsite' => '4'],
|
|
[],
|
|
false,
|
|
'5',
|
|
['idSite' => '5', 'idsite' => '4'],
|
|
['idSite' => '5'],
|
|
],
|
|
|
|
// all post, no get
|
|
[
|
|
[],
|
|
['idSite' => '1', 'idSites' => '2,3', 'idsite' => '4'],
|
|
false,
|
|
'5',
|
|
['idSite' => '5'],
|
|
['idSite' => '5', 'idsite' => '4'],
|
|
],
|
|
|
|
// post + get, no idSites
|
|
[
|
|
['idSite' => '1', 'idsite' => '3'],
|
|
['idSite' => '2', 'idsite' => '4'],
|
|
false,
|
|
'5',
|
|
['idSite' => '5', 'idsite' => '3'],
|
|
['idSite' => '5', 'idsite' => '4'],
|
|
],
|
|
|
|
// post + get, tracker mode
|
|
[
|
|
['idSite' => '1', 'idsite' => '4'],
|
|
['idSite' => '1', 'idsite' => '6'],
|
|
true,
|
|
'5',
|
|
['idSite' => '5', 'idsite' => '5'],
|
|
['idSite' => '5', 'idsite' => '5'],
|
|
],
|
|
|
|
// no variables set before
|
|
[
|
|
[],
|
|
[],
|
|
false,
|
|
'5',
|
|
['idSite' => '5'],
|
|
['idSite' => '5'],
|
|
],
|
|
[
|
|
[],
|
|
[],
|
|
true,
|
|
'5',
|
|
['idSite' => '5', 'idsite' => '5'],
|
|
['idSite' => '5', 'idsite' => '5'],
|
|
],
|
|
];
|
|
}
|
|
}
|