diff --git a/composer.json b/composer.json index fdb4e39520..8fccee686b 100644 --- a/composer.json +++ b/composer.json @@ -90,6 +90,7 @@ "autoload": { "psr-4": { "EonX\\EasyActivity\\": "packages/EasyActivity/src", + "EonX\\EasyActivity\\Bundle\\": "packages/EasyActivity/bundle", "EonX\\EasyApiPlatform\\": "packages/EasyApiPlatform/src", "EonX\\EasyApiPlatform\\Bundle\\": "packages/EasyApiPlatform/bundle", "EonX\\EasyApiToken\\": "packages/EasyApiToken/src", @@ -127,7 +128,8 @@ "autoload-dev": { "psr-4": { "EonX\\EasyActivity\\Tests\\": "packages/EasyActivity/tests", - "EonX\\EasyActivity\\Tests\\Bridge\\Symfony\\Fixtures\\App\\": "packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/src", + "EonX\\EasyActivity\\Tests\\Fixture\\App\\": "packages/EasyActivity/tests/Fixture/app/src", + "EonX\\EasyActivity\\Tests\\Unit\\": "packages/EasyActivity/tests/Unit/src", "EonX\\EasyApiPlatform\\Tests\\": "packages/EasyApiPlatform/tests", "EonX\\EasyApiPlatform\\Tests\\Application\\": "packages/EasyApiPlatform/tests/Application/src", "EonX\\EasyApiPlatform\\Tests\\Fixture\\App\\": "packages/EasyApiPlatform/tests/Fixture/app/src", diff --git a/packages/EasyActivity/src/Bridge/Symfony/EasyActivitySymfonyBundle.php b/packages/EasyActivity/bundle/EasyActivityBundle.php similarity index 70% rename from packages/EasyActivity/src/Bridge/Symfony/EasyActivitySymfonyBundle.php rename to packages/EasyActivity/bundle/EasyActivityBundle.php index 180cc2eded..b38d317918 100644 --- a/packages/EasyActivity/src/Bridge/Symfony/EasyActivitySymfonyBundle.php +++ b/packages/EasyActivity/bundle/EasyActivityBundle.php @@ -1,9 +1,9 @@ BridgeConstantsInterface::PARAM_DISALLOWED_PROPERTIES, - 'easy_doctrine_subscriber_enabled' => BridgeConstantsInterface::PARAM_EASY_DOCTRINE_SUBSCRIBER_ENABLED, - 'subjects' => BridgeConstantsInterface::PARAM_SUBJECTS, - 'table_name' => BridgeConstantsInterface::PARAM_TABLE_NAME, + 'disallowed_properties' => ConfigParam::DisallowedProperties, + 'easy_doctrine_subscriber_enabled' => ConfigParam::EasyDoctrineSubscriberEnabled, + 'subjects' => ConfigParam::Subjects, + 'table_name' => ConfigParam::TableName, ]; - protected string $extensionAlias = 'easy_activity'; - - public function __construct() - { - $this->path = \realpath(__DIR__); - } - public function configure(DefinitionConfigurator $definition): void { - $definition->import(__DIR__ . '/Resources/config/definition.php'); + $definition->import(__DIR__ . '/config/definition.php'); } public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void @@ -37,13 +30,13 @@ public function loadExtension(array $config, ContainerConfigurator $container, C foreach (self::EASY_ACTIVITY_CONFIG as $name => $param) { $container ->parameters() - ->set($param, $config[$name]); + ->set($param->value, $config[$name]); } - $container->import(__DIR__ . '/Resources/config/services.php'); + $container->import(__DIR__ . '/config/services.php'); if ($this->easyDoctrineBundleIsRegistered($builder)) { - $container->import(__DIR__ . '/Resources/config/easy-doctrine-bridge-services.php'); + $container->import(__DIR__ . '/config/easy-doctrine-bridge-services.php'); } } diff --git a/packages/EasyActivity/bundle/Enum/ConfigParam.php b/packages/EasyActivity/bundle/Enum/ConfigParam.php new file mode 100644 index 0000000000..e305b59819 --- /dev/null +++ b/packages/EasyActivity/bundle/Enum/ConfigParam.php @@ -0,0 +1,15 @@ +services(); @@ -15,6 +15,6 @@ $services ->set(EasyDoctrineEntityEventsSubscriberInterface::class, EasyDoctrineEntityEventsSubscriber::class) - ->arg('$enabled', '%' . BridgeConstantsInterface::PARAM_EASY_DOCTRINE_SUBSCRIBER_ENABLED . '%') + ->arg('$enabled', param(ConfigParam::EasyDoctrineSubscriberEnabled->value)) ->tag('kernel.event_subscriber'); }; diff --git a/packages/EasyActivity/bundle/config/services.php b/packages/EasyActivity/bundle/config/services.php new file mode 100644 index 0000000000..3f114201c7 --- /dev/null +++ b/packages/EasyActivity/bundle/config/services.php @@ -0,0 +1,74 @@ +services(); + $services->defaults() + ->autowire() + ->autoconfigure(); + + $services + ->set(StoreInterface::class, DoctrineDbalStore::class) + ->arg('$table', param(ConfigParam::TableName->value)); + + $services + ->set(IdFactoryInterface::class, UuidFactory::class); + + $services + ->set(ActorResolverInterface::class, DefaultActorResolver::class); + + $services + ->set(ActivitySubjectResolverInterface::class, DefaultActivitySubjectResolver::class) + ->arg('$subjects', param(ConfigParam::Subjects->value)); + + $services + ->set(ActivitySubjectDataResolverInterface::class, DoctrineActivitySubjectDataResolver::class); + + $services + ->set(ActivityLoggerInterface::class, AsyncActivityLogger::class); + + $services + ->alias(ConfigServiceId::Serializer->value, 'serializer'); + + $services->set(ConfigServiceId::CircularReferenceHandler->value, CircularReferenceHandler::class); + + $services + ->set(ActivitySubjectDataSerializerInterface::class, SymfonyActivitySubjectDataSerializer::class) + ->arg('$serializer', service(ConfigServiceId::Serializer->value)) + ->arg('$circularReferenceHandler', service(ConfigServiceId::CircularReferenceHandler->value)) + ->arg('$disallowedProperties', param(ConfigParam::DisallowedProperties->value)); + + $services + ->set(ActivityLogEntryFactoryInterface::class, ActivityLogEntryFactory::class); + + $services + ->set(ActivityLogEntryMessageHandler::class); + + $services + ->set(AsyncDispatcherInterface::class, AsyncDispatcher::class); +}; diff --git a/packages/EasyActivity/composer.json b/packages/EasyActivity/composer.json index 6cb7a4ece9..c68c03bf13 100644 --- a/packages/EasyActivity/composer.json +++ b/packages/EasyActivity/composer.json @@ -4,53 +4,39 @@ "type": "library", "license": "MIT", "require": { - "doctrine/common": "^3.0", - "nesbot/carbon": "^2.67", "php": "^8.1", - "symfony/serializer": "^6.4" - }, - "require-dev": { "doctrine/dbal": "^3.0", - "doctrine/doctrine-bundle": "^2.8", "doctrine/orm": "^2.14", - "doctrine/persistence": "^3.0", "eonx-com/easy-doctrine": "^5.12", - "eonx-com/easy-event-dispatcher": "^5.12", "eonx-com/easy-lock": "^5.12", + "nesbot/carbon": "^2.67", + "symfony/config": "^6.4", + "symfony/dependency-injection": "^6.4", + "symfony/event-dispatcher": "^6.4", + "symfony/http-kernel": "^6.4", + "symfony/messenger": "^6.4", + "symfony/serializer": "^6.4", + "symfony/uid": "^6.4" + }, + "require-dev": { + "doctrine/doctrine-bundle": "^2.8", "eonx-com/easy-test": "^5.12", - "eonx-com/easy-webhook": "^5.12", "phpunit/phpunit": "^10.2", - "psr/log": "^3.0", - "symfony/amazon-sqs-messenger": "^6.4", - "symfony/doctrine-bridge": "^6.4", - "symfony/framework-bundle": "^6.4", - "symfony/monolog-bundle": "^3.8", - "symfony/uid": "^6.4" + "symfony/framework-bundle": "^6.4" }, "autoload": { "psr-4": { - "EonX\\EasyActivity\\": "src" + "EonX\\EasyActivity\\": "src", + "EonX\\EasyActivity\\Bundle\\": "bundle" } }, "autoload-dev": { "psr-4": { "EonX\\EasyActivity\\Tests\\": "tests", - "EonX\\EasyActivity\\Tests\\Bridge\\Symfony\\Fixtures\\App\\": "tests/Bridge/Symfony/Fixtures/app/src" + "EonX\\EasyActivity\\Tests\\Fixture\\App\\": "tests/Fixture/app/src", + "EonX\\EasyActivity\\Tests\\Unit\\": "tests/Unit/src" } }, - "suggest": { - "doctrine/dbal": "To save log entities to a database", - "doctrine/orm": "To save log entities to a database", - "eonx-com/easy-doctrine": "To create log entries from Doctrine events", - "eonx-com/easy-lock": "To lock async messages", - "symfony/config": "To use this package with Symfony", - "symfony/dependency-injection": "To use this package with Symfony", - "symfony/event-dispatcher": "To subscribe to EasyDoctrine events", - "symfony/http-kernel": "To use this package with Symfony", - "symfony/messenger": "To use this package with Symfony", - "symfony/serializer": "To use this package with Symfony", - "symfony/uid": "To use this package with Symfony" - }, "extra": { "branch-alias": { "dev-master": "5.12-dev" diff --git a/packages/EasyActivity/docs/activity-log-entry.md b/packages/EasyActivity/docs/activity-log-entry.md index 330a8e6cbf..4e9f3f19ea 100644 --- a/packages/EasyActivity/docs/activity-log-entry.md +++ b/packages/EasyActivity/docs/activity-log-entry.md @@ -5,16 +5,16 @@ weight: 1003 # ActivityLogEntry class -The `EonX\EasyActivity\ActivityLogEntry` class defines the data that can be recorded in an activity log entry. +The `EonX\EasyActivity\Common\Entity\ActivityLogEntry` class defines the data that can be recorded in an activity log entry. ## Properties An ActivityLogEntry object has the following properties: - `action`: The type of action performed on the subject, which may be one of: - - `ActivityLogEntry::ACTION_CREATE` (i.e. `create`): Create subject - - `ActivityLogEntry::ACTION_DELETE` (i.e. `delete`): Delete subject - - `ActivityLogEntry::ACTION_UPDATE` (i.e. `update`): Update subject + - `ActivityLogEntry::ACTION_CREATE` (i.e. `create`): Create subject + - `ActivityLogEntry::ACTION_DELETE` (i.e. `delete`): Delete subject + - `ActivityLogEntry::ACTION_UPDATE` (i.e. `update`): Update subject - `actorId`: An optional identifier for an actor in the application. - `actorName`: An optional name for an actor in the application. - `actorType`: A mandatory actor type. The actor type could be a `user`, `provider`, `customer`, `jwt:provider`, @@ -35,9 +35,10 @@ An ActivityLogEntry object has the following properties: ## ActivityLogEntry creation -The package provides `EonX\EasyActivity\Interfaces\ActivityLogEntryFactoryInterface` that takes care of activity log -entry creation. A default implementation `EonX\EasyActivity\ActivityLogEntryFactory` is also provided by the package. +The package provides `EonX\EasyActivity\Common\Factory\ActivityLogEntryFactoryInterface` that takes care of activity log +entry creation. A default implementation `EonX\EasyActivity\Common\Factory\ActivityLogEntryFactory` is also provided by the package. See [Usage][2] for more information on using the package. [1]: config.md + [2]: usage.md diff --git a/packages/EasyActivity/docs/config.md b/packages/EasyActivity/docs/config.md index 7a943a99fa..e969e45285 100644 --- a/packages/EasyActivity/docs/config.md +++ b/packages/EasyActivity/docs/config.md @@ -37,24 +37,39 @@ The configuration options are as follows: ## Example configuration file -In Symfony, you could have a configuration file called `easy_activity.yaml` that looks like the following: - -```yaml -easy_activity: - disallowed_properties: - - updatedAt - subjects: - App\Entity\SomeEntity: - allowed_properties: - - content - - description - disallowed_properties: - - author - nested_object_allowed_properties: - App\Entity\SomeOtherEntity: - - processingDate - type: SomeEntity - table_name: activity_logs -``` +In Symfony, you could have a configuration file called `easy_activity.php` that looks like the following: + +```php +tableName('activity_logs') + ->disallowedProperties([ + 'updatedAt', + ]); + + $easyActivityConfig->subjects(SomeEntity::class) + ->allowedProperties([ + 'content', + 'description', + ]) + ->disallowedProperties([ + 'author', + ]) + ->nestedObjectAllowedProperties([ + SomeOtherEntity::class => [ + 'processingDate', + ] + ]) + ->type('SomeEntity'); +}; + +``` diff --git a/packages/EasyActivity/docs/install.md b/packages/EasyActivity/docs/install.md index 745e087d89..92abb6b965 100644 --- a/packages/EasyActivity/docs/install.md +++ b/packages/EasyActivity/docs/install.md @@ -25,7 +25,7 @@ If you're using [Symfony Flex][2], this step has been done automatically for you return [ // Other bundles ... - EonX\EasyActivity\Bridge\Symfony\EasyActivitySymfonyBundle::class => ['all' => true], + EonX\EasyActivity\Bundle\EasyActivityBundle::class => ['all' => true], ]; ``` @@ -39,7 +39,11 @@ following packages for the following purposes: - [symfony/messenger][5]: to store entries asynchronously [1]: https://getcomposer.org/ + [2]: https://flex.symfony.com/ + [3]: https://github.com/eonx-com/easy-doctrine + [4]: https://github.com/symfony/serializer + [5]: https://github.com/symfony/messenger diff --git a/packages/EasyActivity/docs/usage.md b/packages/EasyActivity/docs/usage.md index 4d393b6a46..f9f002bc80 100644 --- a/packages/EasyActivity/docs/usage.md +++ b/packages/EasyActivity/docs/usage.md @@ -10,24 +10,24 @@ as database records in the `easy_activity_logs` table by default (the table name [configuration][1]). See the [ActivityLogEntry class][2] for more information on what can be stored in the database record. -An application can either use `EonX\EasyActivity\Bridge\Doctrine\DoctrineDbalStatementsProvider` to create a table or +An application can either use `EonX\EasyActivity\Doctrine\Provider\DoctrineDbalStatementsProvider` to create a table or describe a database entity/model relying on this table by itself. ## Resolving actors To resolve an actor's identifier, name and type, the package relies on -`EonX\EasyActivity\Interfaces\ActorResolverInterface`. +`EonX\EasyActivity\Common\Resolver\ActorResolverInterface`. -Although a default implementation is provided by the package (`EonX\EasyActivity\Resolvers\DefaultActorResolver`), it +Although a default implementation is provided by the package (`EonX\EasyActivity\Common\Resolver\DefaultActorResolver`), it only sets the actor's type to the default (`system`), so your application should register its own implementation of the interface to provide the required values (e.g. from a Security Context). ## Resolving subjects To resolve a subject's identifier, type, data and old data, the package relies on -`EonX\EasyActivity\Interfaces\ActivitySubjectResolverInterface`. +`EonX\EasyActivity\Common\Resolver\ActivitySubjectResolverInterface`. -The package provides a default implementation (`EonX\EasyActivity\Resolvers\DefaultActivitySubjectResolver`), but you +The package provides a default implementation (`EonX\EasyActivity\Common\Resolver\DefaultActivitySubjectResolver`), but you can implement your own instead. ## Creating activity log entries @@ -36,39 +36,42 @@ To create a new activity log entry, an application can use one of the following - **EasyDoctrine**: Install the [eonx-com/easy-doctrine][3] package that provides events for Doctrine entity creation, update and deletion. EasyActivity has a bridge for EasyDoctrine that contains - `EonX\EasyActivity\Bridge\EasyDoctrine\EasyDoctrineEntityEventsSubscriber`, which will take care of accepting those - events and passing them to `EonX\EasyActivity\Interfaces\ActivityLogEntryFactoryInterface`. The bridge also passes the + `EonX\EasyActivity\EasyDoctrine\Subscriber\EasyDoctrineEntityEventsSubscriber`, which will take care of accepting those + events and passing them to `EonX\EasyActivity\Common\Factory\ActivityLogEntryFactoryInterface`. The bridge also passes the subject list from the EasyActivity configuration to the EasyDoctrine configuration (so the EasyDoctrine knows which Doctrine entities to listen to). - **Eloquent**: Use an Eloquent bridge with a listener for Eloquent events that will take care of passing model data to - `EonX\EasyActivity\Interfaces\ActivityLogEntryFactoryInterface` (not implemented yet). + `EonX\EasyActivity\Common\Factory\ActivityLogEntryFactoryInterface` (not implemented yet). - **Manual creation**: Create activity log entries manually using - `EonX\EasyActivity\Interfaces\ActivityLogEntryFactoryInterface`, with either the default - `EonX\EasyActivity\ActivityLogEntryFactory` implementation or your own implementation registered for the interface. + `EonX\EasyActivity\Common\Factory\ActivityLogEntryFactoryInterface`, with either the default + `EonX\EasyActivity\Common\Factory\ActivityLogEntryFactory` implementation or your own implementation registered for the interface. -To save a new activity log entry the package relies on `EonX\EasyActivity\Interfaces\ActivityLoggerInterface`. An +To save a new activity log entry the package relies on `EonX\EasyActivity\Common\Logger\ActivityLoggerInterface`. An application can register its own implementation or use one of the following: -- `EonX\EasyActivity\Logger\AsyncActivityLogger` to save an activity log entry asynchronously (this is the default) -- `EonX\EasyActivity\Logger\SyncActivityLogger` to save an activity log entry synchronously +- `EonX\EasyActivity\Common\Logger\AsyncActivityLogger` to save an activity log entry asynchronously (this is the default) +- `EonX\EasyActivity\Common\Logger\SyncActivityLogger` to save an activity log entry synchronously ## Symfony bridge The Symfony bridge provided with this package allows it to be integrated into a Symfony-based application. Besides Symfony bundle/extension classes, it brings the following functionality: -- The default implementation for `EonX\EasyActivity\Interfaces\ActivitySubjectDataSerializerInterface`: - `EonX\EasyActivity\Bridge\Symfony\Serializers\SymfonyActivitySubjectDataSerializer`, which is a simple wrapper for +- The default implementation for `EonX\EasyActivity\Common\Serializer\ActivitySubjectDataSerializerInterface`: + `EonX\EasyActivity\Common\Serializer\SymfonyActivitySubjectDataSerializer`, which is a simple wrapper for `Symfony\Component\Serializer\SerializerInterface` used to serialize activity log entry data. Please note that all the nested objects are serialized as an array containing only the `id` key by default. You can change the default behaviour with the `nested_object_allowed_properties` configuration option (see [Configuration][4]). - The Symfony Messenger classes that are used for asynchronous activity log entry storing. -- The default implementation for `EonX\EasyActivity\Interfaces\StoreInterface`: - `EonX\EasyActivity\Bridge\Doctrine\DoctrineDbalStore`, which stores the activity log entries using a DBAL connection. +- The default implementation for `EonX\EasyActivity\Common\Store\StoreInterface`: + `EonX\EasyActivity\Doctrine\Store\DoctrineDbalStore`, which stores the activity log entries using a DBAL connection. An application can register its own implementation for this interface to be able to store activity log entries in a different way or using different storage. [1]: config.md + [2]: activity-log-entry.md + [3]: https://github.com/eonx-com/easy-doctrine + [4]: config.md diff --git a/packages/EasyActivity/src/Bridge/BridgeConstantsInterface.php b/packages/EasyActivity/src/Bridge/BridgeConstantsInterface.php deleted file mode 100644 index c8683889a4..0000000000 --- a/packages/EasyActivity/src/Bridge/BridgeConstantsInterface.php +++ /dev/null @@ -1,19 +0,0 @@ -services(); - $services->defaults() - ->autowire() - ->autoconfigure(); - - $services - ->set(StoreInterface::class, DoctrineDbalStore::class) - ->arg('$table', '%' . BridgeConstantsInterface::PARAM_TABLE_NAME . '%'); - - $services - ->set(IdFactoryInterface::class, UuidFactory::class); - - $services - ->set(ActorResolverInterface::class, DefaultActorResolver::class); - - $services - ->set(ActivitySubjectResolverInterface::class, DefaultActivitySubjectResolver::class) - ->arg('$subjects', '%' . BridgeConstantsInterface::PARAM_SUBJECTS . '%'); - - $services - ->set(ActivitySubjectDataResolverInterface::class, DoctrineActivitySubjectDataResolver::class); - - $services - ->set(ActivityLoggerInterface::class, AsyncActivityLogger::class); - - $services - ->alias(BridgeConstantsInterface::SERVICE_SERIALIZER, 'serializer'); - - $services->set(BridgeConstantsInterface::SERVICE_CIRCULAR_REFERENCE_HANDLER, CircularReferenceHandler::class); - - $services - ->set(ActivitySubjectDataSerializerInterface::class, SymfonyActivitySubjectDataSerializer::class) - ->arg('$serializer', service(BridgeConstantsInterface::SERVICE_SERIALIZER)) - ->arg('$circularReferenceHandler', service(BridgeConstantsInterface::SERVICE_CIRCULAR_REFERENCE_HANDLER)) - ->arg('$disallowedProperties', '%' . BridgeConstantsInterface::PARAM_DISALLOWED_PROPERTIES . '%'); - - $services - ->set(ActivityLogEntryFactoryInterface::class, ActivityLogEntryFactory::class); - - $services - ->set(ActivityLogEntryMessageHandler::class); - - $services - ->set(AsyncDispatcherInterface::class, AsyncDispatcher::class); -}; diff --git a/packages/EasyActivity/src/Bridge/Symfony/Serializers/CircularReferenceHandler.php b/packages/EasyActivity/src/Common/CircularReferenceHandler/CircularReferenceHandler.php similarity index 93% rename from packages/EasyActivity/src/Bridge/Symfony/Serializers/CircularReferenceHandler.php rename to packages/EasyActivity/src/Common/CircularReferenceHandler/CircularReferenceHandler.php index db2e865a19..0043e31b51 100644 --- a/packages/EasyActivity/src/Bridge/Symfony/Serializers/CircularReferenceHandler.php +++ b/packages/EasyActivity/src/Common/CircularReferenceHandler/CircularReferenceHandler.php @@ -1,7 +1,7 @@ 'custom_activity_subject_data_resolver']); - $author = new Author(); - $author->setId((string)(new NilUuid())); - $sut = self::getService(ActivityLogEntryFactoryInterface::class); - - $result = $sut->create( - ActivityLogEntry::ACTION_UPDATE, - $author, - ['field' => [1, 2]] - ); - - self::assertNotNull($result); - self::assertSame('a:1:{s:5:"field";i:1;}', $result->getSubjectData()); - self::assertSame('a:1:{s:5:"field";i:2;}', $result->getSubjectOldData()); - } - - public function testCreateSucceedsWithObjectThatImplementsSubjectInterface(): void - { - $subjectId = 'subject-id'; - $subjectType = 'subject-type'; - $activityLogEntity = new ActivityLogEntity($subjectId, $subjectType, ['field1']); - $sut = self::getService(ActivityLogEntryFactoryInterface::class); - - $result = $sut->create( - ActivityLogEntry::ACTION_UPDATE, - $activityLogEntity, - [ - 'field1' => [1, 2], - 'field2' => [2, 3], - ] - ); - - self::assertNotNull($result); - self::assertSame($subjectId, $result->getSubjectId()); - self::assertSame($subjectType, $result->getSubjectType()); - self::assertSame('{"field1":2}', $result->getSubjectData()); - self::assertSame('{"field1":1}', $result->getSubjectOldData()); - } -} diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_subject_type/easy_activity.php b/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_subject_type/easy_activity.php deleted file mode 100644 index 415a22ecc2..0000000000 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_subject_type/easy_activity.php +++ /dev/null @@ -1,17 +0,0 @@ -subjects(Article::class) - ->type('article'); -}; diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/default_subject_config/easy_activity.php b/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/default_subject_config/easy_activity.php deleted file mode 100644 index 652c1fad48..0000000000 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/default_subject_config/easy_activity.php +++ /dev/null @@ -1,17 +0,0 @@ -subjects(Article::class); -}; diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Serializers/CircularReferenceHandlerTest.php b/packages/EasyActivity/tests/Bridge/Symfony/Serializers/CircularReferenceHandlerTest.php deleted file mode 100644 index 2af4268a85..0000000000 --- a/packages/EasyActivity/tests/Bridge/Symfony/Serializers/CircularReferenceHandlerTest.php +++ /dev/null @@ -1,38 +0,0 @@ -setId((string)(new NilUuid())); - /** @var \EonX\EasyActivity\Bridge\Symfony\Serializers\CircularReferenceHandlerInterface $sut */ - $sut = self::getService(BridgeConstantsInterface::SERVICE_CIRCULAR_REFERENCE_HANDLER); - - $result = $sut($article, 'json', []); - - self::assertSame( - Article::class . '#00000000-0000-0000-0000-000000000000 (circular reference)', - $result - ); - } - - public function testInvokeSucceedsWithoutId(): void - { - $object = new stdClass(); - /** @var \EonX\EasyActivity\Bridge\Symfony\Serializers\CircularReferenceHandlerInterface $sut */ - $sut = self::getService(BridgeConstantsInterface::SERVICE_CIRCULAR_REFERENCE_HANDLER); - - $result = $sut($object, 'json', []); - - self::assertSame('stdClass (circular reference)', $result); - } -} diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/bundles.php b/packages/EasyActivity/tests/Fixture/app/config/bundles.php similarity index 84% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/bundles.php rename to packages/EasyActivity/tests/Fixture/app/config/bundles.php index c60549093d..32e5f6e7ad 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/bundles.php +++ b/packages/EasyActivity/tests/Fixture/app/config/bundles.php @@ -2,13 +2,13 @@ declare(strict_types=1); use Doctrine\Bundle\DoctrineBundle\DoctrineBundle; -use EonX\EasyActivity\Bridge\Symfony\EasyActivitySymfonyBundle; +use EonX\EasyActivity\Bundle\EasyActivityBundle; use EonX\EasyDoctrine\Bridge\Symfony\EasyDoctrineSymfonyBundle; use EonX\EasyEventDispatcher\Bridge\Symfony\EasyEventDispatcherSymfonyBundle; use Symfony\Bundle\FrameworkBundle\FrameworkBundle; return [ - EasyActivitySymfonyBundle::class => [ + EasyActivityBundle::class => [ 'all' => true, ], EasyEventDispatcherSymfonyBundle::class => [ diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/all_properties_are_disallowed/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/all_properties_are_disallowed/easy_activity.php similarity index 70% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/all_properties_are_disallowed/easy_activity.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/all_properties_are_disallowed/easy_activity.php index 9d60578971..b389b5abc1 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/all_properties_are_disallowed/easy_activity.php +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/all_properties_are_disallowed/easy_activity.php @@ -3,11 +3,11 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Article; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Article; use Symfony\Config\EasyActivityConfig; /** - * @see \EonX\EasyActivity\Tests\Bridge\EasyDoctrine\EasyDoctrineEntityEventsSubscriberTest::provideProperties + * @see \EonX\EasyActivity\Tests\Unit\EasyDoctrine\Subscriber\EasyDoctrineEntityEventsSubscriberTest::provideProperties */ return static function (EasyActivityConfig $easyActivityConfig): void { $easyActivityConfig->subjects(Article::class) diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/allowed_and_disallowed_properties_intersection/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/allowed_and_disallowed_properties_intersection/easy_activity.php similarity index 70% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/allowed_and_disallowed_properties_intersection/easy_activity.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/allowed_and_disallowed_properties_intersection/easy_activity.php index 5d2fafe286..88afa5fb8f 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/allowed_and_disallowed_properties_intersection/easy_activity.php +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/allowed_and_disallowed_properties_intersection/easy_activity.php @@ -3,11 +3,11 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Article; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Article; use Symfony\Config\EasyActivityConfig; /** - * @see \EonX\EasyActivity\Tests\Bridge\EasyDoctrine\EasyDoctrineEntityEventsSubscriberTest::provideProperties + * @see \EonX\EasyActivity\Tests\Unit\EasyDoctrine\Subscriber\EasyDoctrineEntityEventsSubscriberTest::provideProperties */ return static function (EasyActivityConfig $easyActivityConfig): void { $easyActivityConfig->subjects(Article::class) diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_activity_subject_data_resolver/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/custom_activity_subject_data_resolver/easy_activity.php similarity index 59% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_activity_subject_data_resolver/easy_activity.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/custom_activity_subject_data_resolver/easy_activity.php index 45fd66cc08..bfcb3a6c8c 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_activity_subject_data_resolver/easy_activity.php +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/custom_activity_subject_data_resolver/easy_activity.php @@ -3,11 +3,11 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Author; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Author; use Symfony\Config\EasyActivityConfig; /** - * @see \EonX\EasyActivity\Tests\ActivityLogEntryFactoryResolversTest::testCreateSucceedsWithCustomSubjectDataResolver + * @see \EonX\EasyActivity\Tests\Unit\Common\Factory\ActivityLogEntryFactoryTest::testCreateSucceedsWithCustomSubjectDataResolver */ return static function (EasyActivityConfig $easyActivityConfig): void { $easyActivityConfig->subjects(Author::class); diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_actor_resolver/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/custom_actor_resolver/easy_activity.php similarity index 57% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_actor_resolver/easy_activity.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/custom_actor_resolver/easy_activity.php index b74e965c0e..779e8f83f4 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_actor_resolver/easy_activity.php +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/custom_actor_resolver/easy_activity.php @@ -3,11 +3,11 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Article; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Article; use Symfony\Config\EasyActivityConfig; /** - * @see \EonX\EasyActivity\Tests\Bridge\EasyDoctrine\EasyDoctrineEntityEventsSubscriberTest::testLoggerSucceedsWithCustomActorResolver + * @see \EonX\EasyActivity\Tests\Unit\EasyDoctrine\Subscriber\EasyDoctrineEntityEventsSubscriberTest::testLoggerSucceedsWithCustomActorResolver */ return static function (EasyActivityConfig $easyActivityConfig): void { $easyActivityConfig->subjects(Article::class); diff --git a/packages/EasyActivity/tests/Fixture/app/config/packages/custom_subject_type/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/custom_subject_type/easy_activity.php new file mode 100644 index 0000000000..f4ad30faac --- /dev/null +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/custom_subject_type/easy_activity.php @@ -0,0 +1,17 @@ +subjects(Article::class) + ->type('article'); +}; diff --git a/packages/EasyActivity/tests/Fixture/app/config/packages/default_subject_config/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/default_subject_config/easy_activity.php new file mode 100644 index 0000000000..904ce9658e --- /dev/null +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/default_subject_config/easy_activity.php @@ -0,0 +1,17 @@ +subjects(Article::class); +}; diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/doctrine.php b/packages/EasyActivity/tests/Fixture/app/config/packages/doctrine.php similarity index 92% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/doctrine.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/doctrine.php index 46fa6a0cbd..33b48e5392 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/doctrine.php +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/doctrine.php @@ -30,6 +30,6 @@ $entityManager->mapping('AppEntity') ->dir(param('kernel.project_dir') . '/src/Entity') ->isBundle(false) - ->prefix('EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity') + ->prefix('EonX\EasyActivity\Tests\Fixture\App\Entity') ->type('attribute'); }; diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/easy_activity.php similarity index 100% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/easy_activity.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/easy_activity.php diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/framework.php b/packages/EasyActivity/tests/Fixture/app/config/packages/framework.php similarity index 100% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/framework.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/framework.php diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/global_and_subject_disallowed_properties/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/global_and_subject_disallowed_properties/easy_activity.php similarity index 70% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/global_and_subject_disallowed_properties/easy_activity.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/global_and_subject_disallowed_properties/easy_activity.php index 16e905898d..127f28deec 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/global_and_subject_disallowed_properties/easy_activity.php +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/global_and_subject_disallowed_properties/easy_activity.php @@ -3,11 +3,11 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Article; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Article; use Symfony\Config\EasyActivityConfig; /** - * @see \EonX\EasyActivity\Tests\Bridge\EasyDoctrine\EasyDoctrineEntityEventsSubscriberTest::provideProperties + * @see \EonX\EasyActivity\Tests\Unit\EasyDoctrine\Subscriber\EasyDoctrineEntityEventsSubscriberTest::provideProperties */ return static function (EasyActivityConfig $easyActivityConfig): void { $easyActivityConfig->subjects(Article::class) diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/nested_object_allowed_properties/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/nested_object_allowed_properties/easy_activity.php similarity index 64% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/nested_object_allowed_properties/easy_activity.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/nested_object_allowed_properties/easy_activity.php index 43479e41f4..583a58d1d1 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/nested_object_allowed_properties/easy_activity.php +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/nested_object_allowed_properties/easy_activity.php @@ -3,12 +3,12 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Article; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Author; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Article; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Author; use Symfony\Config\EasyActivityConfig; /** - * @see \EonX\EasyActivity\Tests\ActivityLogEntryFactoryTest::testCreateSucceedsWithRelatedObjectsWhenConfiguredNestedObjectAllowedProperties + * @see \EonX\EasyActivity\Tests\Unit\Common\Factory\ActivityLogEntryFactoryTest::testCreateSucceedsWithRelatedObjectsWhenConfiguredNestedObjectAllowedProperties */ return static function (EasyActivityConfig $easyActivityConfig): void { $easyActivityConfig->subjects(Article::class) diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/only_allowed_properties/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/only_allowed_properties/easy_activity.php similarity index 66% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/only_allowed_properties/easy_activity.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/only_allowed_properties/easy_activity.php index 9c32b5cc79..0b04fcf271 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/only_allowed_properties/easy_activity.php +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/only_allowed_properties/easy_activity.php @@ -3,11 +3,11 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Article; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Article; use Symfony\Config\EasyActivityConfig; /** - * @see \EonX\EasyActivity\Tests\Bridge\EasyDoctrine\EasyDoctrineEntityEventsSubscriberTest::provideProperties + * @see \EonX\EasyActivity\Tests\Unit\EasyDoctrine\Subscriber\EasyDoctrineEntityEventsSubscriberTest::provideProperties */ return static function (EasyActivityConfig $easyActivityConfig): void { $easyActivityConfig->subjects(Article::class) diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/only_disallowed_properties/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/only_disallowed_properties/easy_activity.php similarity index 65% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/only_disallowed_properties/easy_activity.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/only_disallowed_properties/easy_activity.php index f57f56ba55..9f225e03e0 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/only_disallowed_properties/easy_activity.php +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/only_disallowed_properties/easy_activity.php @@ -3,11 +3,11 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Article; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Article; use Symfony\Config\EasyActivityConfig; /** - * @see \EonX\EasyActivity\Tests\Bridge\EasyDoctrine\EasyDoctrineEntityEventsSubscriberTest::provideProperties + * @see \EonX\EasyActivity\Tests\Unit\EasyDoctrine\Subscriber\EasyDoctrineEntityEventsSubscriberTest::provideProperties */ return static function (EasyActivityConfig $easyActivityConfig): void { $easyActivityConfig->subjects(Article::class) diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/related_object_in_subjects/easy_activity.php b/packages/EasyActivity/tests/Fixture/app/config/packages/related_object_in_subjects/easy_activity.php similarity index 54% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/related_object_in_subjects/easy_activity.php rename to packages/EasyActivity/tests/Fixture/app/config/packages/related_object_in_subjects/easy_activity.php index 7b431f5907..45eadb0b16 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/related_object_in_subjects/easy_activity.php +++ b/packages/EasyActivity/tests/Fixture/app/config/packages/related_object_in_subjects/easy_activity.php @@ -3,12 +3,12 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Article; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\Entity\Author; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Article; +use EonX\EasyActivity\Tests\Fixture\App\Entity\Author; use Symfony\Config\EasyActivityConfig; /** - * @see \EonX\EasyActivity\Tests\Bridge\EasyDoctrine\EasyDoctrineEntityEventsSubscriberTest::testLoggerSucceedsWithRelatedObjects + * @see \EonX\EasyActivity\Tests\Unit\EasyDoctrine\Subscriber\EasyDoctrineEntityEventsSubscriberTest::testLoggerSucceedsWithRelatedObjects */ return static function (EasyActivityConfig $easyActivityConfig): void { $easyActivityConfig->subjects(Article::class); diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/services.php b/packages/EasyActivity/tests/Fixture/app/config/services.php similarity index 91% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/services.php rename to packages/EasyActivity/tests/Fixture/app/config/services.php index fdec9d6af0..6b8f28ab36 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/services.php +++ b/packages/EasyActivity/tests/Fixture/app/config/services.php @@ -13,7 +13,7 @@ ->autowire() ->autoconfigure(); - $services->load('EonX\\EasyActivity\\Tests\\Bridge\\Symfony\\Fixtures\\App\\', '../src/*') + $services->load('EonX\\EasyActivity\\Tests\\Fixture\\App\\', '../src/*') ->exclude([ '../src/Kernel/ApplicationKernel.php', '../src/**/ApiResource', diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/services_custom_activity_subject_data_resolver.php b/packages/EasyActivity/tests/Fixture/app/config/services_custom_activity_subject_data_resolver.php similarity index 68% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/services_custom_activity_subject_data_resolver.php rename to packages/EasyActivity/tests/Fixture/app/config/services_custom_activity_subject_data_resolver.php index 27db8dee49..35d7b826c6 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/services_custom_activity_subject_data_resolver.php +++ b/packages/EasyActivity/tests/Fixture/app/config/services_custom_activity_subject_data_resolver.php @@ -3,8 +3,8 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Interfaces\ActivitySubjectDataResolverInterface; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\ActivitySubjectDataResolver\CustomActivitySubjectDataResolver; +use EonX\EasyActivity\Common\Resolver\ActivitySubjectDataResolverInterface; +use EonX\EasyActivity\Tests\Fixture\App\ActivitySubjectDataResolver\CustomActivitySubjectDataResolver; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/services_custom_actor_resolver.php b/packages/EasyActivity/tests/Fixture/app/config/services_custom_actor_resolver.php similarity index 72% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/services_custom_actor_resolver.php rename to packages/EasyActivity/tests/Fixture/app/config/services_custom_actor_resolver.php index 349971debf..a6a9b7eb8f 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/services_custom_actor_resolver.php +++ b/packages/EasyActivity/tests/Fixture/app/config/services_custom_actor_resolver.php @@ -3,8 +3,8 @@ namespace Symfony\Component\DependencyInjection\Loader\Configurator; -use EonX\EasyActivity\Interfaces\ActorResolverInterface; -use EonX\EasyActivity\Tests\Bridge\Symfony\Fixtures\App\ActorResolver\CustomActorResolver; +use EonX\EasyActivity\Common\Resolver\ActorResolverInterface; +use EonX\EasyActivity\Tests\Fixture\App\ActorResolver\CustomActorResolver; return static function (ContainerConfigurator $containerConfigurator): void { $services = $containerConfigurator->services(); diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/src/ActivitySubjectDataResolver/CustomActivitySubjectDataResolver.php b/packages/EasyActivity/tests/Fixture/app/src/ActivitySubjectDataResolver/CustomActivitySubjectDataResolver.php similarity index 63% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/src/ActivitySubjectDataResolver/CustomActivitySubjectDataResolver.php rename to packages/EasyActivity/tests/Fixture/app/src/ActivitySubjectDataResolver/CustomActivitySubjectDataResolver.php index 949212cc5c..c702af88d7 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/src/ActivitySubjectDataResolver/CustomActivitySubjectDataResolver.php +++ b/packages/EasyActivity/tests/Fixture/app/src/ActivitySubjectDataResolver/CustomActivitySubjectDataResolver.php @@ -1,12 +1,12 @@ + * @var \Doctrine\Common\Collections\Collection */ #[ORM\OneToMany(mappedBy: 'article', targetEntity: Comment::class, cascade: ['persist'])] private Collection $comments; @@ -60,7 +60,7 @@ public function getAuthor(): Author } /** - * @return \Doctrine\Common\Collections\Collection + * @return \Doctrine\Common\Collections\Collection */ public function getComments(): Collection { diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/src/Entity/Author.php b/packages/EasyActivity/tests/Fixture/app/src/Entity/Author.php similarity index 93% rename from packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/src/Entity/Author.php rename to packages/EasyActivity/tests/Fixture/app/src/Entity/Author.php index bdf4224d21..6b8a25b934 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/src/Entity/Author.php +++ b/packages/EasyActivity/tests/Fixture/app/src/Entity/Author.php @@ -1,7 +1,7 @@ setId((string)(new NilUuid())); + /** @var \EonX\EasyActivity\Common\CircularReferenceHandler\CircularReferenceHandlerInterface $sut */ + $sut = self::getService(ConfigServiceId::CircularReferenceHandler->value); + + $result = $sut($article, 'json', []); + + self::assertSame( + Article::class . '#00000000-0000-0000-0000-000000000000 (circular reference)', + $result + ); + } + + public function testInvokeSucceedsWithoutId(): void + { + $object = new stdClass(); + /** @var \EonX\EasyActivity\Common\CircularReferenceHandler\CircularReferenceHandlerInterface $sut */ + $sut = self::getService(ConfigServiceId::CircularReferenceHandler->value); + + $result = $sut($object, 'json', []); + + self::assertSame('stdClass (circular reference)', $result); + } +} diff --git a/packages/EasyActivity/tests/ActivityLogEntryFactoryTest.php b/packages/EasyActivity/tests/Unit/src/Common/Factory/ActivityLogEntryFactoryTest.php similarity index 67% rename from packages/EasyActivity/tests/ActivityLogEntryFactoryTest.php rename to packages/EasyActivity/tests/Unit/src/Common/Factory/ActivityLogEntryFactoryTest.php index 38a06e0a67..451dd4705b 100644 --- a/packages/EasyActivity/tests/ActivityLogEntryFactoryTest.php +++ b/packages/EasyActivity/tests/Unit/src/Common/Factory/ActivityLogEntryFactoryTest.php @@ -1,17 +1,19 @@ 'custom_activity_subject_data_resolver']); + $author = new Author(); + $author->setId((string)(new NilUuid())); + $sut = self::getService(ActivityLogEntryFactoryInterface::class); + + $result = $sut->create( + ActivityLogEntry::ACTION_UPDATE, + $author, + ['field' => [1, 2]] + ); + + self::assertNotNull($result); + self::assertSame('a:1:{s:5:"field";i:1;}', $result->getSubjectData()); + self::assertSame('a:1:{s:5:"field";i:2;}', $result->getSubjectOldData()); + } + + public function testCreateSucceedsWithObjectThatImplementsSubjectInterface(): void + { + $subjectId = 'subject-id'; + $subjectType = 'subject-type'; + $activityLogEntity = new ActivityLogEntity($subjectId, $subjectType, ['field1']); + $sut = self::getService(ActivityLogEntryFactoryInterface::class); + + $result = $sut->create( + ActivityLogEntry::ACTION_UPDATE, + $activityLogEntity, + [ + 'field1' => [1, 2], + 'field2' => [2, 3], + ] + ); + + self::assertNotNull($result); + self::assertSame($subjectId, $result->getSubjectId()); + self::assertSame($subjectType, $result->getSubjectType()); + self::assertSame('{"field1":2}', $result->getSubjectData()); + self::assertSame('{"field1":1}', $result->getSubjectOldData()); + } + + /** + * @see packages/EasyActivity/tests/Fixture/app/config/packages/default_subject_config */ public function testCreateSucceedsWithRelatedObjects(): void { @@ -133,7 +179,7 @@ public function testCreateSucceedsWithRelatedObjects(): void } /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/nested_object_allowed_properties + * @see packages/EasyActivity/tests/Fixture/app/config/packages/nested_object_allowed_properties */ public function testCreateSucceedsWithRelatedObjectsWhenConfiguredNestedObjectAllowedProperties(): void { diff --git a/packages/EasyActivity/tests/Bridge/Symfony/Serializers/SymfonyActivitySubjectDataSerializerTest.php b/packages/EasyActivity/tests/Unit/src/Common/Serializer/SymfonyActivitySubjectDataSerializerTest.php similarity index 90% rename from packages/EasyActivity/tests/Bridge/Symfony/Serializers/SymfonyActivitySubjectDataSerializerTest.php rename to packages/EasyActivity/tests/Unit/src/Common/Serializer/SymfonyActivitySubjectDataSerializerTest.php index c739fa9796..1b00e32dbe 100644 --- a/packages/EasyActivity/tests/Bridge/Symfony/Serializers/SymfonyActivitySubjectDataSerializerTest.php +++ b/packages/EasyActivity/tests/Unit/src/Common/Serializer/SymfonyActivitySubjectDataSerializerTest.php @@ -1,24 +1,24 @@ null, 'expectedResult' => \sprintf( '{"comments":[{"article":{"author":{"id":"00000000-0000-0000-0000-000000000000","name":"John Doe"' - . ',"position":1},"comments":["EonX\\\EasyActivity\\\Tests\\\Bridge\\\Symfony\\\Fixtures' . + . ',"position":1},"comments":["EonX\\\EasyActivity\\\Tests\\\Fixture' . '\\\App\\\Entity\\\Comment#00000000-0000-0000-0000' . '-000000000000 (circular reference)"],"createdAt":"%s","id":"00000000-0000-0000-0000-000000000001"},' . '"id":"00000000-0000-0000-0000-000000000000","message":"some-message"}]}', @@ -212,8 +212,8 @@ public function testSerializeSucceeds( ?array $disallowedProperties, ?string $expectedResult, ): void { - /** @var \EonX\EasyActivity\Bridge\Symfony\Serializers\CircularReferenceHandlerInterface $circularReferenceHandler */ - $circularReferenceHandler = self::getService(BridgeConstantsInterface::SERVICE_CIRCULAR_REFERENCE_HANDLER); + /** @var \EonX\EasyActivity\Common\CircularReferenceHandler\CircularReferenceHandlerInterface $circularReferenceHandler */ + $circularReferenceHandler = self::getService(ConfigServiceId::CircularReferenceHandler->value); $serializer = new SymfonyActivitySubjectDataSerializer( self::getService(SerializerInterface::class), $circularReferenceHandler, diff --git a/packages/EasyActivity/tests/Bridge/EasyDoctrine/EasyDoctrineEntityEventsSubscriberTest.php b/packages/EasyActivity/tests/Unit/src/EasyDoctrine/Subscriber/EasyDoctrineEntityEventsSubscriberTest.php similarity index 89% rename from packages/EasyActivity/tests/Bridge/EasyDoctrine/EasyDoctrineEntityEventsSubscriberTest.php rename to packages/EasyActivity/tests/Unit/src/EasyDoctrine/Subscriber/EasyDoctrineEntityEventsSubscriberTest.php index deacd5bd5e..30cfe10097 100644 --- a/packages/EasyActivity/tests/Bridge/EasyDoctrine/EasyDoctrineEntityEventsSubscriberTest.php +++ b/packages/EasyActivity/tests/Unit/src/EasyDoctrine/Subscriber/EasyDoctrineEntityEventsSubscriberTest.php @@ -1,19 +1,19 @@ [ 'environment' => 'only_allowed_properties', @@ -29,7 +29,7 @@ public static function provideProperties(): iterable ]; /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/allowed_and_disallowed_properties_intersection + * @see packages/EasyActivity/tests/Fixture/app/config/packages/allowed_and_disallowed_properties_intersection */ yield 'allowed and disallowed properties intersection' => [ 'environment' => 'allowed_and_disallowed_properties_intersection', @@ -37,7 +37,7 @@ public static function provideProperties(): iterable ]; /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/only_disallowed_properties + * @see packages/EasyActivity/tests/Fixture/app/config/packages/only_disallowed_properties */ yield 'only disallowed properties' => [ 'environment' => 'only_disallowed_properties', @@ -45,7 +45,7 @@ public static function provideProperties(): iterable ]; /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/all_properties_are_disallowed + * @see packages/EasyActivity/tests/Fixture/app/config/packages/all_properties_are_disallowed */ yield 'all properties are disallowed' => [ 'environment' => 'all_properties_are_disallowed', @@ -53,7 +53,7 @@ public static function provideProperties(): iterable ]; /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/global_and_subject_disallowed_properties + * @see packages/EasyActivity/tests/Fixture/app/config/packages/global_and_subject_disallowed_properties */ yield 'disallowed properties and defined on global and entity levels' => [ 'environment' => 'global_and_subject_disallowed_properties', @@ -76,7 +76,7 @@ public function testLoggerDoesNothingWhenSubjectIsNotDefinedInConfig(): void } /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/default_subject_config + * @see packages/EasyActivity/tests/Fixture/app/config/packages/default_subject_config */ public function testLoggerSucceedsForDeletedSubjects(): void { @@ -129,7 +129,7 @@ public function testLoggerSucceedsForDeletedSubjects(): void } /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_subject_type + * @see packages/EasyActivity/tests/Fixture/app/config/packages/custom_subject_type */ public function testLoggerSucceedsForSubjectsCreatedInTransaction(): void { @@ -176,7 +176,7 @@ public function testLoggerSucceedsForSubjectsCreatedInTransaction(): void } /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_subject_type + * @see packages/EasyActivity/tests/Fixture/app/config/packages/custom_subject_type */ public function testLoggerSucceedsForUpdatedSubjects(): void { @@ -238,7 +238,7 @@ public function testLoggerSucceedsForUpdatedSubjects(): void } /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_subject_type + * @see packages/EasyActivity/tests/Fixture/app/config/packages/custom_subject_type */ public function testLoggerSucceedsWithCollections(): void { @@ -334,8 +334,7 @@ public function testLoggerSucceedsWithCollections(): void } /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/custom_actor_resolver - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/services_custom_actor_resolver.php + * @see packages/EasyActivity/tests/Fixture/app/config/packages/custom_actor_resolver */ public function testLoggerSucceedsWithCustomActorResolver(): void { @@ -362,7 +361,7 @@ public function testLoggerSucceedsWithCustomActorResolver(): void } /** - * @see packages/EasyActivity/tests/Bridge/Symfony/Fixtures/app/config/packages/related_object_in_subjects + * @see packages/EasyActivity/tests/Fixture/app/config/packages/related_object_in_subjects */ public function testLoggerSucceedsWithRelatedObjects(): void { diff --git a/packages/EasyAsync/composer.json b/packages/EasyAsync/composer.json index 94dc16b6d5..d0c8b32979 100644 --- a/packages/EasyAsync/composer.json +++ b/packages/EasyAsync/composer.json @@ -5,8 +5,8 @@ "license": "MIT", "require": { "php": "^8.1", - "doctrine/orm": "^2.14", "doctrine/dbal": "^3.0", + "doctrine/orm": "^2.14", "doctrine/persistence": "^3.0", "psr/log": "^3.0", "symfony/config": "^6.4",