Skip to content

Commit 86c8a05

Browse files
committed
test(Impact\Embodied\Engine,Impact\Usage\Engine): add tests
1 parent fa1cdab commit 86c8a05

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
/**
4+
* -------------------------------------------------------------------------
5+
* Carbon plugin for GLPI
6+
*
7+
* @copyright Copyright (C) 2024-2025 Teclib' and contributors.
8+
* @license https://www.gnu.org/licenses/gpl-3.0.txt GPLv3+
9+
* @link https://github.com/pluginsGLPI/carbon
10+
*
11+
* -------------------------------------------------------------------------
12+
*
13+
* LICENSE
14+
*
15+
* This file is part of Carbon plugin for GLPI.
16+
*
17+
* This program is free software: you can redistribute it and/or modify
18+
* it under the terms of the GNU General Public License as published by
19+
* the Free Software Foundation, either version 3 of the License, or
20+
* (at your option) any later version.
21+
*
22+
* This program is distributed in the hope that it will be useful,
23+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
24+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25+
* GNU General Public License for more details.
26+
*
27+
* You should have received a copy of the GNU General Public License
28+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
29+
*
30+
* -------------------------------------------------------------------------
31+
*/
32+
33+
namespace GlpiPlugin\Carbon\Impact\Usage\Tests;
34+
35+
use Computer as GlpiComputer;
36+
use Monitor as GlpiMonitor;
37+
use NetworkEquipment as GlpiNetworkEquipment;
38+
use Config as GlpiConfig;
39+
use GlpiPlugin\Carbon\DataSource\RestApiClient;
40+
use GlpiPlugin\Carbon\Tests\DbTestCase;
41+
use GlpiPlugin\Carbon\Impact\Usage\Boavizta\Computer;
42+
use GlpiPlugin\Carbon\Impact\Usage\Boavizta\Monitor;
43+
use GlpiPlugin\Carbon\Impact\Usage\Engine;
44+
45+
class EngineTest extends DbTestCase
46+
{
47+
public function testGetEngineFromItemtypeForBoavizta()
48+
{
49+
GlpiConfig::setConfigurationValues('plugin:carbon', [
50+
'boaviztapi_base_url' => 'http://localhost:5000'
51+
]);
52+
$version_response = [
53+
'1.3.11',
54+
];
55+
$client_stub = $this->getMockBuilder(RestApiClient::class)
56+
->getMock();
57+
$client_stub->method('request')->willReturn($version_response);
58+
59+
$itemtype = GlpiComputer::class;
60+
$result = Engine::getEngineFromItemtype($itemtype, $client_stub);
61+
$this->assertTrue($result instanceof Computer);
62+
63+
$itemtype = GlpiMonitor::class;
64+
$result = Engine::getEngineFromItemtype($itemtype, $client_stub);
65+
$this->assertTrue($result instanceof Monitor);
66+
67+
// This case returns null, as Boavizta does not provide data
68+
$itemtype = GlpiNetworkEquipment::class;
69+
$result = Engine::getEngineFromItemtype($itemtype, $client_stub);
70+
$this->assertNull($result);
71+
}
72+
}

0 commit comments

Comments
 (0)