54 lines
2.0 KiB
PHP
54 lines
2.0 KiB
PHP
<?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();
|
|
}
|
|
}
|