Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
fix(fleet): hide policies tab for not managed fleets
Browse files Browse the repository at this point in the history
see #195
  • Loading branch information
btry authored and ajsb85 committed Nov 20, 2017
1 parent bb64c92 commit 250cbeb
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
4 changes: 3 additions & 1 deletion inc/fleet.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public function defineTabs($options = []) {
$this->addDefaultFormTab($tab);
if (!$this->isNewItem()) {
$this->addStandardTab(PluginFlyvemdmAgent::class, $tab, $options);
$this->addStandardTab(PluginFlyvemdmTask::class, $tab, $options);
if ($this->fields['is_default'] == '0') {
$this->addStandardTab(PluginFlyvemdmTask::class, $tab, $options);
}
$this->addStandardTab(Notepad::class, $tab, $options);
$this->addStandardTab(Log::class, $tab, $options);
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/suite-integration/PluginFlyvemdmAgent.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function beforeTestMethod($method) {
$this->resetState();
parent::beforeTestMethod($method);
$this->setupGLPIFramework();
$this->login('glpi', 'glpi');
$this->boolean($this->login('glpi', 'glpi'))->isTrue();
}

/**
Expand Down
70 changes: 70 additions & 0 deletions tests/suite-unit/PluginFlyvemdmFleet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php
/**
* LICENSE
*
* Copyright © 2016-2017 Teclib'
* Copyright © 2010-2016 by the FusionInventory Development Team.
*
* This file is part of Flyve MDM Plugin for GLPI.
*
* Flyve MDM Plugin for GLPI is a subproject of Flyve MDM. Flyve MDM is a mobile
* device management software.
*
* Flyve MDM Plugin for GLPI is free software: you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* Flyve MDM Plugin for GLPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
* You should have received a copy of the GNU Affero General Public License
* along with Flyve MDM Plugin for GLPI. If not, see http://www.gnu.org/licenses/.
* ------------------------------------------------------------------------------
* @author Thierry Bugier
* @copyright Copyright © 2017 Teclib
* @license AGPLv3+ http://www.gnu.org/licenses/agpl.txt
* @link https://github.com/flyve-mdm/flyve-mdm-glpi-plugin
* @link https://flyve-mdm.com/
* ------------------------------------------------------------------------------
*/
namespace tests\units;

use Glpi\Test\CommonTestCase;

class PluginFlyvemdmFleet extends CommonTestCase {

public function setUp() {
parent::setUp();
self::setupGLPIFramework();
$this->boolean($this->login('glpi', 'glpi'))->isTrue();
}

/**
* @engine inline
*/
public function testDefineTabs() {
// Test a managed fleet shows the policies tab
$instance = $this->newInstance();
$instance->add([
'name' => 'I manage devices',
'entities_id' => $_SESSION['glpiactive_entity'],
]);
$this->boolean($instance->isNewItem())->isFalse();
$tabs = $instance->defineTabs();
$this->array($tabs)->hasKey('PluginFlyvemdmTask$1');

// Test a not manged fleet does not show a policies tab
$instance = $this->newInstance();
$instance->getFromDBByCrit([
'AND' => [
'entities_id' => $_SESSION['glpiactive_entity'],
'is_default' => '1',
],
]);
$this->boolean($instance->isNewItem())->isFalse();
$tabs = $instance->defineTabs();
$this->array($tabs)->notHasKey('PluginFlyvemdmTask$1');

}
}

0 comments on commit 250cbeb

Please sign in to comment.