diff --git a/templates/history/status-item.html.twig b/templates/history/status-item.html.twig
index 8031a6a2..469bbd2b 100644
--- a/templates/history/status-item.html.twig
+++ b/templates/history/status-item.html.twig
@@ -193,6 +193,14 @@
{{ fields.field('', field, __('The asset has a category', 'carbon')) }}
{% endif %}
+ {% if status.is_category_not_cloud is defined %}
+ {% set field = nok_field %}
+ {% if status.is_category_not_cloud %}
+ {% set field = ok_field %}
+ {% endif %}
+ {{ fields.field('', field, __('The asset is not in a cloud', 'carbon')) }}
+ {% endif %}
+
{% if status.has_usage_profile is defined %}
{% set field = nok_field %}
{% if status.has_usage_profile %}
diff --git a/tests/src/CommonTestCase.php b/tests/src/CommonTestCase.php
index 35abfb7a..97d2e182 100644
--- a/tests/src/CommonTestCase.php
+++ b/tests/src/CommonTestCase.php
@@ -64,7 +64,7 @@ class CommonTestCase extends TestCase
/** @var int $debugMode save state of GLPI debug mode */
private $debugMode = null;
- protected $str = null;
+ protected ?string $str = null;
protected function disableDebug()
{
@@ -115,7 +115,7 @@ protected function setupGLPIFramework(): void
return;
}
- protected function login($name, $password, $noauto = false)
+ protected function login(string $name, string $password, $noauto = false)
{
Session::start();
$auth = new Auth();
@@ -539,7 +539,7 @@ protected function isolateInEntity(): int
*
* @return mixed
*/
- protected function callPrivateMethod($instance, string $methodName, ...$args)
+ protected function callPrivateMethod($instance, string $methodName, mixed ...$args)
{
$method = new ReflectionMethod($instance, $methodName);
if (version_compare(PHP_VERSION, '8.1.0') < 0) {
diff --git a/tests/units/DataSource/CarbonIntensity/ElectricityMaps/ConfigTest.php b/tests/units/DataSource/CarbonIntensity/ElectricityMaps/ConfigTest.php
index da22ef07..034a2347 100644
--- a/tests/units/DataSource/CarbonIntensity/ElectricityMaps/ConfigTest.php
+++ b/tests/units/DataSource/CarbonIntensity/ElectricityMaps/ConfigTest.php
@@ -99,10 +99,6 @@ public function testConfigUpdate(array $input, array $expected)
/** @var array $CFG_GLPI */
global $CFG_GLPI;
- $CFG_GLPI['plugi:carbon']['lca_datasources'] = [
- Client::class,
- ];
-
$instance = new Config();
$result = $instance->configUpdate($input);
$this->assertEquals($expected, $result);
diff --git a/tests/units/DataSource/Lca/Boaviztapi/ConfigTest.php b/tests/units/DataSource/Lca/Boaviztapi/ConfigTest.php
index 7f5249e1..ef3a40b7 100644
--- a/tests/units/DataSource/Lca/Boaviztapi/ConfigTest.php
+++ b/tests/units/DataSource/Lca/Boaviztapi/ConfigTest.php
@@ -124,10 +124,6 @@ public function testConfigUpdate(array $input, array $expected)
/** @var array $CFG_GLPI */
global $CFG_GLPI;
- $CFG_GLPI['plugi:carbon']['lca_datasources'] = [
- Client::class,
- ];
-
$result = (new Config())->configUpdate($input);
$this->assertEquals($expected, $result);
}
diff --git a/tests/units/Impact/History/ComputerTest.php b/tests/units/Impact/History/ComputerTest.php
index 260850e2..2dbc1b56 100644
--- a/tests/units/Impact/History/ComputerTest.php
+++ b/tests/units/Impact/History/ComputerTest.php
@@ -290,6 +290,7 @@ public function test_getHistorizableDiagnosis_when_computer_is_historizable()
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -328,6 +329,7 @@ public function test_getHistorizableDiagnosis_when_computer_is_deleted()
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -366,6 +368,7 @@ public function test_getHistorizableDiagnosis_when_computer_is_template()
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -404,6 +407,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_usage_profile
'has_usage_profile' => false,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -442,6 +446,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_location()
'has_usage_profile' => true,
'has_location' => false,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => false, // No location cascades this requirement to be not met
'has_model' => true,
'has_model_power_consumption' => true,
@@ -480,6 +485,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_category()
'has_usage_profile' => true,
'has_location' => true,
'has_category' => false,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -518,6 +524,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_carbon_intens
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => false,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -556,6 +563,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_model()
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => false,
'has_model_power_consumption' => false,
@@ -594,6 +602,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_model_power_c
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => false,
@@ -632,6 +641,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_type()
'has_usage_profile' => true,
'has_location' => true,
'has_category' => false,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -670,6 +680,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_type_power_co
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -708,6 +719,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_inventory_ent
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -746,6 +758,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_carbon_intens
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -786,6 +799,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_carbon_intens
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -824,6 +838,7 @@ public function test_getHistorizableDiagnosis_when_computer_is_ignored()
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -863,6 +878,7 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_decommission_
'has_usage_profile' => true,
'has_location' => true,
'has_category' => true,
+ 'is__category_not_cloud' => true,
'has_carbon_intensity_zone' => true,
'has_model' => true,
'has_model_power_consumption' => true,
@@ -878,6 +894,46 @@ public function test_getHistorizableDiagnosis_when_computer_has_no_decommission_
$this->assertEquals($expected, $result);
}
+ public function test_getHistorizableDiagnosis_when_computer_has_cloud_category()
+ {
+ $history = new Computer();
+
+ [
+ $glpi_computer,
+ $glpi_location,
+ $location,
+ $source_zone,
+ $glpi_computer_model,
+ $glpi_computer_type,
+ $computer_type,
+ $infocom,
+ $usage_profile,
+ $zone,
+ ] = $this->getHistorizableComputer();
+ $this->updateItem($computer_type, ['category' => ComputerType::CATEGORY_CLOUD]);
+
+ $expected = [
+ 'is_deleted' => true,
+ 'is_template' => true,
+ 'has_usage_profile' => true,
+ 'has_location' => true,
+ 'has_category' => true,
+ 'is__category_not_cloud' => false,
+ 'has_carbon_intensity_zone' => true,
+ 'has_model' => true,
+ 'has_model_power_consumption' => true,
+ 'has_type' => true,
+ 'has_type_power_consumption' => true,
+ 'has_inventory_entry_date' => true,
+ 'ci_download_enabled' => true,
+ 'ci_fallback_available' => true,
+ 'not_is_ignore' => true,
+ 'has_decommission_date' => true,
+ ];
+ $result = $history->getHistorizableDiagnosis($glpi_computer);
+ $this->assertEquals($expected, $result);
+ }
+
public function testComputerWithEverythingIsHistorizable()
{
$history = new Computer();
@@ -932,6 +988,7 @@ public function testComputerWithEverythingIsHistorizable()
'has_type_power_consumption' => true,
'has_usage_profile' => true,
'has_category' => false,
+ 'is__category_not_cloud' => true,
'has_inventory_entry_date' => true,
'ci_download_enabled' => true,
'ci_fallback_available' => true,