قرینه از
https://github.com/matomo-org/matomo.git
synced 2025-08-22 06:57:53 +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>
96 خطوط
3.2 KiB
PHP
96 خطوط
3.2 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\Plugins\SegmentEditor\tests\System;
|
|
|
|
use Piwik\Config;
|
|
use Piwik\Http;
|
|
use Piwik\Plugins\SegmentEditor\API as SegmentEditorApi;
|
|
use Piwik\Tests\Framework\Fixture;
|
|
use Piwik\Tests\Framework\TestCase\SystemTestCase;
|
|
|
|
class ApiTest extends SystemTestCase
|
|
{
|
|
public function testSegmentHashWorkflowWhenSegmentIsCrazyEncoded()
|
|
{
|
|
$segment = 'pageUrl=@%252F1';
|
|
|
|
Fixture::createWebsite('2020-03-03 00:00:00');
|
|
|
|
Config::getInstance()->General['enable_browser_archiving_triggering'] = 0;
|
|
self::$fixture->getTestEnvironment()->overrideConfig('General', 'enable_browser_archiving_triggering', 0);
|
|
self::$fixture->getTestEnvironment()->save();
|
|
|
|
$url = Fixture::getTestRootUrl() . '?' . http_build_query([
|
|
'module' => 'API',
|
|
'method' => 'SegmentEditor.add',
|
|
'name' => 'test segment',
|
|
'definition' => $segment,
|
|
'idSite' => 1,
|
|
'autoArchive' => 1,
|
|
'enabledAllUsers' => 1,
|
|
'format' => 'json',
|
|
'token_auth' => Fixture::getTokenAuth(),
|
|
]);
|
|
self::assertStringContainsString(urlencode($segment), $url);
|
|
|
|
Http::sendHttpRequest($url, 10);
|
|
|
|
$segments = SegmentEditorApi::getInstance()->getAll();
|
|
$segmentDefinitionHash = end($segments);
|
|
$segmentDefinitionHash = $segmentDefinitionHash['hash'];
|
|
|
|
$url = Fixture::getTestRootUrl() . '?' . http_build_query([
|
|
'module' => 'API',
|
|
'method' => 'ExamplePlugin.getSegmentHash',
|
|
'segment' => $segment,
|
|
'idSite' => 1,
|
|
'format' => 'json',
|
|
'token_auth' => Fixture::getTokenAuth(),
|
|
]);
|
|
|
|
$segmentApiHash = Http::sendHttpRequest($url, 10);
|
|
$segmentApiHash = json_decode($segmentApiHash, true);
|
|
$segmentApiHash = $segmentApiHash['value'];
|
|
|
|
$this->assertEquals($segmentApiHash, $segmentDefinitionHash);
|
|
}
|
|
|
|
/**
|
|
* @dataProvider definitionsDataProvider
|
|
*/
|
|
public function testGeneratedSegmentHash($definition)
|
|
{
|
|
Fixture::createWebsite('2020-03-03 00:00:00');
|
|
|
|
Config::getInstance()->General['enable_browser_archiving_triggering'] = 0;
|
|
self::$fixture->getTestEnvironment()->overrideConfig('General', 'enable_browser_archiving_triggering', 0);
|
|
self::$fixture->getTestEnvironment()->save();
|
|
|
|
$idSegment = SegmentEditorApi::getInstance()->add('test segment', $definition, 1, 1, 1);
|
|
$segment = SegmentEditorApi::getInstance()->get($idSegment);
|
|
|
|
$hash = $segment['hash'];
|
|
$generatedHash = md5(urldecode($segment['definition']));
|
|
|
|
$this->assertEquals($generatedHash, $hash);
|
|
}
|
|
|
|
public function definitionsDataProvider()
|
|
{
|
|
return [
|
|
['pageUrl=@%252F1'],
|
|
['actions>=1'],
|
|
['operatingSystemName==Ubuntu;browserName==Firefox'],
|
|
['pageUrl==https%253A%252F%252Fmatomo.org%252Fpricing%252F'],
|
|
['visitIp>=80.229.0.0;visitIp<=80.229.255.255'],
|
|
];
|
|
}
|
|
}
|