3939use PHPUnit \Framework \Attributes \CoversClass ;
4040
4141#[CoversClass(AbstractEmbodiedImpact::class)]
42- class AbstractEmbodiedImpactTest extends DbTestCase
42+ class AbstractCommonEmbodiedImpactTest extends DbTestCase
4343{
4444 protected static string $ itemtype = '' ;
4545 protected static string $ itemtype_type = '' ;
4646 protected static string $ itemtype_model = '' ;
4747
48- public function testGetItemsToEvaluate ()
48+ public static function setUpBeforeClass (): void
4949 {
5050 if (static ::$ itemtype === '' || static ::$ itemtype_type === '' || static ::$ itemtype_model === '' ) {
5151 // Ensure that the inherited test class is properly implemented for this test
52- $ this -> fail ('Itemtype properties not set in ' . static ::class);
52+ self :: fail ('Itemtype properties not set in ' . static ::class);
5353 }
54+ }
5455
56+ public function test_GetItemsToEvaluate_evaluates_asset_when_no_embodied_impact_exists ()
57+ {
5558 // Test the asset is evaluable when no embodied impact is in the DB
5659 $ glpi_asset_type = $ this ->createItem (static ::$ itemtype_type );
5760 $ asset_type = $ this ->createItem ('GlpiPlugin \\Carbon \\' . static ::$ itemtype_type , [
@@ -64,7 +67,10 @@ public function testGetItemsToEvaluate()
6467 $ asset ->getTableField ('id ' ) => $ asset ->getID (),
6568 ]);
6669 $ this ->assertEquals (1 , $ iterator ->count ());
70+ }
6771
72+ public function test_GetItemsToEvaluate_does_not_evaluates_asset_when_embodied_impact_exists ()
73+ {
6874 // Test the asset is no longer evaluable when there is embodied impact in the DB
6975 $ glpi_asset_type = $ this ->createItem (static ::$ itemtype_type );
7076 $ asset_type = $ this ->createItem ('GlpiPlugin \\Carbon \\' . static ::$ itemtype_type , [
@@ -82,8 +88,11 @@ public function testGetItemsToEvaluate()
8288 $ asset ::getTableField ('id ' ) => $ asset ->getID (),
8389 ]);
8490 $ this ->assertEquals (0 , $ iterator ->count ());
91+ }
8592
86- // Test the asset is evaluable when there is embodied impact in the DB but recamculate is set
93+ public function test_GetItemsToEvaluate_evaluates_asset_when_embodied_impact_exists_and_marked_for_recalculation ()
94+ {
95+ // Test the asset is evaluable when there is embodied impact in the DB but recalculate is set
8796 $ glpi_asset_type = $ this ->createItem (static ::$ itemtype_type );
8897 $ asset_type = $ this ->createItem ('GlpiPlugin \\Carbon \\' . static ::$ itemtype_type , [
8998 getForeignKeyFieldForItemType (static ::$ itemtype_type ) => $ glpi_asset_type ->getID (),
0 commit comments