2022-03-15 17:49:42 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types = 1);
|
|
|
|
|
|
|
|
// {{{ License
|
|
|
|
|
|
|
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
|
|
|
//
|
|
|
|
// GNU social is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// GNU social is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
// }}}
|
|
|
|
|
|
|
|
namespace Plugin\ActivityPub\Test\Objects;
|
|
|
|
|
|
|
|
use App\Core\VisibilityScope;
|
|
|
|
use App\Entity\Note;
|
|
|
|
use App\Util\GNUsocialTestCase;
|
|
|
|
use Plugin\ActivityPub\ActivityPub;
|
|
|
|
use Plugin\ActivityPub\Entity\ActivitypubObject;
|
|
|
|
use Plugin\ActivityPub\Util\Explorer;
|
|
|
|
|
2022-03-28 21:04:24 +01:00
|
|
|
class GSObjectArticleTest extends GNUsocialTestCase
|
2022-03-15 17:49:42 +00:00
|
|
|
{
|
|
|
|
public function testNoteFromJson()
|
|
|
|
{
|
|
|
|
self::bootKernel();
|
|
|
|
|
|
|
|
$actor_uri = 'https://instance.gnusocial.test/actor/42';
|
|
|
|
$object_uri = 'https://instance.gnusocial.test/object/note/1338';
|
2022-03-19 22:21:15 +00:00
|
|
|
$group_uri = 'https://instance.gnusocial.test/actor/21';
|
2022-03-28 21:04:24 +01:00
|
|
|
$article = ActivityPub::getObjectByUri($object_uri, try_online: false);
|
|
|
|
static::assertInstanceOf(Note::class, $article);
|
2022-03-15 17:49:42 +00:00
|
|
|
|
2022-03-28 21:04:24 +01:00
|
|
|
static::assertSame(Explorer::getOneFromUri($actor_uri)->getId(), $article->getActorId());
|
|
|
|
static::assertSame('text/markdown', $article->getContentType());
|
|
|
|
static::assertSame('This is an interesting article.', $article->getContent());
|
|
|
|
static::assertSame('<p>This is an interesting article.</p>', $article->getRendered());
|
|
|
|
static::assertSame('ActivityPub', $article->getSource());
|
|
|
|
static::assertNull($article->getReplyTo());
|
|
|
|
static::assertFalse($article->getIsLocal());
|
|
|
|
static::assertSame(VisibilityScope::EVERYWHERE, $article->getScope());
|
|
|
|
static::assertSame($object_uri, $article->getUrl());
|
|
|
|
static::assertNull($article->getLanguageLocale());
|
|
|
|
static::assertSame('article', $article->getType());
|
|
|
|
static::assertSame('hello, world.', $article->getTitle());
|
2022-03-15 17:49:42 +00:00
|
|
|
|
|
|
|
$ap_object = ActivitypubObject::getByPK(['object_uri' => $object_uri]);
|
|
|
|
static::assertSame(Note::schemaName(), $ap_object->getObjectType());
|
|
|
|
static::assertSame($object_uri, $ap_object->getObjectUri());
|
2022-03-28 21:04:24 +01:00
|
|
|
static::assertSame($article->getId(), $ap_object->getObjectId());
|
2022-03-15 17:49:42 +00:00
|
|
|
|
2022-03-28 21:04:24 +01:00
|
|
|
static::assertCount(1, $attT = $article->getAttentionTargets());
|
2022-03-19 22:21:15 +00:00
|
|
|
static::assertObjectEquals(Explorer::getOneFromUri($group_uri, try_online: false), $attT[0]);
|
2022-03-28 21:04:24 +01:00
|
|
|
static::assertSame([], $article->getMentionTargets());
|
2022-03-15 17:49:42 +00:00
|
|
|
}
|
|
|
|
}
|