Merge pull request #13254 from nupplaphil/bug/fix_tests
Fix php unit test with PHP 8.2
This commit is contained in:
commit
755bbac496
12 changed files with 73 additions and 18 deletions
6
composer.lock
generated
6
composer.lock
generated
|
@ -720,11 +720,11 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "friendica/json-ld",
|
"name": "friendica/json-ld",
|
||||||
"version": "1.1.2",
|
"version": "1.1.3",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.friendi.ca/friendica/php-json-ld",
|
"url": "https://git.friendi.ca/friendica/php-json-ld",
|
||||||
"reference": "5f6ea87b261d346e57f03457ae906e6835f0205f"
|
"reference": "8d1d421b1dfd493adc058a79541a257d4bfadb01"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
|
@ -760,7 +760,7 @@
|
||||||
"Semantic Web",
|
"Semantic Web",
|
||||||
"jsonld"
|
"jsonld"
|
||||||
],
|
],
|
||||||
"time": "2023-02-20T21:56:16+00:00"
|
"time": "2023-05-23T05:58:06+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "fxp/composer-asset-plugin",
|
"name": "fxp/composer-asset-plugin",
|
||||||
|
|
|
@ -29,6 +29,7 @@ class Notifications extends BaseCollection
|
||||||
/**
|
/**
|
||||||
* @return Notification
|
* @return Notification
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function current()
|
public function current()
|
||||||
{
|
{
|
||||||
return parent::current();
|
return parent::current();
|
||||||
|
|
|
@ -24,8 +24,8 @@ namespace Friendica\Object\Api\Twitter;
|
||||||
use Friendica\BaseDataTransferObject;
|
use Friendica\BaseDataTransferObject;
|
||||||
use Friendica\Content\ContactSelector;
|
use Friendica\Content\ContactSelector;
|
||||||
use Friendica\Content\Text\BBCode;
|
use Friendica\Content\Text\BBCode;
|
||||||
use Friendica\Core\Protocol;
|
|
||||||
use Friendica\Model\Contact;
|
use Friendica\Model\Contact;
|
||||||
|
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||||
use Friendica\Util\DateTimeFormat;
|
use Friendica\Util\DateTimeFormat;
|
||||||
use Friendica\Util\Proxy;
|
use Friendica\Util\Proxy;
|
||||||
|
|
||||||
|
@ -82,6 +82,42 @@ class User extends BaseDataTransferObject
|
||||||
protected $withheld_in_countries;
|
protected $withheld_in_countries;
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $withheld_scope;
|
protected $withheld_scope;
|
||||||
|
/** @var string */
|
||||||
|
protected $profile_image_url;
|
||||||
|
/** @var bool */
|
||||||
|
protected $follow_request_sent;
|
||||||
|
/** @var string */
|
||||||
|
protected $profile_image_url_large;
|
||||||
|
/** @var string */
|
||||||
|
protected $profile_image_url_profile_size;
|
||||||
|
/** @var int */
|
||||||
|
protected $utc_offset;
|
||||||
|
/** @var string */
|
||||||
|
protected $time_zone;
|
||||||
|
/** @var bool */
|
||||||
|
protected $geo_enabled;
|
||||||
|
/** @var null */
|
||||||
|
protected $lang;
|
||||||
|
/** @var bool */
|
||||||
|
protected $contributors_enabled;
|
||||||
|
/** @var bool */
|
||||||
|
protected $is_translator;
|
||||||
|
/** @var bool */
|
||||||
|
protected $is_translation_enabled;
|
||||||
|
/** @var bool */
|
||||||
|
protected $following;
|
||||||
|
/** @var bool */
|
||||||
|
protected $statusnet_blocking;
|
||||||
|
/** @var bool */
|
||||||
|
protected $notifications;
|
||||||
|
/** @var int */
|
||||||
|
protected $uid;
|
||||||
|
/** @var int */
|
||||||
|
protected $pid;
|
||||||
|
/** @var int */
|
||||||
|
protected $cid;
|
||||||
|
/** @var mixed */
|
||||||
|
protected $statusnet_profile_url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Missing fields:
|
* Missing fields:
|
||||||
|
@ -95,11 +131,12 @@ class User extends BaseDataTransferObject
|
||||||
* @param array $publicContact Full contact table record with uid = 0
|
* @param array $publicContact Full contact table record with uid = 0
|
||||||
* @param array $apcontact Optional full apcontact table record
|
* @param array $apcontact Optional full apcontact table record
|
||||||
* @param array $userContact Optional full contact table record with uid != 0
|
* @param array $userContact Optional full contact table record with uid != 0
|
||||||
* @param bool $skip_status Whether to remove the last status property, currently unused
|
* @param null $status
|
||||||
* @param bool $include_user_entities Whether to add the entities property
|
* @param bool $include_user_entities Whether to add the entities property
|
||||||
* @throws \Friendica\Network\HTTPException\InternalServerErrorException
|
*
|
||||||
|
* @throws InternalServerErrorException
|
||||||
*/
|
*/
|
||||||
public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], $status = null, $include_user_entities = true)
|
public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], $status = null, bool $include_user_entities = true)
|
||||||
{
|
{
|
||||||
$uid = $userContact['uid'] ?? 0;
|
$uid = $userContact['uid'] ?? 0;
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ final class ACLFormatter
|
||||||
*
|
*
|
||||||
* @return array The array based on the IDs (empty in case there is no list)
|
* @return array The array based on the IDs (empty in case there is no list)
|
||||||
*/
|
*/
|
||||||
public function expand(string $acl_string = null)
|
public function expand(string $acl_string = null): array
|
||||||
{
|
{
|
||||||
// In case there is no ID list, return empty array (=> no ACL set)
|
// In case there is no ID list, return empty array (=> no ACL set)
|
||||||
if (empty($acl_string)) {
|
if (empty($acl_string)) {
|
||||||
|
@ -55,7 +55,7 @@ final class ACLFormatter
|
||||||
* @param string|null $acl_string
|
* @param string|null $acl_string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function sanitize(string $acl_string = null)
|
public function sanitize(string $acl_string = null): string
|
||||||
{
|
{
|
||||||
if (empty($acl_string)) {
|
if (empty($acl_string)) {
|
||||||
return '';
|
return '';
|
||||||
|
@ -107,10 +107,13 @@ final class ACLFormatter
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function toString($permissions) {
|
function toString($permissions): string
|
||||||
|
{
|
||||||
$return = '';
|
$return = '';
|
||||||
if (is_array($permissions)) {
|
if (is_array($permissions)) {
|
||||||
$item = $permissions;
|
$item = $permissions;
|
||||||
|
} elseif (empty($permissions)) {
|
||||||
|
return '';
|
||||||
} else {
|
} else {
|
||||||
$item = explode(',', $permissions);
|
$item = explode(',', $permissions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ class ReversedFileReader implements \Iterator
|
||||||
*
|
*
|
||||||
* @return string|null Depending on data being buffered
|
* @return string|null Depending on data being buffered
|
||||||
*/
|
*/
|
||||||
private function _readline()
|
private function _readline(): ?string
|
||||||
{
|
{
|
||||||
$buffer = & $this->buffer;
|
$buffer = & $this->buffer;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -112,6 +112,7 @@ class ReversedFileReader implements \Iterator
|
||||||
* @see Iterator::next()
|
* @see Iterator::next()
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function next()
|
public function next()
|
||||||
{
|
{
|
||||||
++$this->key;
|
++$this->key;
|
||||||
|
@ -124,6 +125,7 @@ class ReversedFileReader implements \Iterator
|
||||||
* @see Iterator::rewind()
|
* @see Iterator::rewind()
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
#[\ReturnTypeWillChange]
|
||||||
public function rewind()
|
public function rewind()
|
||||||
{
|
{
|
||||||
if ($this->filesize > 0) {
|
if ($this->filesize > 0) {
|
||||||
|
|
|
@ -118,7 +118,7 @@ class XML
|
||||||
$namespace = null;
|
$namespace = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$element->addAttribute($attr_key, $attr_value, $namespace);
|
$element->addAttribute($attr_key, $attr_value ?? '', $namespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -60,7 +60,6 @@ class StaticDatabase extends Database
|
||||||
$this->driver = 'pdo';
|
$this->driver = 'pdo';
|
||||||
$this->connection = self::$staticConnection;
|
$this->connection = self::$staticConnection;
|
||||||
$this->connected = true;
|
$this->connected = true;
|
||||||
$this->emulate_prepares = false;
|
|
||||||
|
|
||||||
return $this->connected;
|
return $this->connected;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Intercept extends php_user_filter
|
||||||
public static $cache = '';
|
public static $cache = '';
|
||||||
|
|
||||||
/** @noinspection PhpMissingParentCallCommonInspection */
|
/** @noinspection PhpMissingParentCallCommonInspection */
|
||||||
public function filter($in, $out, &$consumed, $closing)
|
public function filter($in, $out, &$consumed, $closing): int
|
||||||
{
|
{
|
||||||
while ($bucket = stream_bucket_make_writeable($in)) {
|
while ($bucket = stream_bucket_make_writeable($in)) {
|
||||||
self::$cache .= $bucket->data;
|
self::$cache .= $bucket->data;
|
||||||
|
|
|
@ -178,7 +178,7 @@ class BaseURLTest extends MockedTest
|
||||||
public function testRedirectException()
|
public function testRedirectException()
|
||||||
{
|
{
|
||||||
self::expectException(InternalServerErrorException::class);
|
self::expectException(InternalServerErrorException::class);
|
||||||
self::expectErrorMessage('https://friendica.other is not a relative path, please use System::externalRedirect');
|
self::expectExceptionMessage('https://friendica.other is not a relative path, please use System::externalRedirect');
|
||||||
|
|
||||||
$config = new ReadOnlyFileConfig(new Cache([
|
$config = new ReadOnlyFileConfig(new Cache([
|
||||||
'system' => [
|
'system' => [
|
||||||
|
|
|
@ -28,6 +28,9 @@ use Friendica\Test\FixtureTest;
|
||||||
|
|
||||||
class BBCodeTest extends FixtureTest
|
class BBCodeTest extends FixtureTest
|
||||||
{
|
{
|
||||||
|
/** @var \HTMLPurifier */
|
||||||
|
public $HTMLPurifier;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
|
@ -30,6 +30,15 @@ class DatabaseTest extends FixtureTest
|
||||||
{
|
{
|
||||||
use CreateDatabaseTrait;
|
use CreateDatabaseTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var Cache
|
||||||
|
*/
|
||||||
|
protected $configCache;
|
||||||
|
/**
|
||||||
|
* @var ConfigFileManager
|
||||||
|
*/
|
||||||
|
protected $configFileManager;
|
||||||
|
|
||||||
protected function setUp(): void
|
protected function setUp(): void
|
||||||
{
|
{
|
||||||
$this->setUpVfsDir();
|
$this->setUpVfsDir();
|
||||||
|
|
|
@ -231,11 +231,12 @@ class CookieTest extends MockedTest
|
||||||
|
|
||||||
$data = json_decode(StaticCookie::$_COOKIE[Cookie::NAME]);
|
$data = json_decode(StaticCookie::$_COOKIE[Cookie::NAME]);
|
||||||
|
|
||||||
self::assertObjectHasAttribute('uid', $data);
|
self::assertIsObject($data);
|
||||||
|
self::assertTrue(property_exists($data, 'uid'));
|
||||||
self::assertEquals($uid, $data->uid);
|
self::assertEquals($uid, $data->uid);
|
||||||
self::assertObjectHasAttribute('hash', $data);
|
self::assertTrue(property_exists($data, 'hash'));
|
||||||
self::assertEquals($hash, $data->hash);
|
self::assertEquals($hash, $data->hash);
|
||||||
self::assertObjectHasAttribute('ip', $data);
|
self::assertTrue(property_exists($data, 'ip'));
|
||||||
self::assertEquals($remoteIp, $data->ip);
|
self::assertEquals($remoteIp, $data->ip);
|
||||||
|
|
||||||
self::assertLessThanOrEqual(time() + Cookie::DEFAULT_EXPIRE * 24 * 60 * 60, StaticCookie::$_EXPIRE);
|
self::assertLessThanOrEqual(time() + Cookie::DEFAULT_EXPIRE * 24 * 60 * 60, StaticCookie::$_EXPIRE);
|
||||||
|
|
Loading…
Reference in a new issue