From 87a721ecbcb3d3b3a66ee839e7402154c7367ad9 Mon Sep 17 00:00:00 2001 From: GitHub Date: Wed, 9 Aug 2023 07:41:08 +0000 Subject: [PATCH] [ns-panel-connector] Finalizing connector implementation (#137) --- .eslintrc | 1 + src/Entities/Triggers/AutomaticTrigger.php | 2 +- src/Entities/Triggers/Trigger.php | 6 +++--- tests/cases/unit/Controllers/ActionsV1Test.php | 5 +++++ tests/cases/unit/Controllers/ConditionsV1Test.php | 5 +++++ tests/cases/unit/Controllers/NotificationsV1Test.php | 5 +++++ tests/cases/unit/Controllers/TriggerControlsV1Test.php | 2 ++ tests/cases/unit/Controllers/TriggersV1Test.php | 5 +++++ tests/cases/unit/DI/TriggersModuleExtensionTests.php | 2 ++ tests/cases/unit/DbTestCase.php | 10 ++++++++++ tests/cases/unit/Entities/Actions/ActionTest.php | 2 ++ tests/cases/unit/Entities/Conditions/ConditionTest.php | 2 ++ .../unit/Models/Repositories/ActionsRepositoryTest.php | 3 +++ .../Models/Repositories/ConditionsRepositoryTest.php | 3 +++ .../Repositories/NotificationsRepositoryTest.php | 3 +++ .../Models/Repositories/TriggersRepositoryTest.php | 3 +++ tests/cases/unit/Queries/FindActionsTest.php | 2 ++ tests/cases/unit/Queries/FindConditionsTest.php | 2 ++ tests/cases/unit/Router/RouterTest.php | 2 ++ 19 files changed, 61 insertions(+), 4 deletions(-) diff --git a/.eslintrc b/.eslintrc index dec1566..13388e9 100644 --- a/.eslintrc +++ b/.eslintrc @@ -28,6 +28,7 @@ } ], "no-useless-computed-key": "off", + "vue/no-setup-props-destructure": "off", "@typescript-eslint/explicit-function-return-type": ["error"], "@typescript-eslint/ban-ts-comment": "off", "@typescript-eslint/no-explicit-any": "off", diff --git a/src/Entities/Triggers/AutomaticTrigger.php b/src/Entities/Triggers/AutomaticTrigger.php index 47c2e84..f4a19d6 100644 --- a/src/Entities/Triggers/AutomaticTrigger.php +++ b/src/Entities/Triggers/AutomaticTrigger.php @@ -72,7 +72,7 @@ public function setConditions(array $conditions = []): void $this->conditions = new Common\Collections\ArrayCollection(); foreach ($conditions as $entity) { - $this->conditions->add($entity); + $this->addCondition($entity); } } diff --git a/src/Entities/Triggers/Trigger.php b/src/Entities/Triggers/Trigger.php index 3104a0f..5d255d3 100644 --- a/src/Entities/Triggers/Trigger.php +++ b/src/Entities/Triggers/Trigger.php @@ -132,7 +132,7 @@ public function setActions(array $actions = []): void $this->actions = new Common\Collections\ArrayCollection(); foreach ($actions as $entity) { - $this->actions->add($entity); + $this->addAction($entity); } } @@ -178,7 +178,7 @@ public function setNotifications(array $notifications = []): void $this->notifications = new Common\Collections\ArrayCollection(); foreach ($notifications as $entity) { - $this->notifications->add($entity); + $this->addNotification($entity); } } @@ -224,7 +224,7 @@ public function setControls(array $controls = []): void $this->controls = new Common\Collections\ArrayCollection(); foreach ($controls as $entity) { - $this->controls->add($entity); + $this->addControl($entity); } } diff --git a/tests/cases/unit/Controllers/ActionsV1Test.php b/tests/cases/unit/Controllers/ActionsV1Test.php index 52ec843..553670c 100644 --- a/tests/cases/unit/Controllers/ActionsV1Test.php +++ b/tests/cases/unit/Controllers/ActionsV1Test.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Controllers; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Library\Metadata; use FastyBird\Module\Triggers\Tests\Cases\Unit\DbTestCase; @@ -29,6 +30,7 @@ final class ActionsV1Test extends DbTestCase * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider actionsRead @@ -212,6 +214,7 @@ public static function actionsRead(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider actionsCreate @@ -329,6 +332,7 @@ public static function actionsCreate(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider actionsUpdate @@ -459,6 +463,7 @@ public static function actionsUpdate(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider actionsDelete diff --git a/tests/cases/unit/Controllers/ConditionsV1Test.php b/tests/cases/unit/Controllers/ConditionsV1Test.php index d98c459..9b8bb8d 100644 --- a/tests/cases/unit/Controllers/ConditionsV1Test.php +++ b/tests/cases/unit/Controllers/ConditionsV1Test.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Controllers; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Library\Metadata; use FastyBird\Module\Triggers\Tests\Cases\Unit\DbTestCase; @@ -29,6 +30,7 @@ final class ConditionsV1Test extends DbTestCase * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider conditionsRead @@ -225,6 +227,7 @@ public static function conditionsRead(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider conditionsCreate @@ -356,6 +359,7 @@ public static function conditionsCreate(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider conditionsUpdate @@ -490,6 +494,7 @@ public static function conditionsUpdate(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider conditionsDelete diff --git a/tests/cases/unit/Controllers/NotificationsV1Test.php b/tests/cases/unit/Controllers/NotificationsV1Test.php index b874f34..74ae5da 100644 --- a/tests/cases/unit/Controllers/NotificationsV1Test.php +++ b/tests/cases/unit/Controllers/NotificationsV1Test.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Controllers; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Library\Metadata; use FastyBird\Module\Triggers\Tests\Cases\Unit\DbTestCase; @@ -29,6 +30,7 @@ final class NotificationsV1Test extends DbTestCase * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider notificationsRead @@ -212,6 +214,7 @@ public static function notificationsRead(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider notificationsCreate @@ -354,6 +357,7 @@ public static function notificationsCreate(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider notificationsUpdate @@ -488,6 +492,7 @@ public static function notificationsUpdate(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider notificationsDelete diff --git a/tests/cases/unit/Controllers/TriggerControlsV1Test.php b/tests/cases/unit/Controllers/TriggerControlsV1Test.php index 8cb19e8..b1c658a 100644 --- a/tests/cases/unit/Controllers/TriggerControlsV1Test.php +++ b/tests/cases/unit/Controllers/TriggerControlsV1Test.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Controllers; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Library\Metadata; use FastyBird\Module\Triggers\Tests\Cases\Unit\DbTestCase; @@ -28,6 +29,7 @@ final class TriggerControlsV1Test extends DbTestCase * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider triggerControlsRead diff --git a/tests/cases/unit/Controllers/TriggersV1Test.php b/tests/cases/unit/Controllers/TriggersV1Test.php index 20ea847..de071ae 100644 --- a/tests/cases/unit/Controllers/TriggersV1Test.php +++ b/tests/cases/unit/Controllers/TriggersV1Test.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Controllers; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Library\Metadata; use FastyBird\Module\Triggers\Tests\Cases\Unit\DbTestCase; @@ -32,6 +33,7 @@ final class TriggersV1Test extends DbTestCase * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider triggersRead @@ -207,6 +209,7 @@ public static function triggersRead(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider triggersCreate @@ -344,6 +347,7 @@ public static function triggersCreate(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider triggersUpdate @@ -457,6 +461,7 @@ public static function triggersUpdate(): array * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * @throws Utils\JsonException * * @dataProvider triggersDelete diff --git a/tests/cases/unit/DI/TriggersModuleExtensionTests.php b/tests/cases/unit/DI/TriggersModuleExtensionTests.php index 4f6699f..6ef240b 100644 --- a/tests/cases/unit/DI/TriggersModuleExtensionTests.php +++ b/tests/cases/unit/DI/TriggersModuleExtensionTests.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\DI; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Module\Triggers\Commands; use FastyBird\Module\Triggers\Controllers; @@ -25,6 +26,7 @@ final class TriggersModuleExtensionTests extends DbTestCase * @throws Exceptions\InvalidArgument * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testServicesRegistration(): void { diff --git a/tests/cases/unit/DbTestCase.php b/tests/cases/unit/DbTestCase.php index d2a4b8e..c2708e1 100644 --- a/tests/cases/unit/DbTestCase.php +++ b/tests/cases/unit/DbTestCase.php @@ -5,6 +5,7 @@ use DateTimeImmutable; use Doctrine\DBAL; use Doctrine\ORM; +use Error; use FastyBird\DateTimeFactory; use FastyBird\Library\Bootstrap\Boot as BootstrapBoot; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; @@ -67,6 +68,7 @@ abstract class DbTestCase extends TestCase * @throws Exceptions\InvalidArgument * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function setUp(): void { @@ -97,6 +99,7 @@ protected function registerDatabaseSchemaFile(string $file): void * @throws Exceptions\InvalidArgument * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ protected function mockContainerService( string $serviceType, @@ -116,6 +119,7 @@ protected function mockContainerService( * @throws Exceptions\InvalidArgument * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ protected function getContainer(): Nette\DI\Container { @@ -131,6 +135,7 @@ protected function getContainer(): Nette\DI\Container * @throws Exceptions\InvalidArgument * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ private function createContainer(): Nette\DI\Container { @@ -168,6 +173,7 @@ private function createContainer(): Nette\DI\Container * @throws Exceptions\InvalidArgument * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ private function setupDatabase(): void { @@ -201,6 +207,7 @@ private function setupDatabase(): void * @throws Exceptions\InvalidArgument * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ protected function getDb(): DBAL\Connection { @@ -212,6 +219,7 @@ protected function getDb(): DBAL\Connection * @throws Exceptions\InvalidArgument * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ protected function getEntityManager(): NettrineORM\EntityManagerDecorator { @@ -273,6 +281,7 @@ private function loadFromFile(DBAL\Connection $db, string $file): void * @throws Exceptions\InvalidArgument * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ private function replaceContainerService(string $serviceName, object $service): void { @@ -293,6 +302,7 @@ protected function registerNeonConfigurationFile(string $file): void * @throws BootstrapExceptions\InvalidArgument * @throws Exceptions\InvalidArgument * @throws RuntimeException + * @throws Error */ protected function tearDown(): void { diff --git a/tests/cases/unit/Entities/Actions/ActionTest.php b/tests/cases/unit/Entities/Actions/ActionTest.php index 65b4c40..e5f56cd 100644 --- a/tests/cases/unit/Entities/Actions/ActionTest.php +++ b/tests/cases/unit/Entities/Actions/ActionTest.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Entities\Actions; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Module\Triggers\Exceptions; use FastyBird\Module\Triggers\Models; @@ -25,6 +26,7 @@ final class ActionTest extends DbTestCase * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testValidation(): void { diff --git a/tests/cases/unit/Entities/Conditions/ConditionTest.php b/tests/cases/unit/Entities/Conditions/ConditionTest.php index 164aff5..97b6de5 100644 --- a/tests/cases/unit/Entities/Conditions/ConditionTest.php +++ b/tests/cases/unit/Entities/Conditions/ConditionTest.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Entities\Conditions; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Module\Triggers\Exceptions; use FastyBird\Module\Triggers\Models; @@ -25,6 +26,7 @@ final class ConditionTest extends DbTestCase * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testValidation(): void { diff --git a/tests/cases/unit/Models/Repositories/ActionsRepositoryTest.php b/tests/cases/unit/Models/Repositories/ActionsRepositoryTest.php index c30be7e..98d76ee 100644 --- a/tests/cases/unit/Models/Repositories/ActionsRepositoryTest.php +++ b/tests/cases/unit/Models/Repositories/ActionsRepositoryTest.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Models\Repositories; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Module\Triggers\Exceptions; use FastyBird\Module\Triggers\Models; @@ -26,6 +27,7 @@ final class ActionsRepositoryTest extends DbTestCase * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testReadOne(): void { @@ -47,6 +49,7 @@ public function testReadOne(): void * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testReadResultSet(): void { diff --git a/tests/cases/unit/Models/Repositories/ConditionsRepositoryTest.php b/tests/cases/unit/Models/Repositories/ConditionsRepositoryTest.php index 693d76d..ad5ad02 100644 --- a/tests/cases/unit/Models/Repositories/ConditionsRepositoryTest.php +++ b/tests/cases/unit/Models/Repositories/ConditionsRepositoryTest.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Models\Repositories; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Module\Triggers\Exceptions; use FastyBird\Module\Triggers\Models; @@ -26,6 +27,7 @@ final class ConditionsRepositoryTest extends DbTestCase * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testReadOne(): void { @@ -47,6 +49,7 @@ public function testReadOne(): void * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testReadResultSet(): void { diff --git a/tests/cases/unit/Models/Repositories/NotificationsRepositoryTest.php b/tests/cases/unit/Models/Repositories/NotificationsRepositoryTest.php index c3542b2..6bcfac0 100644 --- a/tests/cases/unit/Models/Repositories/NotificationsRepositoryTest.php +++ b/tests/cases/unit/Models/Repositories/NotificationsRepositoryTest.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Models\Repositories; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Module\Triggers\Entities; use FastyBird\Module\Triggers\Exceptions; @@ -26,6 +27,7 @@ final class NotificationsRepositoryTest extends DbTestCase * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testReadOne(): void { @@ -55,6 +57,7 @@ public function testReadOne(): void * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testReadResultSet(): void { diff --git a/tests/cases/unit/Models/Repositories/TriggersRepositoryTest.php b/tests/cases/unit/Models/Repositories/TriggersRepositoryTest.php index 406bbfa..e1952fb 100644 --- a/tests/cases/unit/Models/Repositories/TriggersRepositoryTest.php +++ b/tests/cases/unit/Models/Repositories/TriggersRepositoryTest.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Models\Repositories; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Module\Triggers\Entities; use FastyBird\Module\Triggers\Exceptions; @@ -26,6 +27,7 @@ final class TriggersRepositoryTest extends DbTestCase * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testReadOne(): void { @@ -48,6 +50,7 @@ public function testReadOne(): void * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testReadResultSet(): void { diff --git a/tests/cases/unit/Queries/FindActionsTest.php b/tests/cases/unit/Queries/FindActionsTest.php index 2d7e296..6a16bef 100644 --- a/tests/cases/unit/Queries/FindActionsTest.php +++ b/tests/cases/unit/Queries/FindActionsTest.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Queries; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Module\Triggers\Exceptions; use FastyBird\Module\Triggers\Models; @@ -25,6 +26,7 @@ final class FindActionsTest extends DbTestCase * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testFindById(): void { diff --git a/tests/cases/unit/Queries/FindConditionsTest.php b/tests/cases/unit/Queries/FindConditionsTest.php index a25a286..a710783 100644 --- a/tests/cases/unit/Queries/FindConditionsTest.php +++ b/tests/cases/unit/Queries/FindConditionsTest.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Queries; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Module\Triggers\Exceptions; use FastyBird\Module\Triggers\Models; @@ -25,6 +26,7 @@ final class FindConditionsTest extends DbTestCase * @throws Exceptions\InvalidState * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error */ public function testFindById(): void { diff --git a/tests/cases/unit/Router/RouterTest.php b/tests/cases/unit/Router/RouterTest.php index f3f9008..3f04714 100644 --- a/tests/cases/unit/Router/RouterTest.php +++ b/tests/cases/unit/Router/RouterTest.php @@ -2,6 +2,7 @@ namespace FastyBird\Module\Triggers\Tests\Cases\Unit\Router; +use Error; use FastyBird\Library\Bootstrap\Exceptions as BootstrapExceptions; use FastyBird\Library\Metadata; use FastyBird\Module\Triggers\Exceptions; @@ -34,6 +35,7 @@ public function setUp(): void * @throws InvalidArgumentException * @throws Nette\DI\MissingServiceException * @throws RuntimeException + * @throws Error * * @dataProvider prefixedRoutes */