[PLUGIN][ActivityPub][TESTS] Move ActivityPub test fixtures to new facility

This commit is contained in:
Hugo Sales 2022-03-13 18:11:11 +00:00
parent 1d8bba3949
commit cbae649991
No known key found for this signature in database
GPG Key ID: 7D0C7EAFC9D835A0
3 changed files with 10 additions and 18 deletions

View File

@ -24,12 +24,12 @@ declare(strict_types = 1);
namespace Plugin\ActivityPub\tests\Objects;
use App\Entity\Actor;
use App\Util\GNUsocialTestCase;
use Plugin\ActivityPub\Entity\ActivitypubActor;
use Plugin\ActivityPub\Entity\ActivitypubRsa;
use Plugin\ActivityPub\tests\ActivityPubTestCase;
use Plugin\ActivityPub\Util\Explorer;
class GSGroupTest extends ActivityPubTestCase
class GSGroupTest extends GNUsocialTestCase
{
public function testGroupFromJson()
{

View File

@ -24,12 +24,12 @@ declare(strict_types = 1);
namespace Plugin\ActivityPub\tests\Objects;
use App\Entity\Actor;
use App\Util\GNUsocialTestCase;
use Plugin\ActivityPub\Entity\ActivitypubActor;
use Plugin\ActivityPub\Entity\ActivitypubRsa;
use Plugin\ActivityPub\tests\ActivityPubTestCase;
use Plugin\ActivityPub\Util\Explorer;
class GSPersonTest extends ActivityPubTestCase
class GSPersonTest extends GNUsocialTestCase
{
public function testPersonFromJson()
{

View File

@ -2,17 +2,17 @@
declare(strict_types = 1);
namespace Plugin\ActivityPub\tests;
namespace Plugin\ActivityPub\Test\Fixtures;
use App\Core\DB\DB;
use App\Util\GNUsocialTestCase;
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 ActivityPubTestCase extends GNUsocialTestCase
class ActivityPubFixtures extends Fixture
{
private static bool $loaded_fixtures = false;
private static string $fixtures_path = INSTALLDIR . '/plugins/ActivityPub/tests/fixtures';
public static function fixturesPath(string $path, string $ontology = 'gnusocial'): string
@ -20,21 +20,13 @@ class ActivityPubTestCase extends GNUsocialTestCase
return self::$fixtures_path . \DIRECTORY_SEPARATOR . $ontology . \DIRECTORY_SEPARATOR . $path;
}
public static function setUpBeforeClass(): void
{
static::bootKernel();
if (!static::$loaded_fixtures) {
static::loadFixtures();
}
static::$loaded_fixtures = true;
}
public static function loadFixtures(string $ontology = 'gnusocial'): void
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)));