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",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://git.friendi.ca/friendica/php-json-ld",
|
||||
"reference": "5f6ea87b261d346e57f03457ae906e6835f0205f"
|
||||
"reference": "8d1d421b1dfd493adc058a79541a257d4bfadb01"
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
|
@ -760,7 +760,7 @@
|
|||
"Semantic Web",
|
||||
"jsonld"
|
||||
],
|
||||
"time": "2023-02-20T21:56:16+00:00"
|
||||
"time": "2023-05-23T05:58:06+00:00"
|
||||
},
|
||||
{
|
||||
"name": "fxp/composer-asset-plugin",
|
||||
|
|
|
@ -29,6 +29,7 @@ class Notifications extends BaseCollection
|
|||
/**
|
||||
* @return Notification
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function current()
|
||||
{
|
||||
return parent::current();
|
||||
|
|
|
@ -24,8 +24,8 @@ namespace Friendica\Object\Api\Twitter;
|
|||
use Friendica\BaseDataTransferObject;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Text\BBCode;
|
||||
use Friendica\Core\Protocol;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Network\HTTPException\InternalServerErrorException;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
use Friendica\Util\Proxy;
|
||||
|
||||
|
@ -82,6 +82,42 @@ class User extends BaseDataTransferObject
|
|||
protected $withheld_in_countries;
|
||||
/** @var string */
|
||||
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:
|
||||
|
@ -95,11 +131,12 @@ class User extends BaseDataTransferObject
|
|||
* @param array $publicContact Full contact table record with uid = 0
|
||||
* @param array $apcontact Optional full apcontact table record
|
||||
* @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
|
||||
* @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;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ final class ACLFormatter
|
|||
*
|
||||
* @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)
|
||||
if (empty($acl_string)) {
|
||||
|
@ -55,7 +55,7 @@ final class ACLFormatter
|
|||
* @param string|null $acl_string
|
||||
* @return string
|
||||
*/
|
||||
public function sanitize(string $acl_string = null)
|
||||
public function sanitize(string $acl_string = null): string
|
||||
{
|
||||
if (empty($acl_string)) {
|
||||
return '';
|
||||
|
@ -107,10 +107,13 @@ final class ACLFormatter
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function toString($permissions) {
|
||||
function toString($permissions): string
|
||||
{
|
||||
$return = '';
|
||||
if (is_array($permissions)) {
|
||||
$item = $permissions;
|
||||
} elseif (empty($permissions)) {
|
||||
return '';
|
||||
} else {
|
||||
$item = explode(',', $permissions);
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ class ReversedFileReader implements \Iterator
|
|||
*
|
||||
* @return string|null Depending on data being buffered
|
||||
*/
|
||||
private function _readline()
|
||||
private function _readline(): ?string
|
||||
{
|
||||
$buffer = & $this->buffer;
|
||||
while (true) {
|
||||
|
@ -112,6 +112,7 @@ class ReversedFileReader implements \Iterator
|
|||
* @see Iterator::next()
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function next()
|
||||
{
|
||||
++$this->key;
|
||||
|
@ -124,6 +125,7 @@ class ReversedFileReader implements \Iterator
|
|||
* @see Iterator::rewind()
|
||||
* @return void
|
||||
*/
|
||||
#[\ReturnTypeWillChange]
|
||||
public function rewind()
|
||||
{
|
||||
if ($this->filesize > 0) {
|
||||
|
|
|
@ -118,7 +118,7 @@ class XML
|
|||
$namespace = null;
|
||||
}
|
||||
|
||||
$element->addAttribute($attr_key, $attr_value, $namespace);
|
||||
$element->addAttribute($attr_key, $attr_value ?? '', $namespace);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
|
|
@ -60,7 +60,6 @@ class StaticDatabase extends Database
|
|||
$this->driver = 'pdo';
|
||||
$this->connection = self::$staticConnection;
|
||||
$this->connected = true;
|
||||
$this->emulate_prepares = false;
|
||||
|
||||
return $this->connected;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class Intercept extends php_user_filter
|
|||
public static $cache = '';
|
||||
|
||||
/** @noinspection PhpMissingParentCallCommonInspection */
|
||||
public function filter($in, $out, &$consumed, $closing)
|
||||
public function filter($in, $out, &$consumed, $closing): int
|
||||
{
|
||||
while ($bucket = stream_bucket_make_writeable($in)) {
|
||||
self::$cache .= $bucket->data;
|
||||
|
|
|
@ -178,7 +178,7 @@ class BaseURLTest extends MockedTest
|
|||
public function testRedirectException()
|
||||
{
|
||||
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([
|
||||
'system' => [
|
||||
|
|
|
@ -28,6 +28,9 @@ use Friendica\Test\FixtureTest;
|
|||
|
||||
class BBCodeTest extends FixtureTest
|
||||
{
|
||||
/** @var \HTMLPurifier */
|
||||
public $HTMLPurifier;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
|
|
@ -30,6 +30,15 @@ class DatabaseTest extends FixtureTest
|
|||
{
|
||||
use CreateDatabaseTrait;
|
||||
|
||||
/**
|
||||
* @var Cache
|
||||
*/
|
||||
protected $configCache;
|
||||
/**
|
||||
* @var ConfigFileManager
|
||||
*/
|
||||
protected $configFileManager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->setUpVfsDir();
|
||||
|
|
|
@ -231,11 +231,12 @@ class CookieTest extends MockedTest
|
|||
|
||||
$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::assertObjectHasAttribute('hash', $data);
|
||||
self::assertTrue(property_exists($data, 'hash'));
|
||||
self::assertEquals($hash, $data->hash);
|
||||
self::assertObjectHasAttribute('ip', $data);
|
||||
self::assertTrue(property_exists($data, 'ip'));
|
||||
self::assertEquals($remoteIp, $data->ip);
|
||||
|
||||
self::assertLessThanOrEqual(time() + Cookie::DEFAULT_EXPIRE * 24 * 60 * 60, StaticCookie::$_EXPIRE);
|
||||
|
|
Loading…
Reference in a new issue