[TESTS] Fix a couple of issues from last changes
This commit is contained in:
parent
888c3798b7
commit
20f690c532
@ -39,8 +39,6 @@ use App\Core\Entity;
|
||||
* @copyright 2009-2014 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @author Diogo Peralta Cordeiro <@diogo.site>
|
||||
* @copyright 2021-2022 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @author Diogo Peralta Cordeiro <@diogo.site>
|
||||
* @copyright 2022 Free Software Foundation, Inc http://www.fsf.org
|
||||
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
|
||||
*/
|
||||
class Attention extends Entity
|
||||
|
@ -43,6 +43,7 @@ use App\Core\Event;
|
||||
use App\Core\Form;
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Core\Log;
|
||||
use App\Entity\Actor;
|
||||
use App\Util\Common;
|
||||
use App\Util\Exception\AuthenticationException;
|
||||
use App\Util\Exception\NicknameEmptyException;
|
||||
@ -91,8 +92,9 @@ class PersonSettings extends Controller
|
||||
public function allSettings(Request $request, LanguageController $language): array
|
||||
{
|
||||
// Ensure the user is logged in and retrieve Actor object for given user
|
||||
$user = Common::ensureLoggedIn();
|
||||
$actor = $user->getActor();
|
||||
$user = Common::ensureLoggedIn();
|
||||
// Must be persisted
|
||||
$actor = DB::findOneBy(Actor::class, ['id' => $user->getId()]);
|
||||
|
||||
$personal_form = ActorForms::personalInfo(request: $request, scope: $actor, target: $actor);
|
||||
$email_form = self::email($request);
|
||||
|
@ -55,13 +55,13 @@ class PersonSettingsTest extends GNUsocialTestCase
|
||||
]);
|
||||
$changed_user = DB::findOneBy(LocalUser::class, ['id' => $user->getId()]);
|
||||
$actor = $changed_user->getActor();
|
||||
static::assertSame($changed_user->getNickname(), 'form_test_user_new_nickname');
|
||||
static::assertSame($actor->getNickname(), 'form_test_user_new_nickname');
|
||||
static::assertSame($actor->getFullName(), 'Form User');
|
||||
static::assertSame($actor->getHomepage(), 'https://gnu.org');
|
||||
static::assertSame($actor->getBio(), 'I was born at a very young age');
|
||||
static::assertSame($actor->getLocation(), 'right here');
|
||||
// static::assertSame($changed_user->getPhoneNumber()->getNationalNumber(), '908555842');
|
||||
static::assertSame('form_test_user_new_nickname', $changed_user->getNickname());
|
||||
static::assertSame('form_test_user_new_nickname', $actor->getNickname());
|
||||
static::assertSame('Form User', $actor->getFullName());
|
||||
static::assertSame('https://gnu.org', $actor->getHomepage());
|
||||
static::assertSame('I was born at a very young age', $actor->getBio());
|
||||
static::assertSame('right here', $actor->getLocation());
|
||||
// static::assertSame('908555842', $changed_user->getPhoneNumber()->getNationalNumber());
|
||||
}
|
||||
|
||||
/**
|
||||
|
61
plugins/ActivityPub/Test/Fixtures/ActivityPubFixtures.php
Normal file
61
plugins/ActivityPub/Test/Fixtures/ActivityPubFixtures.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Plugin\ActivityPub\Test\Fixtures;
|
||||
|
||||
use App\Core\DB\DB;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Plugin\ActivityPub\Util\Model\Activity;
|
||||
use Plugin\ActivityPub\Util\Model\Actor;
|
||||
use Plugin\ActivityPub\Util\Model\Note;
|
||||
|
||||
class ActivityPubFixtures extends Fixture
|
||||
{
|
||||
private static string $fixtures_path = __DIR__ . \DIRECTORY_SEPARATOR;
|
||||
|
||||
public static function fixturesPath(string $path, string $ontology = 'gnusocial'): string
|
||||
{
|
||||
return self::$fixtures_path . $ontology . \DIRECTORY_SEPARATOR . $path;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
/*
|
||||
* Beware that it's important to Load Actors, Objects, Activities in this sequence
|
||||
* because we're running offline tests here.
|
||||
*/
|
||||
$ontology = 'gnusocial';
|
||||
|
||||
// Load Actors
|
||||
$person_path = self::fixturesPath('objects/person.jsonld', $ontology);
|
||||
$person = Actor::fromJson(fread(fopen($person_path, 'r'), filesize($person_path)));
|
||||
DB::flush();
|
||||
$group_path = self::fixturesPath('objects/group.jsonld', $ontology);
|
||||
$group = Actor::fromJson(fread(fopen($group_path, 'r'), filesize($group_path)));
|
||||
DB::flush();
|
||||
|
||||
// Load Objects
|
||||
$note_path = self::fixturesPath('objects/note.jsonld', $ontology);
|
||||
$note = Note::fromJson(fread(fopen($note_path, 'r'), filesize($note_path)));
|
||||
DB::flush();
|
||||
$page_path = self::fixturesPath('objects/page.jsonld', $ontology);
|
||||
$page = Note::fromJson(fread(fopen($page_path, 'r'), filesize($page_path)));
|
||||
DB::flush();
|
||||
$reply_path = self::fixturesPath('objects/reply.jsonld', $ontology);
|
||||
$reply = Note::fromJson(fread(fopen($reply_path, 'r'), filesize($reply_path)));
|
||||
DB::flush();
|
||||
|
||||
// Load Activities
|
||||
$create_note_path = self::fixturesPath('activities/create_note.jsonld', $ontology);
|
||||
$create_note = Activity::fromJson(fread(fopen($create_note_path, 'r'), filesize($create_note_path)));
|
||||
DB::flush();
|
||||
$create_page_path = self::fixturesPath('activities/create_page.jsonld', $ontology);
|
||||
$create_page = Activity::fromJson(fread(fopen($create_page_path, 'r'), filesize($create_page_path)));
|
||||
DB::flush();
|
||||
$create_reply_path = self::fixturesPath('activities/create_reply.jsonld', $ontology);
|
||||
$create_reply = Activity::fromJson(fread(fopen($create_reply_path, 'r'), filesize($create_reply_path)));
|
||||
DB::flush();
|
||||
}
|
||||
}
|
@ -19,14 +19,14 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "https://testv3.gnusocial.rocks/activity/1337",
|
||||
"id": "https://instance.gnusocial.test/activity/1337",
|
||||
"published": "2022-03-01T20:58:48+00:00",
|
||||
"actor": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"actor": "https://instance.gnusocial.test/actor/42",
|
||||
"object": {
|
||||
"type": "Note",
|
||||
"id": "https://testv3.gnusocial.rocks/object/note/1337",
|
||||
"id": "https://instance.gnusocial.test/object/note/1337",
|
||||
"published": "2022-03-10T23:07:50+00:00",
|
||||
"attributedTo": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"attributedTo": "https://instance.gnusocial.test/actor/42",
|
||||
"content": "<p>hello, world.</p>",
|
||||
"mediaType": "text/html",
|
||||
"source": {
|
||||
@ -35,18 +35,18 @@
|
||||
},
|
||||
"attachment": [],
|
||||
"tag": [],
|
||||
"inConversation": "https://testv3.gnusocial.rocks/conversation/1337",
|
||||
"inConversation": "https://instance.gnusocial.test/conversation/1337",
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"cc": [
|
||||
"https://testv3.gnusocial.rocks/actor/42/subscribers"
|
||||
"https://instance.gnusocial.test/actor/42/subscribers"
|
||||
]
|
||||
},
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"cc": [
|
||||
"https://testv3.gnusocial.rocks/actor/42/subscribers"
|
||||
"https://instance.gnusocial.test/actor/42/subscribers"
|
||||
]
|
||||
}
|
@ -19,14 +19,14 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "https://testv3.gnusocial.rocks/activity/1338",
|
||||
"id": "https://instance.gnusocial.test/activity/1338",
|
||||
"published": "2022-03-01T18:19:51+00:00",
|
||||
"actor": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"actor": "https://instance.gnusocial.test/actor/42",
|
||||
"object": {
|
||||
"type": "Page",
|
||||
"id": "https://testv3.gnusocial.rocks/object/note/1338",
|
||||
"id": "https://instance.gnusocial.test/object/note/1338",
|
||||
"published": "2022-03-01T22:44:29+00:00",
|
||||
"attributedTo": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"attributedTo": "https://instance.gnusocial.test/actor/42",
|
||||
"name": "hello, world.",
|
||||
"content": "<p>This is an interesting page.</p>",
|
||||
"mediaType": "text/html",
|
||||
@ -36,20 +36,20 @@
|
||||
},
|
||||
"attachment": [],
|
||||
"tag": [],
|
||||
"inConversation": "https://testv3.gnusocial.rocks/conversation/1338",
|
||||
"inConversation": "https://instance.gnusocial.test/conversation/1338",
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"cc": [
|
||||
"https://testv3.gnusocial.rocks/actor/42/subscribers",
|
||||
"https://testv3.gnusocial.rocks/actor/21"
|
||||
"https://instance.gnusocial.test/actor/42/subscribers",
|
||||
"https://instance.gnusocial.test/actor/21"
|
||||
]
|
||||
},
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"cc": [
|
||||
"https://testv3.gnusocial.rocks/actor/42/subscribers",
|
||||
"https://testv3.gnusocial.rocks/actor/21"
|
||||
"https://instance.gnusocial.test/actor/42/subscribers",
|
||||
"https://instance.gnusocial.test/actor/21"
|
||||
]
|
||||
}
|
@ -19,14 +19,14 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "https://testv3.gnusocial.rocks/activity/1339",
|
||||
"id": "https://instance.gnusocial.test/activity/1339",
|
||||
"published": "2022-03-01T20:58:48+00:00",
|
||||
"actor": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"actor": "https://instance.gnusocial.test/actor/42",
|
||||
"object": {
|
||||
"type": "Note",
|
||||
"id": "https://testv3.gnusocial.rocks/object/note/1339",
|
||||
"id": "https://instance.gnusocial.test/object/note/1339",
|
||||
"published": "2022-03-01T21:00:16+00:00",
|
||||
"attributedTo": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"attributedTo": "https://instance.gnusocial.test/actor/42",
|
||||
"content": "<p>yay ^^</p>",
|
||||
"mediaType": "text/html",
|
||||
"source": {
|
||||
@ -35,19 +35,19 @@
|
||||
},
|
||||
"attachment": [],
|
||||
"tag": [],
|
||||
"inReplyTo": "https://testv3.gnusocial.rocks/object/note/1338",
|
||||
"inConversation": "https://testv3.gnusocial.rocks/conversation/1338",
|
||||
"inReplyTo": "https://instance.gnusocial.test/object/note/1338",
|
||||
"inConversation": "https://instance.gnusocial.test/conversation/1338",
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"cc": [
|
||||
"https://testv3.gnusocial.rocks/actor/42/subscribers"
|
||||
"https://instance.gnusocial.test/actor/42/subscribers"
|
||||
]
|
||||
},
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"cc": [
|
||||
"https://testv3.gnusocial.rocks/actor/42/subscribers"
|
||||
"https://instance.gnusocial.test/actor/42/subscribers"
|
||||
]
|
||||
}
|
@ -20,23 +20,23 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "https://testv3.gnusocial.rocks/actor/21",
|
||||
"inbox": "https://testv3.gnusocial.rocks/actor/21/inbox.json",
|
||||
"outbox": "https://testv3.gnusocial.rocks/actor/21/outbox.json",
|
||||
"following": "https://testv3.gnusocial.rocks/actor/21/subscriptions",
|
||||
"followers": "https://testv3.gnusocial.rocks/actor/21/subscribers",
|
||||
"liked": "https://testv3.gnusocial.rocks/actor/21/favourites",
|
||||
"id": "https://instance.gnusocial.test/actor/21",
|
||||
"inbox": "https://instance.gnusocial.test/actor/21/inbox.json",
|
||||
"outbox": "https://instance.gnusocial.test/actor/21/outbox.json",
|
||||
"following": "https://instance.gnusocial.test/actor/21/subscriptions",
|
||||
"followers": "https://instance.gnusocial.test/actor/21/subscribers",
|
||||
"liked": "https://instance.gnusocial.test/actor/21/favourites",
|
||||
"preferredUsername": "hackers",
|
||||
"publicKey": {
|
||||
"id": "https://testv3.gnusocial.rocks/actor/2#public-key",
|
||||
"owner": "https://testv3.gnusocial.rocks/actor/2",
|
||||
"id": "https://instance.gnusocial.test/actor/2#public-key",
|
||||
"owner": "https://instance.gnusocial.test/actor/2",
|
||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoZyKL+GyJbTV/ilVBlzz\n8OL/UwNi3KpfV5kQwXU0pPcBbw6y2JOfWnKUT1CfiHG3ntiOFnc+wQfHZk4hRSE8\n9Xe/G5Y215xW+gqx/kjt2GOENqzSzYXdEZ5Qsx6yumZD/yb6VZK9Og0HjX2mpRs9\nbactY76w4BQVntjZ17gSkMhYcyPFZTAIe7QDkeSPk5lkXfTwtaB3YcJSbQ3+s7La\npeEgukQDkrLUIP6cxayKrgUl4fhHdpx1Yk4Bzd/1XkZCjeBca94lP1p2M12amI+Z\nOLSTuLyEiCcku8aN+Ms9plwATmIDaGvKFVk0YVtBHdIJlYXV0yIscab3bqyhsLBK\njwIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||
},
|
||||
"name": "Hackers!",
|
||||
"published": "2022-02-23T21:54:52+00:00",
|
||||
"updated": "2022-02-23T21:55:16+00:00",
|
||||
"url": "https://testv3.gnusocial.rocks/!hackers",
|
||||
"url": "https://instance.gnusocial.test/!hackers",
|
||||
"endpoints": {
|
||||
"sharedInbox": "https://testv3.gnusocial.rocks/inbox.json"
|
||||
"sharedInbox": "https://instance.gnusocial.test/inbox.json"
|
||||
}
|
||||
}
|
@ -19,9 +19,9 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "https://testv3.gnusocial.rocks/object/note/1337",
|
||||
"id": "https://instance.gnusocial.test/object/note/1337",
|
||||
"published": "2022-03-10T23:07:50+00:00",
|
||||
"attributedTo": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"attributedTo": "https://instance.gnusocial.test/actor/42",
|
||||
"content": "<p>hello, world.</p>",
|
||||
"mediaType": "text/html",
|
||||
"source": {
|
||||
@ -30,11 +30,11 @@
|
||||
},
|
||||
"attachment": [],
|
||||
"tag": [],
|
||||
"inConversation": "https://testv3.gnusocial.rocks/conversation/1337",
|
||||
"inConversation": "https://instance.gnusocial.test/conversation/1337",
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"cc": [
|
||||
"https://testv3.gnusocial.rocks/actor/42/subscribers"
|
||||
"https://instance.gnusocial.test/actor/42/subscribers"
|
||||
]
|
||||
}
|
@ -19,9 +19,9 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "https://testv3.gnusocial.rocks/object/note/1338",
|
||||
"id": "https://instance.gnusocial.test/object/note/1338",
|
||||
"published": "2022-03-01T22:44:29+00:00",
|
||||
"attributedTo": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"attributedTo": "https://instance.gnusocial.test/actor/42",
|
||||
"name": "hello, world.",
|
||||
"content": "<p>This is an interesting page.</p>",
|
||||
"mediaType": "text/html",
|
||||
@ -31,12 +31,12 @@
|
||||
},
|
||||
"attachment": [],
|
||||
"tag": [],
|
||||
"inConversation": "https://testv3.gnusocial.rocks/conversation/1338",
|
||||
"inConversation": "https://instance.gnusocial.test/conversation/1338",
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"cc": [
|
||||
"https://testv3.gnusocial.rocks/actor/42/subscribers",
|
||||
"https://testv3.gnusocial.rocks/actor/21"
|
||||
"https://instance.gnusocial.test/actor/42/subscribers",
|
||||
"https://instance.gnusocial.test/actor/21"
|
||||
]
|
||||
}
|
@ -20,23 +20,23 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"inbox": "https://testv3.gnusocial.rocks/actor/42/inbox.json",
|
||||
"outbox": "https://testv3.gnusocial.rocks/actor/42/outbox.json",
|
||||
"following": "https://testv3.gnusocial.rocks/actor/42/subscriptions",
|
||||
"followers": "https://testv3.gnusocial.rocks/actor/42/subscribers",
|
||||
"liked": "https://testv3.gnusocial.rocks/actor/42/favourites",
|
||||
"id": "https://instance.gnusocial.test/actor/42",
|
||||
"inbox": "https://instance.gnusocial.test/actor/42/inbox.json",
|
||||
"outbox": "https://instance.gnusocial.test/actor/42/outbox.json",
|
||||
"following": "https://instance.gnusocial.test/actor/42/subscriptions",
|
||||
"followers": "https://instance.gnusocial.test/actor/42/subscribers",
|
||||
"liked": "https://instance.gnusocial.test/actor/42/favourites",
|
||||
"preferredUsername": "diogo",
|
||||
"publicKey": {
|
||||
"id": "https://testv3.gnusocial.rocks/actor/42#public-key",
|
||||
"owner": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"id": "https://instance.gnusocial.test/actor/42#public-key",
|
||||
"owner": "https://instance.gnusocial.test/actor/42",
|
||||
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArBB+3ldwA2qC1hQTtIho\n9KYhvvMlPdydn8dA6OlyIQ3Jy57ADt2e144jDSY5RQ3esmzWm2QqsI8rAsZsAraO\nl2+855y7Fw35WH4GBc7PJ6MLAEvMk1YWeS/rttXaDzh2i4n/AXkMuxDjS1IBqw2w\nn0qTz2sdGcBJ+mop6AB9Qt2lseBc5IW040jSnfLEDDIaYgoc5m2yRsjGKItOh3BG\njGHDb6JB9FySToSMGIt0/tE5k06wfvAxtkxX5dfGeKtciBpC2MGT169iyMIOM8DN\nFhSl8mowtV1NJQ7nN692USrmNvSJjqe9ugPCDPPvwQ5A6A61Qrgpz5pav/o5Sz69\nzQIDAQAB\n-----END PUBLIC KEY-----\n"
|
||||
},
|
||||
"name": "Diogo Peralta Cordeiro",
|
||||
"published": "2022-02-23T17:20:30+00:00",
|
||||
"updated": "2022-02-25T02:12:48+00:00",
|
||||
"url": "https://testv3.gnusocial.rocks/@diogo",
|
||||
"url": "https://instance.gnusocial.test/@diogo",
|
||||
"endpoints": {
|
||||
"sharedInbox": "https://testv3.gnusocial.rocks/inbox.json"
|
||||
"sharedInbox": "https://instance.gnusocial.test/inbox.json"
|
||||
}
|
||||
}
|
@ -19,9 +19,9 @@
|
||||
}
|
||||
}
|
||||
],
|
||||
"id": "https://testv3.gnusocial.rocks/object/note/1339",
|
||||
"id": "https://instance.gnusocial.test/object/note/1339",
|
||||
"published": "2022-03-01T21:00:16+00:00",
|
||||
"attributedTo": "https://testv3.gnusocial.rocks/actor/42",
|
||||
"attributedTo": "https://instance.gnusocial.test/actor/42",
|
||||
"content": "<p>yay ^^</p>",
|
||||
"mediaType": "text/html",
|
||||
"source": {
|
||||
@ -30,12 +30,12 @@
|
||||
},
|
||||
"attachment": [],
|
||||
"tag": [],
|
||||
"inReplyTo": "https://testv3.gnusocial.rocks/object/note/1338",
|
||||
"inConversation": "https://testv3.gnusocial.rocks/conversation/1338",
|
||||
"inReplyTo": "https://instance.gnusocial.test/object/note/1338",
|
||||
"inConversation": "https://instance.gnusocial.test/conversation/1338",
|
||||
"to": [
|
||||
"https://www.w3.org/ns/activitystreams#Public"
|
||||
],
|
||||
"cc": [
|
||||
"https://testv3.gnusocial.rocks/actor/42/subscribers"
|
||||
"https://instance.gnusocial.test/actor/42/subscribers"
|
||||
]
|
||||
}
|
@ -21,7 +21,7 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace Plugin\ActivityPub\tests\Objects;
|
||||
namespace Plugin\ActivityPub\Test\Objects;
|
||||
|
||||
use App\Entity\Actor;
|
||||
use App\Util\GNUsocialTestCase;
|
||||
@ -29,16 +29,18 @@ use Plugin\ActivityPub\Entity\ActivitypubActor;
|
||||
use Plugin\ActivityPub\Entity\ActivitypubRsa;
|
||||
use Plugin\ActivityPub\Util\Explorer;
|
||||
|
||||
class GSGroupTest extends GNUsocialTestCase
|
||||
class GSActorGroupTest extends GNUsocialTestCase
|
||||
{
|
||||
public function testGroupFromJson()
|
||||
{
|
||||
$group = Explorer::getOneFromUri('https://testv3.gnusocial.rocks/actor/21', try_online: false);
|
||||
self::bootKernel();
|
||||
|
||||
$group = Explorer::getOneFromUri('https://instance.gnusocial.test/actor/21', try_online: false);
|
||||
$ap_group = ActivitypubActor::getByPK(['actor_id' => $group->getId()]);
|
||||
static::assertSame('https://testv3.gnusocial.rocks/actor/21/inbox.json', $ap_group->getInboxUri());
|
||||
static::assertSame('https://testv3.gnusocial.rocks/inbox.json', $ap_group->getInboxSharedUri());
|
||||
static::assertSame('https://instance.gnusocial.test/actor/21/inbox.json', $ap_group->getInboxUri());
|
||||
static::assertSame('https://instance.gnusocial.test/inbox.json', $ap_group->getInboxSharedUri());
|
||||
$group = $ap_group->getActor();
|
||||
static::assertSame('https://testv3.gnusocial.rocks/actor/21', $group->getUri());
|
||||
static::assertSame('https://instance.gnusocial.test/actor/21', $group->getUri());
|
||||
static::assertSame(Actor::GROUP, $group->getType());
|
||||
static::assertSame('hackers', $group->getNickname());
|
||||
static::assertSame('Hackers!', $group->getFullname());
|
@ -21,7 +21,7 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace Plugin\ActivityPub\tests\Objects;
|
||||
namespace Plugin\ActivityPub\Test\Objects;
|
||||
|
||||
use App\Entity\Actor;
|
||||
use App\Util\GNUsocialTestCase;
|
||||
@ -29,16 +29,18 @@ use Plugin\ActivityPub\Entity\ActivitypubActor;
|
||||
use Plugin\ActivityPub\Entity\ActivitypubRsa;
|
||||
use Plugin\ActivityPub\Util\Explorer;
|
||||
|
||||
class GSPersonTest extends GNUsocialTestCase
|
||||
class GSActorPersonTest extends GNUsocialTestCase
|
||||
{
|
||||
public function testPersonFromJson()
|
||||
{
|
||||
$person = Explorer::getOneFromUri('https://testv3.gnusocial.rocks/actor/42', try_online: false);
|
||||
self::bootKernel();
|
||||
|
||||
$person = Explorer::getOneFromUri('https://instance.gnusocial.test/actor/42', try_online: false);
|
||||
$ap_person = ActivitypubActor::getByPK(['actor_id' => $person->getId()]);
|
||||
static::assertSame('https://testv3.gnusocial.rocks/actor/42/inbox.json', $ap_person->getInboxUri());
|
||||
static::assertSame('https://testv3.gnusocial.rocks/inbox.json', $ap_person->getInboxSharedUri());
|
||||
static::assertSame('https://instance.gnusocial.test/actor/42/inbox.json', $ap_person->getInboxUri());
|
||||
static::assertSame('https://instance.gnusocial.test/inbox.json', $ap_person->getInboxSharedUri());
|
||||
$person = $ap_person->getActor();
|
||||
static::assertSame('https://testv3.gnusocial.rocks/actor/42', $person->getUri());
|
||||
static::assertSame('https://instance.gnusocial.test/actor/42', $person->getUri());
|
||||
static::assertSame(Actor::PERSON, $person->getType());
|
||||
static::assertSame('diogo', $person->getNickname());
|
||||
static::assertSame('Diogo Peralta Cordeiro', $person->getFullname());
|
@ -188,7 +188,7 @@ class Note extends Model
|
||||
|
||||
$attention_targets = [];
|
||||
foreach ($to as $target) {
|
||||
if ($target === 'https://www.w3.org/ns/activitystreams#Public') {
|
||||
if (\in_array($target, ActivityPub::PUBLIC_TO)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
@ -217,7 +217,7 @@ class Note extends Model
|
||||
}
|
||||
|
||||
foreach ($cc as $target) {
|
||||
if ($target === 'https://www.w3.org/ns/activitystreams#Public') {
|
||||
if (\in_array($target, ActivityPub::PUBLIC_TO)) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
|
@ -1,53 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace Plugin\ActivityPub\Test\Fixtures;
|
||||
|
||||
use App\Core\DB\DB;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Plugin\ActivityPub\Util\Model\Activity;
|
||||
use Plugin\ActivityPub\Util\Model\Actor;
|
||||
use Plugin\ActivityPub\Util\Model\Note;
|
||||
|
||||
class ActivityPubFixtures extends Fixture
|
||||
{
|
||||
private static string $fixtures_path = INSTALLDIR . '/plugins/ActivityPub/tests/fixtures';
|
||||
|
||||
public static function fixturesPath(string $path, string $ontology = 'gnusocial'): string
|
||||
{
|
||||
return self::$fixtures_path . \DIRECTORY_SEPARATOR . $ontology . \DIRECTORY_SEPARATOR . $path;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
/*
|
||||
* Beware that it's important to Load Actors, Objects, Activities in this sequence
|
||||
* because we're running offline tests here.
|
||||
*/
|
||||
$ontology = 'gnusocial';
|
||||
|
||||
// Load Actors
|
||||
$person = Actor::fromJson(file_get_contents(self::fixturesPath('objects/person.jsonld', $ontology)));
|
||||
DB::flush();
|
||||
$group = Actor::fromJson(file_get_contents(self::fixturesPath('objects/group.jsonld', $ontology)));
|
||||
DB::flush();
|
||||
|
||||
// Load Objects
|
||||
$note = Note::fromJson(file_get_contents(self::fixturesPath('objects/note.jsonld', $ontology)));
|
||||
DB::flush();
|
||||
$page = Note::fromJson(file_get_contents(self::fixturesPath('objects/page.jsonld', $ontology)));
|
||||
DB::flush();
|
||||
$reply = Note::fromJson(file_get_contents(self::fixturesPath('objects/reply.jsonld', $ontology)));
|
||||
DB::flush();
|
||||
|
||||
// Load Activities
|
||||
$create_note = Activity::fromJson(file_get_contents(self::fixturesPath('activities/create_note.jsonld', $ontology)));
|
||||
DB::flush();
|
||||
$create_page = Activity::fromJson(file_get_contents(self::fixturesPath('activities/create_page.jsonld', $ontology)));
|
||||
DB::flush();
|
||||
$create_reply = Activity::fromJson(file_get_contents(self::fixturesPath('activities/create_reply.jsonld', $ontology)));
|
||||
DB::flush();
|
||||
}
|
||||
}
|
@ -196,6 +196,8 @@ abstract class Form
|
||||
}
|
||||
|
||||
DB::flush();
|
||||
} else {
|
||||
throw new ClientException('Invalid Form submitted.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,12 +36,14 @@ use App\Core\GNUsocial;
|
||||
use Functional as F;
|
||||
use ReflectionClass;
|
||||
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\TestContainer;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Symfony\Component\HttpKernel\KernelInterface;
|
||||
|
||||
class GNUsocialTestCase extends WebTestCase
|
||||
{
|
||||
private static GNUsocial $social;
|
||||
protected static TestContainer|null $container = null;
|
||||
|
||||
/**
|
||||
* Provide our own initialization for testing
|
||||
@ -62,10 +64,10 @@ class GNUsocialTestCase extends WebTestCase
|
||||
|
||||
private static function do_setup()
|
||||
{
|
||||
$container = self::$kernel->getContainer()->get('test.service_container');
|
||||
$services = F\map(
|
||||
static::$container = self::$kernel->getContainer()->get('test.service_container');
|
||||
$services = F\map(
|
||||
(new ReflectionClass(GNUsocial::class))->getMethod('__construct')->getParameters(),
|
||||
fn ($p) => $container->get((string) $p->getType()),
|
||||
fn ($p) => static::$container->get((string) $p->getType()),
|
||||
);
|
||||
self::$social = new GNUsocial(...$services);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
namespace App\Test\Controller;
|
||||
|
||||
use App\Core\DB\DB;
|
||||
use App\Entity\LocalUser;
|
||||
|
@ -21,7 +21,7 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
namespace App\Test\Controller;
|
||||
|
||||
use App\Util\GNUsocialTestCase;
|
||||
|
||||
|
@ -21,15 +21,15 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Core;
|
||||
namespace App\Test\Core;
|
||||
|
||||
use App\Core\Cache;
|
||||
use App\Util\Common;
|
||||
use App\Util\GNUsocialTestCase;
|
||||
use ReflectionClass;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
|
||||
|
||||
class CacheTest extends KernelTestCase
|
||||
class CacheTest extends GNUsocialTestCase
|
||||
{
|
||||
private function doTest(array $adapters, $result_pool, $throws = null, $recompute = \INF)
|
||||
{
|
||||
@ -38,7 +38,7 @@ class CacheTest extends KernelTestCase
|
||||
// Setup Common::config to have the values in $conf
|
||||
$conf = ['cache' => ['adapters' => $adapters, 'early_recompute' => $recompute]];
|
||||
$cb = $this->createMock(ContainerBagInterface::class);
|
||||
static::assertTrue($cb instanceof ContainerBagInterface);
|
||||
static::assertInstanceOf(ContainerBagInterface::class, $cb);
|
||||
$cb->method('get')
|
||||
->willReturnMap([['gnusocial', $conf], ['gnusocial_defaults', $conf]]);
|
||||
Common::setupConfig($cb);
|
||||
|
@ -21,7 +21,7 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Core;
|
||||
namespace App\Test\Core;
|
||||
|
||||
use App\Util\GNUsocialTestCase;
|
||||
use Jchook\AssertThrows\AssertThrows;
|
||||
|
@ -19,7 +19,7 @@ declare(strict_types = 1);
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Core\DB;
|
||||
namespace App\Test\Core\DB;
|
||||
|
||||
use App\Core\ActorLocalRoles;
|
||||
use App\Core\DB\DB;
|
||||
@ -66,7 +66,7 @@ class DBTest extends GNUsocialTestCase
|
||||
{
|
||||
static::bootKernel();
|
||||
$actor = DB::findOneBy('actor', ['nickname' => 'taken_user']);
|
||||
static::assertTrue($actor instanceof Actor);
|
||||
static::assertInstanceOf(Actor::class, $actor);
|
||||
|
||||
static::assertThrows(DuplicateFoundException::class, fn () => DB::findOneBy('actor', ['is_null' => 'bio']));
|
||||
static::assertThrows(NotFoundException::class, fn () => DB::findOneBy('actor', ['nickname' => 'nickname_not_in_use']));
|
||||
@ -86,6 +86,6 @@ class DBTest extends GNUsocialTestCase
|
||||
$id = DB::persistWithSameId($actor, $user, fn ($id) => $id);
|
||||
static::assertTrue($id != 0);
|
||||
static::assertTrue($actor->getId() == $id);
|
||||
static::assertTrue($user->getId() == $id);
|
||||
static::assertTrue($user->getId() == $id);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ declare(strict_types = 1);
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Core\DB;
|
||||
namespace App\Test\Core\DB;
|
||||
|
||||
use App\Core\DB\DB;
|
||||
use App\Core\DB\UpdateListener;
|
||||
|
@ -21,7 +21,7 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Core;
|
||||
namespace App\Test\Core;
|
||||
|
||||
use App\Core\DB\DB;
|
||||
use App\Entity\LocalUser;
|
||||
|
@ -21,7 +21,7 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Core;
|
||||
namespace App\Test\Core;
|
||||
|
||||
use App\Core\Event;
|
||||
use App\Util\GNUsocialTestCase;
|
||||
|
@ -21,7 +21,7 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Core;
|
||||
namespace App\Test\Core;
|
||||
|
||||
use App\Core\ActorLocalRoles;
|
||||
use App\Core\DB\DB;
|
||||
|
@ -21,7 +21,7 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Core;
|
||||
namespace App\Test\Core;
|
||||
|
||||
use App\Core\GSFile;
|
||||
use App\Util\GNUsocialTestCase;
|
||||
|
@ -19,15 +19,15 @@ declare(strict_types = 1);
|
||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Core\I18n;
|
||||
namespace App\Test\Core\I18n;
|
||||
|
||||
use function App\Core\I18n\_m;
|
||||
use App\Core\I18n\I18n;
|
||||
use App\Util\GNUsocialTestCase;
|
||||
use InvalidArgumentException;
|
||||
use Jchook\AssertThrows\AssertThrows;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
class I18nTest extends KernelTestCase
|
||||
class I18nTest extends GNUsocialTestCase
|
||||
{
|
||||
use AssertThrows;
|
||||
|
||||
|
@ -21,7 +21,7 @@ declare(strict_types = 1);
|
||||
|
||||
// }}}
|
||||
|
||||
namespace App\Tests\Core;
|
||||
namespace App\Test\Core;
|
||||
|
||||
use App\Core\Router\RouteLoader;
|
||||
use App\Core\Router\Router;
|
||||
|
4
tests/fixtures/CoreFixtures.php
vendored
4
tests/fixtures/CoreFixtures.php
vendored
@ -109,10 +109,10 @@ class CoreFixtures extends Fixture
|
||||
$manager->persist(Notification::create(['activity_id' => $activity->getId(), 'target_id' => $local_entities['taken_private_group']->getActorId(), 'reason' => 'testing']));
|
||||
}
|
||||
|
||||
$manager->persist(Attention::create(['note_id' => $public_group_note->getId(), 'target_id' => $local_entities['taken_public_group']->getActorId()]));
|
||||
$manager->persist(Attention::create(['object_type' => Note::schemaName(), 'object_id' => $public_group_note->getId(), 'target_id' => $local_entities['taken_public_group']->getActorId()]));
|
||||
|
||||
$manager->persist(GroupMember::create(['group_id' => $local_entities['taken_private_group']->getActorId(), 'actor_id' => $actors['some_user']->getId()]));
|
||||
$manager->persist(Attention::create(['note_id' => $private_group_note->getId(), 'target_id' => $local_entities['taken_private_group']->getActorId()]));
|
||||
$manager->persist(Attention::create(['object_type' => Note::schemaName(), 'object_id' => $private_group_note->getId(), 'target_id' => $local_entities['taken_private_group']->getActorId()]));
|
||||
|
||||
$manager->flush();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user