From cf98205dda7c0c16e4a276b62d7398180b401956 Mon Sep 17 00:00:00 2001 From: Curtis Conard Date: Thu, 21 Mar 2024 12:12:17 -0400 Subject: [PATCH] even more test fixes --- src/Api/HL/Controller/AssetController.php | 67 +++++++++++++++++-- src/Link.php | 14 +++- src/Search/Provider/SQLProvider.php | 5 +- tests/functional/CartridgeItem.php | 16 +---- tests/functional/ConsumableItem.php | 15 +---- tests/functional/Glpi/Inventory/Inventory.php | 40 +++++------ tests/functional/Link.php | 2 +- tests/functional/Monitor.php | 4 +- tests/functional/Search.php | 5 ++ 9 files changed, 107 insertions(+), 61 deletions(-) diff --git a/src/Api/HL/Controller/AssetController.php b/src/Api/HL/Controller/AssetController.php index cf727e5cb28a..19a58cdd330b 100644 --- a/src/Api/HL/Controller/AssetController.php +++ b/src/Api/HL/Controller/AssetController.php @@ -52,6 +52,7 @@ use Location; use Manufacturer; use Network; +use Software; use State; use User; @@ -405,7 +406,7 @@ class: User::class, if (\Toolbox::hasTrait($asset_type, AssignableAsset::class)) { // Assignable assets all support multiple groups and the group links are in a separate table if (in_array($asset_type, $CFG_GLPI['linkgroup_types'], true)) { - $schemas[$schema_name]['properties']['groups'] = [ + $schemas[$schema_name]['properties']['group'] = [ 'type' => Doc\Schema::TYPE_ARRAY, 'items' => [ 'type' => Doc\Schema::TYPE_OBJECT, @@ -436,7 +437,7 @@ class: User::class, ]; } if (in_array($asset_type, $CFG_GLPI['linkgroup_tech_types'], true)) { - $schemas[$schema_name]['properties']['groups_tech'] = [ + $schemas[$schema_name]['properties']['group_tech'] = [ 'type' => Doc\Schema::TYPE_ARRAY, 'items' => [ 'type' => Doc\Schema::TYPE_OBJECT, @@ -699,7 +700,7 @@ class: Group::class, ]; $schemas['Software'] = [ - 'x-itemtype' => \Software::class, + 'x-itemtype' => Software::class, 'type' => Doc\Schema::TYPE_OBJECT, 'properties' => [ 'id' => [ @@ -717,9 +718,65 @@ class: Group::class, 'parent' => self::getDropdownTypeSchema(class: \Software::class, full_schema: 'Software'), 'is_helpdesk_visible' => ['type' => Doc\Schema::TYPE_BOOLEAN], 'user' => self::getDropdownTypeSchema(class: User::class, full_schema: 'User'), - 'group' => self::getDropdownTypeSchema(class: Group::class, full_schema: 'Group'), + 'group' => [ + 'type' => Doc\Schema::TYPE_ARRAY, + 'items' => [ + 'type' => Doc\Schema::TYPE_OBJECT, + 'x-full-schema' => 'Group', + 'x-join' => [ + 'table' => 'glpi_groups', // The table with the desired data + 'fkey' => 'groups_id', + 'field' => 'id', + 'ref-join' => [ + 'table' => 'glpi_groups_assets', + 'fkey' => 'id', + 'field' => 'items_id', + 'condition' => [ + 'itemtype' => Software::class, + 'type' => 0 // Normal + ] + ] + ], + 'properties' => [ + 'id' => [ + 'type' => Doc\Schema::TYPE_INTEGER, + 'format' => Doc\Schema::FORMAT_INTEGER_INT64, + 'description' => 'ID', + ], + 'name' => ['type' => Doc\Schema::TYPE_STRING], + ] + ] + ], 'user_tech' => self::getDropdownTypeSchema(class: User::class, field: 'users_id_tech', full_schema: 'User'), - 'group_tech' => self::getDropdownTypeSchema(class: Group::class, field: 'groups_id_tech', full_schema: 'Group'), + 'group_tech' => [ + 'type' => Doc\Schema::TYPE_ARRAY, + 'items' => [ + 'type' => Doc\Schema::TYPE_OBJECT, + 'x-full-schema' => 'Group', + 'x-join' => [ + 'table' => 'glpi_groups', // The table with the desired data + 'fkey' => 'groups_id', + 'field' => 'id', + 'ref-join' => [ + 'table' => 'glpi_groups_assets', + 'fkey' => 'id', + 'field' => 'items_id', + 'condition' => [ + 'itemtype' => Software::class, + 'type' => 1 // Tech + ] + ] + ], + 'properties' => [ + 'id' => [ + 'type' => Doc\Schema::TYPE_INTEGER, + 'format' => Doc\Schema::FORMAT_INTEGER_INT64, + 'description' => 'ID', + ], + 'name' => ['type' => Doc\Schema::TYPE_STRING], + ] + ] + ], 'is_deleted' => ['type' => Doc\Schema::TYPE_BOOLEAN], 'is_update' => ['type' => Doc\Schema::TYPE_BOOLEAN], 'is_valid' => ['type' => Doc\Schema::TYPE_BOOLEAN], diff --git a/src/Link.php b/src/Link.php index 7e7b75f7de22..776f99fdd51d 100644 --- a/src/Link.php +++ b/src/Link.php @@ -36,6 +36,7 @@ use Glpi\Application\View\TemplateRenderer; use Glpi\ContentTemplates\TemplateManager; use Glpi\DBAL\QueryExpression; +use Glpi\Features\AssignableAsset; use Glpi\Toolbox\URL; /** @@ -438,10 +439,21 @@ public static function generateLinkContents($link, CommonDBTM $item, bool $safe_ 'DOMAIN' => '', 'NETWORK' => $item->isField('networks_id') ? Dropdown::getDropdownName('glpi_networks', $item->getField('networks_id')) : '', 'USER' => $item->isField('users_id') ? Dropdown::getDropdownName('glpi_users', $item->getField('users_id')) : '', - 'GROUP' => $item->isField('groups_id') ? Dropdown::getDropdownName('glpi_groups', $item->getField('groups_id')) : '', 'REALNAME' => $item->isField('realname') ? $item->getField('realname') : '', 'FIRSTNAME' => $item->isField('firstname') ? $item->getField('firstname') : '', ]; + if (Toolbox::hasTrait($item::class, AssignableAsset::class)) { + if (in_array(0, $item->getGroupTypes(), true)) { + $group_names = array_map(static fn ($group_id) => Dropdown::getDropdownName('glpi_groups', $group_id), $item->fields['groups_id']); + $vars['GROUPS'] = $group_names; + // GROUP - BC for < GLPI 11 + $vars['GROUP'] = count($group_names) > 0 ? array_shift($group_names) : ''; + } + } else { + $vars['GROUPS'] = []; + // GROUP - BC for < GLPI 11 + $vars['GROUP'] = $item->isField('groups_id') ? Dropdown::getDropdownName('glpi_groups', $item->getField('groups_id')) : ''; + } $item_fields = $item->fields; $item::unsetUndisclosedFields($item_fields); if (count($item_fields)) { diff --git a/src/Search/Provider/SQLProvider.php b/src/Search/Provider/SQLProvider.php index 5d0cdb8de064..14a13245d531 100644 --- a/src/Search/Provider/SQLProvider.php +++ b/src/Search/Provider/SQLProvider.php @@ -1001,7 +1001,10 @@ public static function getDefaultWhereCriteria(string $itemtype): array if (Toolbox::hasTrait($itemtype, AssignableAsset::class)) { /** @var AssignableAsset $itemtype */ - $criteria[] = $itemtype::getAssignableVisiblityCriteria(); + $visibility_criteria = $itemtype::getAssignableVisiblityCriteria(); + if (count($visibility_criteria)) { + $criteria[] = $visibility_criteria; + } } /* Hook to restrict user right on current itemtype */ diff --git a/tests/functional/CartridgeItem.php b/tests/functional/CartridgeItem.php index 94263dcfc8dc..8c2afbe0ea1e 100644 --- a/tests/functional/CartridgeItem.php +++ b/tests/functional/CartridgeItem.php @@ -49,49 +49,39 @@ public function testAddAndUpdateMultipleGroups() $cartridgeitem = $this->createItem(\CartridgeItem::class, [ 'name' => __FUNCTION__, 'entities_id' => $this->getTestRootEntity(true), - 'groups_id' => [1, 2], 'groups_id_tech' => [3, 4], - ], ['groups_id', 'groups_id_tech']); + ], ['groups_id_tech']); $cartridgeitems_id_1 = $cartridgeitem->fields['id']; - $this->array($cartridgeitem->fields['groups_id'])->containsValues([1, 2]); $this->array($cartridgeitem->fields['groups_id_tech'])->containsValues([3, 4]); $cartridgeitem = $this->createItem(\CartridgeItem::class, [ 'name' => __FUNCTION__, 'entities_id' => $this->getTestRootEntity(true), - 'groups_id' => null, 'groups_id_tech' => null, - ], ['groups_id', 'groups_id_tech']); + ], ['groups_id_tech']); $cartridgeitems_id_2 = $cartridgeitem->fields['id']; - $this->array($cartridgeitem->fields['groups_id'])->isEmpty(); $this->array($cartridgeitem->fields['groups_id_tech'])->isEmpty(); // Update both assets. Asset 1 will have the groups set to null and asset 2 will have the groups set to an array. $cartridgeitem->getFromDB($cartridgeitems_id_1); $this->boolean($cartridgeitem->update([ 'id' => $cartridgeitems_id_1, - 'groups_id' => null, 'groups_id_tech' => null, ]))->isTrue(); - $this->array($cartridgeitem->fields['groups_id'])->isEmpty(); $this->array($cartridgeitem->fields['groups_id_tech'])->isEmpty(); $cartridgeitem->getFromDB($cartridgeitems_id_2); $this->boolean($cartridgeitem->update([ 'id' => $cartridgeitems_id_2, - 'groups_id' => [5, 6], 'groups_id_tech' => [7, 8], ]))->isTrue(); - $this->array($cartridgeitem->fields['groups_id'])->containsValues([5, 6]); $this->array($cartridgeitem->fields['groups_id_tech'])->containsValues([7, 8]); // Test updating array to array $this->boolean($cartridgeitem->update([ 'id' => $cartridgeitems_id_2, - 'groups_id' => [1, 2], 'groups_id_tech' => [3, 4], ]))->isTrue(); - $this->array($cartridgeitem->fields['groups_id'])->containsValues([1, 2]); $this->array($cartridgeitem->fields['groups_id_tech'])->containsValues([3, 4]); } @@ -125,6 +115,7 @@ public function testLoadOldItemsSingleGroup() 'type' => 1 // Tech ], ); + $cartridgeitem->getFromDB($cartridgeitems_id); $this->array($cartridgeitem->fields['groups_id_tech']) ->hasSize(1) ->containsValues([2]); @@ -138,7 +129,6 @@ public function testGetEmptyMultipleGroups() { $cartridgeitem = new \CartridgeItem(); $cartridgeitem->getEmpty(); - $this->array($cartridgeitem->fields['groups_id'])->isEmpty(); $this->array($cartridgeitem->fields['groups_id_tech'])->isEmpty(); } } diff --git a/tests/functional/ConsumableItem.php b/tests/functional/ConsumableItem.php index 8f8d2da35e6f..863b14a02a48 100644 --- a/tests/functional/ConsumableItem.php +++ b/tests/functional/ConsumableItem.php @@ -49,49 +49,39 @@ public function testAddAndUpdateMultipleGroups() $consumableitem = $this->createItem(\ConsumableItem::class, [ 'name' => __FUNCTION__, 'entities_id' => $this->getTestRootEntity(true), - 'groups_id' => [1, 2], 'groups_id_tech' => [3, 4], - ], ['groups_id', 'groups_id_tech']); + ], ['groups_id_tech']); $consumableitems_id_1 = $consumableitem->fields['id']; - $this->array($consumableitem->fields['groups_id'])->containsValues([1, 2]); $this->array($consumableitem->fields['groups_id_tech'])->containsValues([3, 4]); $consumableitem = $this->createItem(\ConsumableItem::class, [ 'name' => __FUNCTION__, 'entities_id' => $this->getTestRootEntity(true), - 'groups_id' => null, 'groups_id_tech' => null, - ], ['groups_id', 'groups_id_tech']); + ], ['groups_id_tech']); $consumableitems_id_2 = $consumableitem->fields['id']; - $this->array($consumableitem->fields['groups_id'])->isEmpty(); $this->array($consumableitem->fields['groups_id_tech'])->isEmpty(); // Update both assets. Asset 1 will have the groups set to null and asset 2 will have the groups set to an array. $consumableitem->getFromDB($consumableitems_id_1); $this->boolean($consumableitem->update([ 'id' => $consumableitems_id_1, - 'groups_id' => null, 'groups_id_tech' => null, ]))->isTrue(); - $this->array($consumableitem->fields['groups_id'])->isEmpty(); $this->array($consumableitem->fields['groups_id_tech'])->isEmpty(); $consumableitem->getFromDB($consumableitems_id_2); $this->boolean($consumableitem->update([ 'id' => $consumableitems_id_2, - 'groups_id' => [5, 6], 'groups_id_tech' => [7, 8], ]))->isTrue(); - $this->array($consumableitem->fields['groups_id'])->containsValues([5, 6]); $this->array($consumableitem->fields['groups_id_tech'])->containsValues([7, 8]); // Test updating array to array $this->boolean($consumableitem->update([ 'id' => $consumableitems_id_2, - 'groups_id' => [1, 2], 'groups_id_tech' => [3, 4], ]))->isTrue(); - $this->array($consumableitem->fields['groups_id'])->containsValues([1, 2]); $this->array($consumableitem->fields['groups_id_tech'])->containsValues([3, 4]); } @@ -140,7 +130,6 @@ public function testGetEmptyMultipleGroups() { $consumableitem = new \ConsumableItem(); $consumableitem->getEmpty(); - $this->array($consumableitem->fields['groups_id'])->isEmpty(); $this->array($consumableitem->fields['groups_id_tech'])->isEmpty(); } } diff --git a/tests/functional/Glpi/Inventory/Inventory.php b/tests/functional/Glpi/Inventory/Inventory.php index 0166a2f0fb4e..efaf5fb811f9 100644 --- a/tests/functional/Glpi/Inventory/Inventory.php +++ b/tests/functional/Glpi/Inventory/Inventory.php @@ -81,7 +81,6 @@ private function checkComputer1($computers_id) 'contact' => 'trasher/root', 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'comment' => null, 'date_mod' => $computer->fields['date_mod'], 'autoupdatesystems_id' => $autoupdatesystems_id, @@ -95,7 +94,6 @@ private function checkComputer1($computers_id) 'is_deleted' => 0, 'is_dynamic' => 1, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'uuid' => '4c4c4544-0034-3010-8048-b6c04f503732', @@ -103,6 +101,8 @@ private function checkComputer1($computers_id) 'is_recursive' => 0, 'last_inventory_update' => $computer->fields['last_inventory_update'], 'last_boot' => '2020-06-09 07:58:08', + 'groups_id' => [], + 'groups_id_tech' => [], ]; $this->array($computer->fields)->isIdenticalTo($expected); @@ -157,7 +157,6 @@ private function checkComputer1($computers_id) 'contact' => 'trasher/root', 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'comment' => null, 'serial' => 'ABH55D', 'otherserial' => null, @@ -179,7 +178,6 @@ private function checkComputer1($computers_id) 'is_template' => 0, 'template_name' => null, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'is_dynamic' => 1, @@ -856,7 +854,6 @@ private function checkComputer1($computers_id) 'contact' => 'trasher/root', 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'serial' => 'MY47L1W1JHEB6', 'otherserial' => null, 'have_serial' => 0, @@ -878,7 +875,6 @@ private function checkComputer1($computers_id) 'init_pages_counter' => 0, 'last_pages_counter' => 0, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'is_dynamic' => 1, @@ -1273,7 +1269,6 @@ public function testUpdateComputer() 'contact' => 'johan', 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'comment' => null, 'date_mod' => $computer->fields['date_mod'], 'autoupdatesystems_id' => $autoupdatesystems_id, @@ -1287,7 +1282,6 @@ public function testUpdateComputer() 'is_deleted' => 0, 'is_dynamic' => 1, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'uuid' => '0055ADC9-1D3A-E411-8043-B05D95113232', @@ -1295,6 +1289,8 @@ public function testUpdateComputer() 'is_recursive' => 0, 'last_inventory_update' => $computer->fields['last_inventory_update'], 'last_boot' => "2017-02-20 08:11:53", + 'groups_id' => [], + 'groups_id_tech' => [], ]; $this->array($computer->fields)->isIdenticalTo($expected); @@ -1486,7 +1482,6 @@ public function testUpdateComputer() 'contact' => 'johan', 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'comment' => null, 'date_mod' => $computer->fields['date_mod'], 'autoupdatesystems_id' => $autoupdatesystems_id, @@ -1500,7 +1495,6 @@ public function testUpdateComputer() 'is_deleted' => 0, 'is_dynamic' => 1, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'uuid' => '0055ADC9-1D3A-E411-8043-B05D95113232', @@ -1508,6 +1502,8 @@ public function testUpdateComputer() 'is_recursive' => 0, 'last_inventory_update' => $computer->fields['last_inventory_update'], 'last_boot' => "2017-02-20 08:11:53", + 'groups_id' => [], + 'groups_id_tech' => [], ]; $this->array($computer->fields)->isIdenticalTo($expected); @@ -1647,7 +1643,6 @@ public function testUpdateComputer() 'contact' => 'johan', 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'comment' => null, 'date_mod' => $computer->fields['date_mod'], 'autoupdatesystems_id' => $autoupdatesystems_id, @@ -1661,7 +1656,6 @@ public function testUpdateComputer() 'is_deleted' => 0, 'is_dynamic' => 1, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'uuid' => '0055ADC9-1D3A-E411-8043-B05D95113232', @@ -1669,6 +1663,8 @@ public function testUpdateComputer() 'is_recursive' => 0, 'last_inventory_update' => $computer->fields['last_inventory_update'], 'last_boot' => "2017-06-08 07:06:47", + 'groups_id' => [], + 'groups_id_tech' => [], ]; $this->array($computer->fields)->isIdenticalTo($expected); @@ -1909,7 +1905,6 @@ public function testImportNetworkEquipment() 'contact' => 'noc@glpi-project.org', 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'date_mod' => $equipment->fields['date_mod'], 'comment' => null, 'locations_id' => $locations_id, @@ -1921,7 +1916,6 @@ public function testImportNetworkEquipment() 'is_template' => 0, 'template_name' => null, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'is_dynamic' => 1, @@ -1933,6 +1927,8 @@ public function testImportNetworkEquipment() 'uptime' => '482 days, 05:42:18.50', 'last_inventory_update' => $date_now, 'snmpcredentials_id' => 4, + 'groups_id' => [], + 'groups_id_tech' => [], ]; $this->array($equipment->fields)->isIdenticalTo($expected); @@ -2252,7 +2248,6 @@ public function testImportStackedNetworkEquipment() 'contact' => null, 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'date_mod' => null, 'comment' => null, 'locations_id' => $locations_id, @@ -2264,7 +2259,6 @@ public function testImportStackedNetworkEquipment() 'is_template' => 0, 'template_name' => null, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'is_dynamic' => 1, @@ -2737,7 +2731,6 @@ public function testImportNetworkEquipmentMultiConnections() 'contact' => null, 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'date_mod' => null, 'comment' => null, 'locations_id' => $locations_id, @@ -2749,7 +2742,6 @@ public function testImportNetworkEquipmentMultiConnections() 'is_template' => 0, 'template_name' => null, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'is_dynamic' => 1, @@ -3414,7 +3406,6 @@ public function testImportNetworkEquipmentWireless() 'contact' => null, 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'date_mod' => null, 'comment' => null, 'locations_id' => $locations_id, @@ -3426,7 +3417,6 @@ public function testImportNetworkEquipmentWireless() 'is_template' => 0, 'template_name' => null, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'is_dynamic' => 1, @@ -3793,7 +3783,6 @@ public function testImportNetworkEquipmentWAggregatedPorts() 'contact' => 'noc@glpi-project.org', 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'date_mod' => $equipment->fields['date_mod'], 'comment' => null, 'locations_id' => $locations_id, @@ -3805,7 +3794,6 @@ public function testImportNetworkEquipmentWAggregatedPorts() 'is_template' => 0, 'template_name' => null, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'is_dynamic' => 1, @@ -3817,6 +3805,8 @@ public function testImportNetworkEquipmentWAggregatedPorts() 'uptime' => '65 days, 20:13:08.93', 'last_inventory_update' => $date_now, 'snmpcredentials_id' => 0, + 'groups_id' => [], + 'groups_id_tech' => [], ]; $this->array($equipment->fields)->isIdenticalTo($expected); @@ -5157,7 +5147,6 @@ public function testImportPhone() 'contact' => 'builder', 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'comment' => null, 'serial' => 'af8d8fcfa6fa4794', 'otherserial' => 'release-keys', @@ -5175,7 +5164,6 @@ public function testImportPhone() 'is_template' => 0, 'template_name' => null, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'is_dynamic' => 1, @@ -5184,6 +5172,8 @@ public function testImportPhone() 'date_creation' => $phone->fields['date_creation'], 'is_recursive' => 0, 'last_inventory_update' => $phone->fields['last_inventory_update'], + 'groups_id' => [], + 'groups_id_tech' => [], ]; $this->array($phone->fields)->isIdenticalTo($expected); @@ -5511,7 +5501,7 @@ public function testImportPhone() 'locations_id' => 0, 'lines_id' => 0, 'users_id' => 0, - 'groups_id' => 0, + 'groups_id' => [], 'pin' => '', 'pin2' => '', 'puk' => '', diff --git a/tests/functional/Link.php b/tests/functional/Link.php index 77cfc9eafaf2..585f01bb64ee 100644 --- a/tests/functional/Link.php +++ b/tests/functional/Link.php @@ -64,7 +64,7 @@ protected function linkContentProvider(): iterable 'locations_id' => getItemByTypeName(\Location::class, '_location01', true), 'networks_id' => $network->getID(), 'users_id' => getItemByTypeName(\User::class, 'glpi', true), - ] + ], ['groups_id'] ); // Attach domains diff --git a/tests/functional/Monitor.php b/tests/functional/Monitor.php index c2a761b59e24..81765a0cf621 100644 --- a/tests/functional/Monitor.php +++ b/tests/functional/Monitor.php @@ -51,7 +51,6 @@ private static function getMonitorFields($id, $date) 'contact' => null, 'contact_num' => null, 'users_id_tech' => 0, - 'groups_id_tech' => 0, 'comment' => null, 'serial' => null, 'otherserial' => null, @@ -73,7 +72,6 @@ private static function getMonitorFields($id, $date) 'is_template' => 0, 'template_name' => null, 'users_id' => 0, - 'groups_id' => 0, 'states_id' => 0, 'ticket_tco' => '0.0000', 'is_dynamic' => 0, @@ -81,6 +79,8 @@ private static function getMonitorFields($id, $date) 'date_creation' => $date, 'is_recursive' => 0, 'uuid' => null, + 'groups_id' => [], + 'groups_id_tech' => [], ]; } diff --git a/tests/functional/Search.php b/tests/functional/Search.php index 1ee5e969e595..2bd34f2b75b8 100644 --- a/tests/functional/Search.php +++ b/tests/functional/Search.php @@ -43,6 +43,7 @@ use Document; use Document_Item; use Glpi\Asset\Capacity\HasDocumentsCapacity; +use Glpi\Features\AssignableAsset; use Group_User; use Psr\Log\LogLevel; use Ticket; @@ -1721,6 +1722,10 @@ public function testAllAssetsFields() $table = getTableForItemType($itemtype); foreach ($needed_fields as $field) { + if (\Toolbox::hasTrait($itemtype, AssignableAsset::class) && str_starts_with($field, 'groups_id')) { + // The group fields don't exist in the main table for these assets + continue; + } $this->boolean($DB->fieldExists($table, $field)) ->isTrue("$table.$field is missing"); }