|
| 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\Tests; |
| 34 | + |
| 35 | +use GlpiPlugin\Carbon\Report; |
| 36 | +use Session; |
| 37 | +use Symfony\Component\DomCrawler\Crawler; |
| 38 | + |
| 39 | +class ReportTest extends DbTestCase |
| 40 | +{ |
| 41 | + /** |
| 42 | + * @covers GlpiPlugin\Carbon\Report::getTypeName |
| 43 | + * |
| 44 | + * @return void |
| 45 | + */ |
| 46 | + public function testGetTypeName() |
| 47 | + { |
| 48 | + $result = Report::getTypeName(1); |
| 49 | + $this->assertEquals('Carbon report', $result); |
| 50 | + |
| 51 | + $result = Report::getTypeName(Session::getPluralNumber()); |
| 52 | + $this->assertEquals('Carbon reports', $result); |
| 53 | + } |
| 54 | + |
| 55 | + public function testGetIcon() |
| 56 | + { |
| 57 | + $result = Report::getIcon(); |
| 58 | + $this->assertEquals('fa-solid fa-solar-panel', $result); |
| 59 | + } |
| 60 | + |
| 61 | + public function testGetMenuContent() |
| 62 | + { |
| 63 | + $this->login('glpi', 'glpi'); |
| 64 | + $result = Report::getMenuContent(); |
| 65 | + $this->assertIsArray($result); |
| 66 | + $this->assertEquals('Carbon reports', $result['title']); |
| 67 | + $this->assertEquals('fa-solid fa-solar-panel', $result['icon']); |
| 68 | + } |
| 69 | + |
| 70 | + public function testShowInstantReport() |
| 71 | + { |
| 72 | + $this->login('glpi', 'glpi'); |
| 73 | + $_SERVER['REQUEST_URI'] = '/ajax/dashboard.php'; |
| 74 | + ob_start(); |
| 75 | + Report::showInstantReport(); |
| 76 | + $output = ob_get_clean(); |
| 77 | + $crawler = new Crawler($output); |
| 78 | + $this->assertCount(1, $crawler->filter('div.plugin_carbon_quick_report')); |
| 79 | + $this->assertCount(1, $crawler->filter('div.dashboard.mini')); |
| 80 | + } |
| 81 | +} |
0 commit comments