From d3c86c8b2e95bed72466e58b1413486119835e5c Mon Sep 17 00:00:00 2001 From: saifulislamferoz Date: Mon, 5 Jan 2026 15:43:22 +0600 Subject: [PATCH 1/3] feat: remove doctrine classutils class usage --- Common/ClassUtils.php | 40 ++++++++++++++++++++++ Resolver/DoctrineObjectEventResolver.php | 2 +- Subscriber/DoctrineSubscriber.php | 14 ++++---- Tests/Common/ClassUtilsTest.php | 43 ++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 Common/ClassUtils.php create mode 100644 Tests/Common/ClassUtilsTest.php diff --git a/Common/ClassUtils.php b/Common/ClassUtils.php new file mode 100644 index 0000000..f3366aa --- /dev/null +++ b/Common/ClassUtils.php @@ -0,0 +1,40 @@ +handleEvent(DoctrineEvents::ENTITY_CREATED, $args); } - public function postUpdate(LifecycleEventArgs $args) + public function postUpdate(LifecycleEventArgs $args): void { $this->handleEvent(DoctrineEvents::ENTITY_UPDATED, $args); } - public function preRemove(LifecycleEventArgs $args) + public function preRemove(LifecycleEventArgs $args): void { if (false === $this->isConfiguredToTrack($args->getObject(), DoctrineEvents::ENTITY_DELETED)) { return; @@ -52,7 +52,7 @@ public function preRemove(LifecycleEventArgs $args) $this->toBeDeleted[$className][spl_object_hash($args->getObject())] = $this->getIdentity($args, $className); } - public function postRemove(LifecycleEventArgs $args) + public function postRemove(LifecycleEventArgs $args): void { $identity = $this->getToBeDeletedId($args->getObject()); @@ -74,7 +74,7 @@ private function getToBeDeletedId($entity) * @param string $eventName * @param LifecycleEventArgs $args */ - private function handleEvent($eventName, LifecycleEventArgs $args) + private function handleEvent($eventName, LifecycleEventArgs $args): void { if (true === $this->isConfiguredToTrack($args->getObject(), $eventName)) { $this->dispatcher->dispatch( @@ -90,7 +90,7 @@ private function handleEvent($eventName, LifecycleEventArgs $args) * * @return bool */ - private function isConfiguredToTrack($entity, $eventName = '') + private function isConfiguredToTrack($entity, $eventName = ''): ?bool { $class = ClassUtils::getClass($entity); $eventType = DoctrineEvents::getShortEventType($eventName); diff --git a/Tests/Common/ClassUtilsTest.php b/Tests/Common/ClassUtilsTest.php new file mode 100644 index 0000000..85b9712 --- /dev/null +++ b/Tests/Common/ClassUtilsTest.php @@ -0,0 +1,43 @@ +assertEquals($className, ClassUtils::getRealClass($className)); + } + + public function testGetRealClassWithProxyClassName() + { + $className = 'My\Proxy\Namespace\\' . Proxy::MARKER . '\My\Real\Class'; + $this->assertEquals('My\Real\Class', ClassUtils::getRealClass($className)); + } + + public function testGetClassWithNonProxyObject() + { + $object = new \stdClass(); + $this->assertEquals('stdClass', ClassUtils::getClass($object)); + } + + public function testGetClassWithProxyObject() + { + $proxy = new \My\Proxy\Namespace\__CG__\My\Real\RealClass(); + $this->assertEquals('My\Real\RealClass', ClassUtils::getClass($proxy)); + } +} + +namespace My\Real; +class RealClass {} + +namespace My\Proxy\Namespace\__CG__\My\Real; +class RealClass extends \My\Real\RealClass implements \Doctrine\Persistence\Proxy { + public function __load(): void {} + public function __isInitialized(): bool { return true; } +} From a67bc879fe774fd29c7ffc505289a7979db040c6 Mon Sep 17 00:00:00 2001 From: saifulislamferoz Date: Mon, 5 Jan 2026 15:43:57 +0600 Subject: [PATCH 2/3] fix: showing deprecations --- DependencyInjection/Configuration.php | 4 +- .../XiideaEasyAuditExtension.php | 2 +- Logger/Logger.php | 2 +- Logger/MonologLogger.php | 2 +- .../Compiler/LoggerFactoryPassTest.php | 34 ++- .../Compiler/SubscriberPassTest.php | 244 ++++++++++-------- Tests/Fixtures/ORM/UserEntity.php | 4 +- .../Bundle/TestBundle/Logger/FileLogger.php | 2 +- Tests/Functional/CommonTest.php | 13 +- .../ImpersonatingUserTestKernel.php | 2 +- Tests/Functional/TestKernel.php | 2 +- Tests/Logger/LoggerTest.php | 8 +- Tests/Logger/MonologLoggerTest.php | 2 +- Tests/XiideaEasyAuditBundleTest.php | 17 +- 14 files changed, 183 insertions(+), 155 deletions(-) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index e74aeaf..b152903 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -46,7 +46,7 @@ public function getConfigTreeBuilder(): TreeBuilder /** * @param ArrayNodeDefinition $rootNode */ - private function addRequiredConfigs(ArrayNodeDefinition $rootNode) + private function addRequiredConfigs(ArrayNodeDefinition $rootNode): void { $rootNode ->children() @@ -58,7 +58,7 @@ private function addRequiredConfigs(ArrayNodeDefinition $rootNode) /** * @param ArrayNodeDefinition $rootNode */ - private function addDefaultServices(ArrayNodeDefinition $rootNode) + private function addDefaultServices(ArrayNodeDefinition $rootNode): void { $rootNode ->children() diff --git a/DependencyInjection/XiideaEasyAuditExtension.php b/DependencyInjection/XiideaEasyAuditExtension.php index 7986414..82811c9 100644 --- a/DependencyInjection/XiideaEasyAuditExtension.php +++ b/DependencyInjection/XiideaEasyAuditExtension.php @@ -54,7 +54,7 @@ public function load(array $configs, ContainerBuilder $container): void * * @throws \Exception */ - protected function loadDefaultResolverServices($config, LoaderInterface $loader) + protected function loadDefaultResolverServices($config, LoaderInterface $loader): void { if ('xiidea.easy_audit.default_event_resolver' === $config['resolver']) { $loader->load('default/event-resolver.yml'); diff --git a/Logger/Logger.php b/Logger/Logger.php index 67a32f5..5f590e2 100644 --- a/Logger/Logger.php +++ b/Logger/Logger.php @@ -25,7 +25,7 @@ public function __construct(private ManagerRegistry $doctrine) } #[\Override] - public function log(AuditLog $event = null) + public function log(?AuditLog $event = null) { if (empty($event)) { return; diff --git a/Logger/MonologLogger.php b/Logger/MonologLogger.php index 40dbbe4..a215c15 100644 --- a/Logger/MonologLogger.php +++ b/Logger/MonologLogger.php @@ -24,7 +24,7 @@ public function __construct(private \Psr\Log\LoggerInterface $logger) } #[\Override] - public function log(AuditLog $event = null) + public function log(?AuditLog $event = null) { if (null === $event) { return; diff --git a/Tests/DependencyInjection/Compiler/LoggerFactoryPassTest.php b/Tests/DependencyInjection/Compiler/LoggerFactoryPassTest.php index f4a7abf..27dfb34 100644 --- a/Tests/DependencyInjection/Compiler/LoggerFactoryPassTest.php +++ b/Tests/DependencyInjection/Compiler/LoggerFactoryPassTest.php @@ -51,8 +51,6 @@ public function testProcessWithLoggerFactoryDefinitions() */ protected function getDefinitionMock() { - $i = 0; - $definitionMock = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition') ->disableOriginalConstructor() ->getMock(); @@ -63,28 +61,26 @@ protected function getDefinitionMock() ); $definitionMock - ->expects($this->at($i++)) + ->expects($this->exactly(2)) ->method('getMethodCalls') - ->will($this->returnValue(array())); + ->willReturnOnConsecutiveCalls(array(), $loggers); + $definitionMock - ->expects($this->at($i++)) + ->expects($this->exactly(2)) ->method('setMethodCalls') - ->with($this->equalTo(array())); + ->withConsecutive( + array($this->equalTo(array())), + array($this->equalTo($loggers)) + ); + $definitionMock - ->expects($this->at($i++)) + ->expects($this->exactly(2)) ->method('addMethodCall') - ->with($this->equalTo('addLogger'), $this->equalTo($loggers[0][1])); - $definitionMock->expects($this->at($i++)) - ->method('addMethodCall') - ->with($this->equalTo('addLogger'), $this->equalTo($loggers[1][1])); - $definitionMock - ->expects($this->at($i++)) - ->method('getMethodCalls') - ->will($this->returnValue($loggers)); - $definitionMock - ->expects($this->at($i)) - ->method('setMethodCalls') - ->with($this->equalTo($loggers)); + ->withConsecutive( + array($this->equalTo('addLogger'), $this->equalTo($loggers[0][1])), + array($this->equalTo('addLogger'), $this->equalTo($loggers[1][1])) + ); + return $definitionMock; } diff --git a/Tests/DependencyInjection/Compiler/SubscriberPassTest.php b/Tests/DependencyInjection/Compiler/SubscriberPassTest.php index 8c0da3e..e021bf4 100644 --- a/Tests/DependencyInjection/Compiler/SubscriberPassTest.php +++ b/Tests/DependencyInjection/Compiler/SubscriberPassTest.php @@ -34,25 +34,61 @@ public function testProcessWithoutEventListenerDefinition() public function testDisableDoctrineEvents() { - $containerBuilder = $this->getContainerBuilderMock(); + $containerBuilder = $this->createMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + + $containerBuilder->expects($this->any()) + ->method('hasDefinition') + ->with($this->equalTo('xiidea.easy_audit.event_listener')) + ->will($this->returnValue(true)); + + $containerBuilder->expects($this->any()) + ->method('getParameter') + ->willReturnMap([ + ['xiidea.easy_audit.events', []], + ['xiidea.easy_audit.doctrine_objects', false], + ]); - $this->containerExpectsForDisabledDoctrineEvents($containerBuilder); + $containerBuilder->expects($this->once()) + ->method('findTaggedServiceIds') + ->with($this->equalTo('easy_audit.event_subscriber')) + ->will($this->returnValue([])); $this->processSubscriberPass($containerBuilder); } public function testEnableDoctrineEvents() { - $containerBuilder = $this->getContainerBuilderMock(); - $this->containerExpectsForEnabledDoctrineEvents($containerBuilder); + $containerBuilder = $this->createMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + + $containerBuilder->expects($this->any()) + ->method('hasDefinition') + ->with($this->equalTo('xiidea.easy_audit.event_listener')) + ->will($this->returnValue(true)); + + $containerBuilder->expects($this->any()) + ->method('getParameter') + ->willReturnMap([ + ['xiidea.easy_audit.events', []], + ['xiidea.easy_audit.doctrine_objects', true], + ['xiidea.easy_audit.custom_resolvers', []], + ]); + + $definitionMock = $this->getDefinitionMock(); + + $containerBuilder + ->method('getDefinition') + ->with($this->equalTo('xiidea.easy_audit.event_listener')) + ->will($this->returnValue($definitionMock)); + + $definitionMock + ->expects($this->once()) + ->method('setTags'); $this->processSubscriberPass($containerBuilder); } public function testSubscribedEventsWithDisableDoctrineEvents() { - $containerBuilder = $this->getContainerBuilderMock(); - $subscribers = array( 'easy.subscriber1' => array( array( @@ -64,10 +100,45 @@ public function testSubscribedEventsWithDisableDoctrineEvents() ), ); - $this->containerExpectsForDisabledDoctrineEvents($containerBuilder, $subscribers); + $containerBuilder = $this->createMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + + $containerBuilder->expects($this->any()) + ->method('hasDefinition') + ->with($this->equalTo('xiidea.easy_audit.event_listener')) + ->will($this->returnValue(true)); + + $containerBuilder->expects($this->any()) + ->method('getParameter') + ->willReturnMap([ + ['xiidea.easy_audit.events', []], + ['xiidea.easy_audit.doctrine_objects', false], + ['xiidea.easy_audit.custom_resolvers', []], + ]); + + $containerBuilder + ->method('findTaggedServiceIds') + ->with($this->equalTo('easy_audit.event_subscriber')) + ->will($this->returnValue($subscribers)); $definitionMock = $this->getDefinitionMock(); + $containerBuilder + ->method('getDefinition') + ->with($this->equalTo('xiidea.easy_audit.event_listener')) + ->will($this->returnValue($definitionMock)); + + $containerBuilder + ->expects($this->exactly(2)) + ->method('get') + ->withConsecutive( + array($this->equalTo('easy.subscriber1')), + array($this->equalTo('easy.subscriber2')) + ) + ->willReturnOnConsecutiveCalls( + new EasySubscriberOne(), + new EasySubscriberTwo() + ); + $listenableEventsList = array( array( 'event' => 'event1', @@ -96,34 +167,12 @@ public function testSubscribedEventsWithDisableDoctrineEvents() ); $definitionMock - ->expects($this->at(0)) + ->expects($this->once()) ->method('setTags') ->with($this->equalTo(array('kernel.event_listener' => $listenableEventsList))); $containerBuilder - ->expects($this->at(4)) - ->method('get') - ->with($this->equalTo('easy.subscriber1')) - ->will($this->returnValue(new EasySubscriberOne())); - $containerBuilder - ->expects($this->at(5)) - ->method('get') - ->with($this->equalTo('easy.subscriber2')) - ->will($this->returnValue(new EasySubscriberTwo())); - - $containerBuilder - ->expects($this->at(6)) - ->method('getDefinition') - ->with($this->equalTo('xiidea.easy_audit.event_listener')) - ->will($this->returnValue($definitionMock)); - - $containerBuilder - ->expects($this->at(7)) - ->method('getParameter') - ->with($this->equalTo('xiidea.easy_audit.custom_resolvers')) - ->will($this->returnValue(array())); - $containerBuilder - ->expects($this->at(8)) + ->expects($this->once()) ->method('setParameter') ->with($this->equalTo('xiidea.easy_audit.custom_resolvers'), array( 'event1' => 'custom_resolver1', @@ -137,8 +186,6 @@ public function testSubscribedEventsWithDisableDoctrineEvents() public function testSubscribedEventsWithEnabledDoctrineEvents() { - $containerBuilder = $this->getContainerBuilderMock(); - $subscribers = array( 'easy.subscriber1' => array( array( @@ -150,6 +197,45 @@ public function testSubscribedEventsWithEnabledDoctrineEvents() ), ); + $containerBuilder = $this->createMock('Symfony\Component\DependencyInjection\ContainerBuilder'); + + $containerBuilder->expects($this->any()) + ->method('hasDefinition') + ->with($this->equalTo('xiidea.easy_audit.event_listener')) + ->will($this->returnValue(true)); + + $containerBuilder->expects($this->any()) + ->method('getParameter') + ->willReturnMap([ + ['xiidea.easy_audit.events', []], + ['xiidea.easy_audit.doctrine_objects', true], + ['xiidea.easy_audit.custom_resolvers', []], + ]); + + $containerBuilder + ->method('findTaggedServiceIds') + ->with($this->equalTo('easy_audit.event_subscriber')) + ->will($this->returnValue($subscribers)); + + $definitionMock = $this->getDefinitionMock(); + + $containerBuilder + ->method('getDefinition') + ->with($this->equalTo('xiidea.easy_audit.event_listener')) + ->will($this->returnValue($definitionMock)); + + $containerBuilder + ->expects($this->exactly(2)) + ->method('get') + ->withConsecutive( + array($this->equalTo('easy.subscriber1')), + array($this->equalTo('easy.subscriber2')) + ) + ->willReturnOnConsecutiveCalls( + new EasySubscriberOne(), + new EasySubscriberTwo() + ); + $listenableEventsList = array( array( 'event' => 'easy_audit.doctrine.object.updated', @@ -189,54 +275,13 @@ public function testSubscribedEventsWithEnabledDoctrineEvents() ), ); - $definitionMock = $this->getDefinitionMock(); - $definitionMock - ->expects($this->at(0)) + ->expects($this->once()) ->method('setTags') ->with($this->equalTo(array('kernel.event_listener' => $listenableEventsList))); $containerBuilder - ->expects($this->at(1)) - ->method('getParameter') - ->with($this->equalTo('xiidea.easy_audit.events')) - ->will($this->returnValue(array())); - $containerBuilder - ->expects($this->at(2)) - ->method('getParameter') - ->with($this->equalTo('xiidea.easy_audit.doctrine_objects')) - ->will($this->returnValue(true)); - $containerBuilder - ->expects($this->at(3)) - ->method('findTaggedServiceIds') - ->with($this->equalTo('easy_audit.event_subscriber')) - ->will($this->returnValue($subscribers)); - - $containerBuilder - ->expects($this->at(4)) - ->method('get') - ->with($this->equalTo('easy.subscriber1')) - ->will($this->returnValue(new EasySubscriberOne())); - $containerBuilder - ->expects($this->at(5)) - ->method('get') - ->with($this->equalTo('easy.subscriber2')) - ->will($this->returnValue(new EasySubscriberTwo())); - - $containerBuilder - ->expects($this->at(6)) - ->method('getDefinition') - ->with($this->equalTo('xiidea.easy_audit.event_listener')) - ->will($this->returnValue($definitionMock)); - - $containerBuilder - ->expects($this->at(7)) - ->method('getParameter') - ->with($this->equalTo('xiidea.easy_audit.custom_resolvers')) - ->will($this->returnValue(array())); - - $containerBuilder - ->expects($this->at(8)) + ->expects($this->once()) ->method('setParameter') ->with($this->equalTo('xiidea.easy_audit.custom_resolvers'), array( 'event1' => 'custom_resolver1', @@ -267,11 +312,19 @@ protected function getContainerBuilderMock() { $containerBuilder = $this->createMock('Symfony\Component\DependencyInjection\ContainerBuilder'); - $containerBuilder->expects($this->once()) + $containerBuilder->expects($this->any()) ->method('hasDefinition') ->with($this->equalTo('xiidea.easy_audit.event_listener')) ->will($this->returnValue(true)); + $containerBuilder->expects($this->any()) + ->method('getParameter') + ->willReturnMap([ + ['xiidea.easy_audit.events', []], + ['xiidea.easy_audit.doctrine_objects', false], + ['xiidea.easy_audit.custom_resolvers', []], + ]); + return $containerBuilder; } @@ -299,35 +352,27 @@ protected function containerExpectsForEnabledDoctrineEvents($containerBuilder, $ ); $definitionMock - ->expects($this->at(0)) + ->expects($this->once()) ->method('setTags') ->with($this->equalTo(array('kernel.event_listener' => $listenableEventsList))); - $containerBuilder - ->expects($this->at(1)) - ->method('getParameter') - ->with($this->equalTo('xiidea.easy_audit.events')) - ->will($this->returnValue(array())); - $containerBuilder - ->expects($this->at(2)) + $containerBuilder->expects($this->any()) ->method('getParameter') - ->with($this->equalTo('xiidea.easy_audit.doctrine_objects')) - ->will($this->returnValue(true)); + ->willReturnMap([ + ['xiidea.easy_audit.events', []], + ['xiidea.easy_audit.doctrine_objects', true], + ['xiidea.easy_audit.custom_resolvers', []], + ]); + $containerBuilder - ->expects($this->at(3)) ->method('findTaggedServiceIds') ->with($this->equalTo('easy_audit.event_subscriber')) ->will($this->returnValue($subscribedEvents)); + $containerBuilder - ->expects($this->at(4)) ->method('getDefinition') ->with($this->equalTo('xiidea.easy_audit.event_listener')) ->will($this->returnValue($definitionMock)); - $containerBuilder - ->expects($this->at(5)) - ->method('getParameter') - ->with($this->equalTo('xiidea.easy_audit.custom_resolvers')) - ->will($this->returnValue(array())); } /** @@ -337,17 +382,6 @@ protected function containerExpectsForEnabledDoctrineEvents($containerBuilder, $ protected function containerExpectsForDisabledDoctrineEvents($containerBuilder, $subscribedEvents = array()) { $containerBuilder - ->expects($this->at(1)) - ->method('getParameter') - ->with($this->equalTo('xiidea.easy_audit.events')) - ->will($this->returnValue(array())); - $containerBuilder - ->expects($this->at(2)) - ->method('getParameter') - ->with($this->equalTo('xiidea.easy_audit.doctrine_objects')) - ->will($this->returnValue(false)); - $containerBuilder - ->expects($this->at(3)) ->method('findTaggedServiceIds') ->with($this->equalTo('easy_audit.event_subscriber')) ->will($this->returnValue($subscribedEvents)); diff --git a/Tests/Fixtures/ORM/UserEntity.php b/Tests/Fixtures/ORM/UserEntity.php index 40a7b04..557c240 100644 --- a/Tests/Fixtures/ORM/UserEntity.php +++ b/Tests/Fixtures/ORM/UserEntity.php @@ -212,7 +212,7 @@ public function isSuperAdmin() * * @return static */ - public function setLastLogin(\DateTime $time = null) + public function setLastLogin(?\DateTime $time = null) { return $this; } @@ -358,7 +358,7 @@ public function setConfirmationToken($confirmationToken) * * @return static */ - public function setPasswordRequestedAt(\DateTime $date = null) + public function setPasswordRequestedAt(?\DateTime $date = null) { return $this; } diff --git a/Tests/Functional/Bundle/TestBundle/Logger/FileLogger.php b/Tests/Functional/Bundle/TestBundle/Logger/FileLogger.php index 3740e8c..3e66a65 100644 --- a/Tests/Functional/Bundle/TestBundle/Logger/FileLogger.php +++ b/Tests/Functional/Bundle/TestBundle/Logger/FileLogger.php @@ -24,7 +24,7 @@ public function __construct($dir) $this->dir = $dir; } - public function log(AuditLog $event = null) + public function log(?AuditLog $event = null) { if (empty($event)) { return; diff --git a/Tests/Functional/CommonTest.php b/Tests/Functional/CommonTest.php index 71ff428..66893aa 100644 --- a/Tests/Functional/CommonTest.php +++ b/Tests/Functional/CommonTest.php @@ -50,7 +50,7 @@ public function testDispatch() $container->get('event_dispatcher')->dispatch(new Basic(), $name); - $logFile = realpath($container->getParameter('kernel.cache_dir').DIRECTORY_SEPARATOR.'audit.log'); + $logFile = realpath($container->getParameter('kernel.cache_dir') . DIRECTORY_SEPARATOR . 'audit.log'); $event = unserialize(file_get_contents($logFile)); $this->assertEquals($name, $event['typeId']); @@ -75,10 +75,10 @@ public function testMultipleChannel() $container->get('event_dispatcher')->dispatch(new Basic(), $name); - $container->get('event_dispatcher')->dispatch(new WithEmbeddedResolver(), $name.'2'); + $container->get('event_dispatcher')->dispatch(new WithEmbeddedResolver(), $name . '2'); - $logFile = realpath($container->getParameter('kernel.cache_dir').DIRECTORY_SEPARATOR.'audit.log'); - $logFile2 = realpath($container->getParameter('kernel.cache_dir').'2'.DIRECTORY_SEPARATOR.'audit.log'); + $logFile = realpath($container->getParameter('kernel.cache_dir') . DIRECTORY_SEPARATOR . 'audit.log'); + $logFile2 = realpath($container->getParameter('kernel.cache_dir') . '2' . DIRECTORY_SEPARATOR . 'audit.log'); $event2 = unserialize(file_get_contents($logFile2)); $event = unserialize(file_get_contents($logFile)); @@ -89,8 +89,8 @@ public function testMultipleChannel() $this->assertEquals('By Command', $event['user']); $this->assertEquals('', $event['ip']); - $this->assertEquals($name.'2', $event2['typeId']); - $this->assertEquals($name.'2', $event2['type']); + $this->assertEquals($name . '2', $event2['typeId']); + $this->assertEquals($name . '2', $event2['type']); $this->assertEquals('It is an embedded event', $event2['description']); $this->assertEquals('By Command', $event2['user']); $this->assertEquals('', $event2['ip']); @@ -169,6 +169,7 @@ private function getEventArrayFromResponse(Crawler $crawler) $html = $crawler->html(); $parts = explode(DefaultController::RESPONSE_BOUNDARY, $html); $event = unserialize($parts[1]); + return $event; } } diff --git a/Tests/Functional/ImpersonatingUserTestKernel.php b/Tests/Functional/ImpersonatingUserTestKernel.php index e31adc1..f6deb74 100644 --- a/Tests/Functional/ImpersonatingUserTestKernel.php +++ b/Tests/Functional/ImpersonatingUserTestKernel.php @@ -68,7 +68,7 @@ public function getProjectDir(): string return __DIR__; } - public function registerContainerConfiguration(LoaderInterface $loader) + public function registerContainerConfiguration(LoaderInterface $loader): void { $loader->load($this->config); } diff --git a/Tests/Functional/TestKernel.php b/Tests/Functional/TestKernel.php index d3f8fcc..aa0cdc5 100644 --- a/Tests/Functional/TestKernel.php +++ b/Tests/Functional/TestKernel.php @@ -59,7 +59,7 @@ public function getLogDir(): string return sys_get_temp_dir().'/XiideaEasyAuditBundle/'.substr(sha1($this->config), 0, 6).'/logs'; } - public function registerContainerConfiguration(LoaderInterface $loader) + public function registerContainerConfiguration(LoaderInterface $loader): void { $loader->load($this->config); } diff --git a/Tests/Logger/LoggerTest.php b/Tests/Logger/LoggerTest.php index f19deaa..a25c31d 100644 --- a/Tests/Logger/LoggerTest.php +++ b/Tests/Logger/LoggerTest.php @@ -53,11 +53,11 @@ public function testIsAnInstanceOfLoggerInterface() public function testLogCallsPersistWithDoctrineForAuditLogObject() { $this->entityManager - ->expects($this->at(0)) + ->expects($this->once()) ->method('persist') ->with($this->isInstanceOf(BaseAuditLog::class)); $this->entityManager - ->expects($this->at(1)) + ->expects($this->once()) ->method('flush') ->with($this->isInstanceOf(BaseAuditLog::class)); @@ -81,11 +81,11 @@ public function testLogCallsDeferred() public function testSavePendingLogsForDelete() { $this->entityManager - ->expects($this->at(0)) + ->expects($this->once()) ->method('persist') ->with($this->isInstanceOf(BaseAuditLog::class)); $this->entityManager - ->expects($this->at(1)) + ->expects($this->once()) ->method('flush') ->with($this->isInstanceOf(BaseAuditLog::class)); diff --git a/Tests/Logger/MonologLoggerTest.php b/Tests/Logger/MonologLoggerTest.php index c1742f6..d93a743 100644 --- a/Tests/Logger/MonologLoggerTest.php +++ b/Tests/Logger/MonologLoggerTest.php @@ -44,7 +44,7 @@ public function testLogCallsLogToLogServiceWithLogArray() $log->setTypeId('null'); $this->symfonyLogger - ->expects($this->at(0)) + ->expects($this->once()) ->method('log') ->with( $this->equalTo('info'), diff --git a/Tests/XiideaEasyAuditBundleTest.php b/Tests/XiideaEasyAuditBundleTest.php index 620e4cf..572cb3c 100644 --- a/Tests/XiideaEasyAuditBundleTest.php +++ b/Tests/XiideaEasyAuditBundleTest.php @@ -24,17 +24,14 @@ public function testBuildInitializeBundleAddCompilerPass() //Expect compiler pass to be added $containerBuilder - ->expects($this->at(0)) + ->expects($this->exactly(4)) ->method('addCompilerPass') - ->with($this->isInstanceOf('Xiidea\EasyAuditBundle\DependencyInjection\Compiler\MonologLoggerPass')); - $containerBuilder - ->expects($this->at(1)) - ->method('addCompilerPass') - ->with($this->isInstanceOf('Xiidea\EasyAuditBundle\DependencyInjection\Compiler\LoggerFactoryPass')); - $containerBuilder - ->expects($this->at(2)) - ->method('addCompilerPass') - ->with($this->isInstanceOf('Xiidea\EasyAuditBundle\DependencyInjection\Compiler\SubscriberPass')); + ->withConsecutive( + array($this->isInstanceOf('Xiidea\EasyAuditBundle\DependencyInjection\Compiler\MonologLoggerPass')), + array($this->isInstanceOf('Xiidea\EasyAuditBundle\DependencyInjection\Compiler\LoggerFactoryPass')), + array($this->isInstanceOf('Xiidea\EasyAuditBundle\DependencyInjection\Compiler\SubscriberPass')), + array($this->isInstanceOf('Xiidea\EasyAuditBundle\DependencyInjection\Compiler\ResolverFactoryPass')) + ); $bundle = new XiideaEasyAuditBundle(); $bundle->build($containerBuilder); From 0323e0b3c84bc9d650dd6431ed5d30db76e146e4 Mon Sep 17 00:00:00 2001 From: saifulislamferoz Date: Tue, 6 Jan 2026 10:26:04 +0600 Subject: [PATCH 3/3] fix: showing deprecations --- DependencyInjection/XiideaEasyAuditExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/XiideaEasyAuditExtension.php b/DependencyInjection/XiideaEasyAuditExtension.php index 82811c9..1ec9bf9 100644 --- a/DependencyInjection/XiideaEasyAuditExtension.php +++ b/DependencyInjection/XiideaEasyAuditExtension.php @@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; +use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader; /**