|
| 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\ComputerUsageProfile; |
| 36 | +use GlpiPlugin\Carbon\Profile; |
| 37 | +use GlpiPlugin\Carbon\UsageInfo; |
| 38 | +use Computer as GlpiComputer; |
| 39 | +use Contact; |
| 40 | +use Symfony\Component\DomCrawler\Crawler; |
| 41 | + |
| 42 | +class UsageInfoTest extends DbTestCase |
| 43 | +{ |
| 44 | + /** |
| 45 | + * @covers GlpiPlugin\Carbon\UsageInfo::getTypeName |
| 46 | + * |
| 47 | + * @return void |
| 48 | + */ |
| 49 | + public function testGetTypeName() |
| 50 | + { |
| 51 | + $usageInfo = new UsageInfo(); |
| 52 | + $typeName = $usageInfo->getTypeName(); |
| 53 | + $this->assertEquals(__('Usage informations', 'Carbon'), $typeName); |
| 54 | + } |
| 55 | + |
| 56 | + /** |
| 57 | + * @covers GlpiPlugin\Carbon\UsageInfo::getIcon |
| 58 | + * |
| 59 | + * @return void |
| 60 | + */ |
| 61 | + public function testGetIcon() |
| 62 | + { |
| 63 | + $usageInfo = new UsageInfo(); |
| 64 | + $icon = $usageInfo->getIcon(); |
| 65 | + $this->assertEquals('fa-solid fa-solar-panel', $icon); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * @covers GlpiPlugin\Carbon\UsageInfo::getTabNameForItem |
| 70 | + * |
| 71 | + * @return void |
| 72 | + */ |
| 73 | + public function testGetTabNameForItem() |
| 74 | + { |
| 75 | + $usageInfo = new UsageInfo(); |
| 76 | + $item = new GlpiComputer(); |
| 77 | + $tabName = $usageInfo->getTabNameForItem($item); |
| 78 | + $this->assertEquals('Environmental impact', $tabName); |
| 79 | + |
| 80 | + $item = new Contact(); |
| 81 | + $tabName = $usageInfo->getTabNameForItem($item); |
| 82 | + $this->assertEquals('', $tabName); |
| 83 | + } |
| 84 | +} |
0 commit comments