Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/matomo-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
adapter: 'PDO_MYSQL'
mysql-engine: 'Mariadb'
mysql-version: '11.4'
- php: '8.4'
- php: '8.5'
adapter: 'MYSQLI'
mysql-engine: 'Mysql'
mysql-version: '8.0'
Expand Down
8 changes: 8 additions & 0 deletions core/Http.php
Original file line number Diff line number Diff line change
Expand Up @@ -624,9 +624,17 @@ public static function sendHttpRequestBy(
fwrite($file, $response);
}
fclose($handle);

if (function_exists('http_get_last_response_headers')) {
$http_response_header = http_get_last_response_headers();
}
} else {
$response = @file_get_contents($aUrl, 0, $ctx);

if (function_exists('http_get_last_response_headers')) {
$http_response_header = http_get_last_response_headers();
}

// try to get http status code from response headers
if (!empty($http_response_header) && preg_match('~^HTTP/(\d\.\d)\s+(\d+)(\s*.*)?~', implode("\n", $http_response_header), $m)) {
$status = (int)$m[2];
Expand Down
5 changes: 4 additions & 1 deletion plugins/Marketplace/tests/Unit/PluginsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public function testPrettifyNumberOfDownloads($numDownloads, $expectedPrettyDown

$pluginsReflection = new ReflectionClass($pluginsClass);
$method = $pluginsReflection->getMethod('prettifyNumberOfDownloads');
$method->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$plugin = ['numDownloads' => $numDownloads];
$method->invokeArgs($pluginsClass, [&$plugin]);
Expand Down
5 changes: 4 additions & 1 deletion plugins/ScheduledReports/tests/Integration/ApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,10 @@ public function testGetReportSubjectAndReportTitle($expectedReportSubject, $expe
'\\Piwik\\Plugins\\ScheduledReports\\API',
'getReportSubjectAndReportTitle'
);
$getReportSubjectAndReportTitle->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$getReportSubjectAndReportTitle->setAccessible(true);
}

[$reportSubject, $reportTitle] = $getReportSubjectAndReportTitle->invoke(APIScheduledReports::getInstance(), $websiteName, $reports);
$this->assertEquals($expectedReportSubject, $reportSubject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ public function setUp(): void

$this->filter = new UserAccessFilter($this->model, $this->access);
$method = new \ReflectionMethod($this->filter, 'isNonSuperUserAllowedToSeeThisLogin');
$method->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$this->isNonSuperUserAllowedToSeeThisLogin = $method;
}

Expand Down
5 changes: 4 additions & 1 deletion tests/PHPUnit/Integration/API/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,10 @@ private function createAccessMock($auth)
// some tests require it)
$reflection = new ReflectionClass(Access::class);
$reflectionProperty = $reflection->getProperty('idsitesByAccess');
$reflectionProperty->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$reflectionProperty->setAccessible(true);
}

$reflectionProperty->setValue($mock, $this->idSitesAccess);
});
Expand Down
6 changes: 5 additions & 1 deletion tests/PHPUnit/Integration/CliMulti/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ public function testGetSecondsSinceCreation()
{
// This is not proper, but it avoids using sleep and stopping the tests for several seconds
$r = new ReflectionProperty($this->process, 'timeCreation');
$r->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$r->setAccessible(true);
}

$r->setValue($this->process, time() - 2);

$seconds = $this->process->getSecondsSinceCreation();
Expand Down
5 changes: 4 additions & 1 deletion tests/PHPUnit/Integration/CronArchiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,10 @@ public function testCanWeSkipInvalidatingBecauseThereIsAUsablePeriodReturnsExpec

$class = new \ReflectionClass(CronArchive::class);
$method = $class->getMethod('canWeSkipInvalidatingBecauseThereIsAUsablePeriod');
$method->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$actual = $method->invoke($archiver, $params, $dayToArchive === 'yesterday');
$this->assertSame($expected, $actual);
Expand Down
12 changes: 10 additions & 2 deletions tests/PHPUnit/Integration/DataAccess/LogAggregatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ public function testGetSelectDimensions($dimensions, $tableName, $expectedResult
{
$class = new \ReflectionClass(LogAggregator::class);
$method = $class->getMethod('getSelectDimensions');
$method->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$output = $method->invoke($this->logAggregator, $dimensions, $tableName);
$this->assertEquals($expectedResult, $output);
}
Expand Down Expand Up @@ -127,7 +131,11 @@ public function testGetGroupByDimensions($dimensions, $tableName, $expectedResul
{
$class = new \ReflectionClass(LogAggregator::class);
$method = $class->getMethod('getGroupByDimensions');
$method->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$output = $method->invoke($this->logAggregator, $dimensions, $tableName);
$this->assertEquals($expectedResult, $output);
}
Expand Down
5 changes: 4 additions & 1 deletion tests/PHPUnit/System/ArchiveInvalidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,10 @@ public function testDatesCorrectlyParsed($dates, $period, $expected)
$api = CoreAdminHomeApi::getInstance();
$reflection = new \ReflectionClass(CoreAdminHomeApi::class);
$method = $reflection->getMethod('getDatesToInvalidateFromString');
$method->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$parameters = [$dates, $period];

Expand Down
8 changes: 5 additions & 3 deletions tests/PHPUnit/Unit/DbHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ public function testExtractOrderByFromQuery(string $sql, ?string $expectedOrderB
{
$extractedOrderBy = DbHelper::extractOrderByFromQuery($sql);

// compare with collapsed whitespace
$expectedOrderBy = trim(preg_replace('/\s+/', ' ', $expectedOrderBy));
$extractedOrderBy = trim(preg_replace('/\s+/', ' ', $extractedOrderBy));
if (null !== $expectedOrderBy) {
// compare with collapsed whitespace
$expectedOrderBy = trim(preg_replace('/\s+/', ' ', $expectedOrderBy));
$extractedOrderBy = trim(preg_replace('/\s+/', ' ', $extractedOrderBy));
}

$this->assertSame($expectedOrderBy, $extractedOrderBy);
}
Expand Down
5 changes: 4 additions & 1 deletion tests/PHPUnit/Unit/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ class HttpTest extends \PHPUnit\Framework\TestCase
public function testgetProxyConfiguration($url, $proxyConfiguration, $expected)
{
$getProxyConfiguration = new ReflectionMethod('\\Piwik\\Http', 'getProxyConfiguration');
$getProxyConfiguration->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$getProxyConfiguration->setAccessible(true);
}

Config::getInstance()->proxy['host'] = $proxyConfiguration[0];
Config::getInstance()->proxy['port'] = $proxyConfiguration[1];
Expand Down
6 changes: 5 additions & 1 deletion tests/PHPUnit/Unit/SettingsServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ public function testGetMegaBytesFromShorthandByte($data, $expected)
{
$class = new \ReflectionClass(SettingsServer::class);
$method = $class->getMethod('getMegaBytesFromShorthandByte');
$method->setAccessible(true);

if (PHP_VERSION_ID < 80100) {
$method->setAccessible(true);
}

$output = $method->invoke($class, $data);

$this->assertEquals($expected, $output);
Expand Down
Loading