4242use DbUtils ;
4343use DisplayPreference ;
4444use Glpi \Dashboard \Dashboard ;
45+ use Glpi \Dashboard \Grid ;
4546use Glpi \Dashboard \Item ;
4647use Glpi \Dashboard \Right ;
4748use Glpi \DBAL \QueryExpression as QueryExpression ;
6768use NetworkEquipmentType ;
6869use PHPUnit \Framework \Attributes \CoversClass ;
6970use PHPUnit \Framework \Attributes \CoversNothing ;
71+ use PHPUnit \Framework \Attributes \Depends ;
7072use Plugin ;
7173use Profile ;
7274use ProfileRight ;
@@ -117,7 +119,8 @@ protected function executeInstallation()
117119 ob_start ();
118120 $ plugin ->install ($ plugin ->fields ['id ' ]);
119121 $ install_output = ob_get_clean ();
120- $ this ->assertTrue ($ plugin ->isInstalled ($ plugin_name ), $ install_output );
122+ $ session_messages = implode (PHP_EOL , $ _SESSION ['MESSAGE_AFTER_REDIRECT ' ][ERROR ] ?? []);
123+ $ this ->assertTrue ($ plugin ->isInstalled ($ plugin_name ), $ install_output . PHP_EOL . $ session_messages );
121124
122125 // Enable the plugin
123126 $ success = $ plugin ->activate ($ plugin ->fields ['id ' ]);
@@ -144,7 +147,6 @@ public function testInstallPlugin()
144147
145148 $ this ->checkConfig ();
146149 $ this ->checkAutomaticAction ();
147- $ this ->checkDashboard ();
148150 $ this ->checkRights ();
149151 $ this ->checkInitialDataSources ();
150152 $ this ->checkInitialZones ();
@@ -510,7 +512,7 @@ private function checkPredefinedUsageProfiles()
510512 $ this ->assertEquals (2 , count ($ rows ));
511513 }
512514
513- public function checkBuitFiles ()
515+ public function checkBuiltFiles ()
514516 {
515517 global $ PLUGIN_HOOKS ;
516518
@@ -523,7 +525,8 @@ public function checkBuitFiles()
523525 $ this ->assertTrue (in_array ('lib/apexcharts.js ' , $ PLUGIN_HOOKS [Hooks::ADD_JAVASCRIPT ]['carbon ' ]));
524526 }
525527
526- public function checkDashboard ()
528+ #[Depends('testInstallPlugin ' )]
529+ public function test_dashboard_is_configured ()
527530 {
528531 /** @var DBmysql $DB */
529532 global $ DB ;
@@ -581,6 +584,16 @@ public function checkDashboard()
581584 'dashboards_dashboards_id ' => $ dashboard ->fields ['id ' ],
582585 ]);
583586 $ this ->assertCount ($ expected_cards_count , $ rows );
587+
588+ // Check that all cards actually generate a valid content
589+ // Let the plugin believe we are viewing the reporting page
590+ $ _SERVER ['REQUEST_URI ' ] = 'https://localhost/carbon/front/report.php ' ;
591+ $ grid = new Grid ();
592+ foreach ($ rows as $ row ) {
593+ $ dashboardItem ->getFromDB ($ row ['id ' ]);
594+ $ html = $ grid ->getCardHtml ($ row ['card_id ' ], ['args ' => json_decode ($ row ['card_options ' ], true )]);
595+ $ this ->assertStringNotContainsString ('empty card! ' , $ html , "Card with id {$ row ['card_id ' ]} returns empty content " );
596+ }
584597 }
585598
586599 private $ zones = [
0 commit comments