Skip to content

Commit

Permalink
Fixing subscriber interface (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Dec 18, 2022
1 parent fdf994d commit 17deb44
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fastybird/devices-module",
"version": "1.0.0-dev.8",
"version": "1.0.0-dev.9",
"type": "module",
"description": "FastyBird IoT devices module for connectors & devices management & basic control logic",
"keywords": [
Expand Down
13 changes: 10 additions & 3 deletions src/Subscribers/ModuleEntities.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use Doctrine\Common;
use Doctrine\ORM;
use Doctrine\Persistence;
use Exception;
use FastyBird\Library\Exchange\Entities as ExchangeEntities;
use FastyBird\Library\Exchange\Exceptions as ExchangeExceptions;
Expand Down Expand Up @@ -81,6 +82,8 @@ public function getSubscribedEvents(): array
}

/**
* @param Persistence\Event\LifecycleEventArgs<ORM\EntityManagerInterface> $eventArgs
*
* @throws DoctrineOrmQueryExceptions\QueryException
* @throws Exception
* @throws Exceptions\InvalidState
Expand All @@ -95,7 +98,7 @@ public function getSubscribedEvents(): array
* @throws PhoneExceptions\NoValidCountryException
* @throws PhoneExceptions\NoValidPhoneException
*/
public function postPersist(ORM\Event\LifecycleEventArgs $eventArgs): void
public function postPersist(Persistence\Event\LifecycleEventArgs $eventArgs): void
{
// onFlush was executed before, everything already initialized
$entity = $eventArgs->getObject();
Expand All @@ -109,6 +112,8 @@ public function postPersist(ORM\Event\LifecycleEventArgs $eventArgs): void
}

/**
* @param Persistence\Event\LifecycleEventArgs<ORM\EntityManagerInterface> $eventArgs
*
* @throws DoctrineOrmQueryExceptions\QueryException
* @throws Exception
* @throws ExchangeExceptions\InvalidState
Expand All @@ -123,7 +128,7 @@ public function postPersist(ORM\Event\LifecycleEventArgs $eventArgs): void
* @throws PhoneExceptions\NoValidCountryException
* @throws PhoneExceptions\NoValidPhoneException
*/
public function postUpdate(ORM\Event\LifecycleEventArgs $eventArgs): void
public function postUpdate(Persistence\Event\LifecycleEventArgs $eventArgs): void
{
$uow = $this->entityManager->getUnitOfWork();

Expand Down Expand Up @@ -151,6 +156,8 @@ public function postUpdate(ORM\Event\LifecycleEventArgs $eventArgs): void
}

/**
* @param Persistence\Event\LifecycleEventArgs<ORM\EntityManagerInterface> $eventArgs
*
* @throws DoctrineOrmQueryExceptions\QueryException
* @throws Exception
* @throws ExchangeExceptions\InvalidState
Expand All @@ -165,7 +172,7 @@ public function postUpdate(ORM\Event\LifecycleEventArgs $eventArgs): void
* @throws PhoneExceptions\NoValidCountryException
* @throws PhoneExceptions\NoValidPhoneException
*/
public function postRemove(ORM\Event\LifecycleEventArgs $eventArgs): void
public function postRemove(Persistence\Event\LifecycleEventArgs $eventArgs): void
{
// onFlush was executed before, everything already initialized
$entity = $eventArgs->getObject();
Expand Down
7 changes: 4 additions & 3 deletions tests/cases/unit/Subscribers/ModuleEntitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace FastyBird\Module\Devices\Tests\Cases\Unit\Subscribers;

use Doctrine\ORM;
use Doctrine\Persistence;
use Exception;
use FastyBird\Library\Exchange\Entities as ExchangeEntities;
use FastyBird\Library\Exchange\Publisher as ExchangePublisher;
Expand Down Expand Up @@ -175,7 +176,7 @@ public function testPublishCreatedEntity(): void
$entity = new Entities\Devices\Blank('device-name', $connectorEntity, 'device-name');
$entity->setName('Device custom name');

$eventArgs = $this->createMock(ORM\Event\LifecycleEventArgs::class);
$eventArgs = $this->createMock(Persistence\Event\LifecycleEventArgs::class);
$eventArgs
->expects(self::once())
->method('getObject')
Expand Down Expand Up @@ -291,7 +292,7 @@ public function testPublishUpdatedEntity(): void
$entity = new Entities\Devices\Blank('device-name', $connectorEntity, 'device-name');
$entity->setName('Device custom name');

$eventArgs = $this->createMock(ORM\Event\LifecycleEventArgs::class);
$eventArgs = $this->createMock(Persistence\Event\LifecycleEventArgs::class);
$eventArgs
->expects(self::once())
->method('getObject')
Expand Down Expand Up @@ -407,7 +408,7 @@ public function testPublishDeletedEntity(): void
$publisher,
);

$eventArgs = $this->createMock(ORM\Event\LifecycleEventArgs::class);
$eventArgs = $this->createMock(Persistence\Event\LifecycleEventArgs::class);
$eventArgs
->expects(self::once())
->method('getObject')
Expand Down

0 comments on commit 17deb44

Please sign in to comment.