-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
Potential BugSomething that might be a bug, but needs validation and confirmation it can be reproduced.Something that might be a bug, but needs validation and confirmation it can be reproduced.triaged
Description
What happened?
This is an issue that affects plugin development, specifically writing system tests for API methods.
System tests construct test URLs and use them to invoke API methods. When using an associative array, eg:
['apiParameters' => ['param1' => 1, 'param2' => 2]]
for the 'otherRequestParameters' property of an API test configuration, it is transformed to this in the test URL:
apiParameters[]=1&apiParameters[]=2
This makes it impossible to test API.getMetadata/API.getProcessedReport with a custom apiParameters value.
What should happen?
Using apiParameters in the otherRequestParameters property should be correctly converted to a URL that respects associative array keys, like this:
apiParameters[param1]=1&apiParameters[param2]=2
How can this be reproduced?
This issue can be reproduced with the following code (based on SystemTestCase::runApiTests()):
$api = 'API.getMetadata';
$params = [
'idSite' => $idSite,
'date' => $date,
'periods' => ['day'],
'apiModule' => 'Goals',
'apiAction' => 'getItemsCategory',
'otherRequestParameters' => [
'apiParameters' => ['idGoal' => 5],
]
];
$testConfig = new ApiTestConfig($params);
$testRequests = new Collection($api, $testConfig, $api);
foreach ($testRequests->getRequestUrls() as $apiId => $requestUrl) {
Assert::assertStringNotContainsString('apiParameters[]=', $requestUrl);
Assert::assertStringContainsString('apiParameters[idGoal]=', $requestUrl);
}
Matomo version
5.3.0
PHP version
No response
Server operating system
No response
What browsers are you seeing the problem on?
No response
Computer operating system
No response
Relevant log output
Validations
- Read our Contributing Guidelines.
- Follow our Security Policy.
- Check that there isn't already an issue that reports the same bug to avoid creating duplicates.
- The provided steps to reproduce is a minimal reproducible of the Bug.
Metadata
Metadata
Assignees
Labels
Potential BugSomething that might be a bug, but needs validation and confirmation it can be reproduced.Something that might be a bug, but needs validation and confirmation it can be reproduced.triaged