From a0c62f08d0dd1fd3622ca2b8748f450dcb85dd52 Mon Sep 17 00:00:00 2001 From: David Durieux Date: Thu, 11 Apr 2024 21:03:02 +0200 Subject: [PATCH] Fix tests --- inc/deployuserinteraction.class.php | 2 +- tests/Unit/Deploy/DeployUserinteractionTest.php | 11 +++++------ tests/Unit/Deploy/PackageJsonTest.php | 7 ++++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/inc/deployuserinteraction.class.php b/inc/deployuserinteraction.class.php index 7a2f8b01a..3d01aa15b 100644 --- a/inc/deployuserinteraction.class.php +++ b/inc/deployuserinteraction.class.php @@ -395,7 +395,7 @@ function save_item($params) { 'name' => $params['name'], 'title' => $params['title'], 'text' => $params['text'], - 'type' => $params['userinteractionstype'], + 'type' => $params['type'], 'template' => $params['template'] ]; diff --git a/tests/Unit/Deploy/DeployUserinteractionTest.php b/tests/Unit/Deploy/DeployUserinteractionTest.php index fbb89b8c2..40211500a 100644 --- a/tests/Unit/Deploy/DeployUserinteractionTest.php +++ b/tests/Unit/Deploy/DeployUserinteractionTest.php @@ -183,22 +183,21 @@ public function testAdd_item() { $packages_id = $pfDeployPackage->add($input); $interaction = new PluginFusioninventoryDeployUserinteraction(); - $params = ['id' => $packages_id, - 'userinteractionstype' => 'before', - 'name' => 'My interaction', + $params = ['id' => intval($packages_id), + 'type' => 'before', 'name' => 'interaction 1', 'title' => 'My title', 'text' => 'my text', 'template' => 0, ]; + $interaction->add_item($params); $expected = '{"jobs":{"checks":[],"associatedFiles":[],"actions":[],"userinteractions":[{"name":"interaction 1","title":"My title","text":"my text","type":"before","template":0}]},"associatedFiles":[]}'; $json = Toolbox::stripslashes_deep($interaction->getJson($packages_id)); $this->assertEquals($expected, $json); - $params = ['id' => $packages_id, - 'userinteractionstype' => 'after', - 'name' => 'My interaction 2', + $params = ['id' => intval($packages_id), + 'type' => 'after', 'name' => 'interaction 2', 'title' => 'My title', 'text' => 'my text', diff --git a/tests/Unit/Deploy/PackageJsonTest.php b/tests/Unit/Deploy/PackageJsonTest.php index 613f14288..958a4cd0a 100644 --- a/tests/Unit/Deploy/PackageJsonTest.php +++ b/tests/Unit/Deploy/PackageJsonTest.php @@ -76,14 +76,15 @@ public function AddItem() { // Add check $item = [ - 'id' => $packages_id, + 'id' => intval($packages_id), 'name' => 'check winkey', - 'itemtype' => 'PluginFusioninventoryDeployCheck', 'checkstype' => 'winkeyExists', 'path' => 'toto', 'return' => 'error', - 'add_item' => 'Add' + 'value' => '', + 'unit' => '' ]; + $pfDeployCheck->add_item($item); $pfDeployPackage->getFromDB($packages_id);