Skip to content

Commit

Permalink
fix kb id in templates
Browse files Browse the repository at this point in the history
  • Loading branch information
cconard96 committed Jul 18, 2024
1 parent 9f7d538 commit cc6ae83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ContentTemplates/Parameters/TicketParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ protected function defineValues(CommonDBTM $ticket): array
$kbis = KnowbaseItem_Item::getItems($ticket);
$values['knowbaseitems'] = [];
foreach ($kbis as $data) {
if ($kbi = KnowbaseItem::getById($data['id'])) {
if ($kbi = KnowbaseItem::getById($data[KnowbaseItem::getForeignKeyField()])) {
$kbi_parameters = new KnowbaseItemParameters();
$values['knowbaseitems'][] = $kbi_parameters->getValues($kbi);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function testGetValues(): void
$suppliers_id = getItemByTypeName('Supplier', '_suplier01_name', true);

$now = date('Y-m-d H:i:s');
$this->createItem('Ticket', [
$created_ticket = $this->createItem('Ticket', [
'name' => 'ticket_testGetValues',
'content' => '<p>ticket_testGetValues content</p>',
'entities_id' => $test_entity_id,
Expand All @@ -114,8 +114,13 @@ public function testGetValues(): void
'_groups_id_assign' => [$assigned_groups_id],
'_suppliers_id_assign' => [$suppliers_id],
]);
$tickets_id = $created_ticket->getID();

$tickets_id = getItemByTypeName('Ticket', 'ticket_testGetValues', true);
$this->createItem(\KnowbaseItem_Item::class, [
'knowbaseitems_id' => getItemByTypeName(\KnowbaseItem::class, '_knowbaseitem01', true),
'itemtype' => 'Ticket',
'items_id' => $tickets_id,
]);

$parameters = $this->newTestedInstance();
$values = $parameters->getValues(getItemByTypeName('Ticket', 'ticket_testGetValues'));
Expand Down Expand Up @@ -247,7 +252,14 @@ public function testGetValues(): void
'name' => 'location_testGetValues',
'completename' => 'location_testGetValues',
],
'knowbaseitems' => [],
'knowbaseitems' => [
[
'id' => getItemByTypeName(\KnowbaseItem::class, '_knowbaseitem01', true),
'name' => '_knowbaseitem01',
'answer' => "Answer for Knowledge base entry _knowbaseitem01 apple juice turnover",
'link' => "<a href='/glpi/front/knowbaseitem.form.php?id=1' title=\"_knowbaseitem01\">_knowbaseitem01</a>"
]
],
'assets' => [],
]);

Expand Down

0 comments on commit cc6ae83

Please sign in to comment.