Skip to content

Commit

Permalink
Extend tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martialblog committed Aug 2, 2024
1 parent 2b9e797 commit 55dec68
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ _icingaweb2/
_libraries/
.phpunit.cache/
.phplint.cache/
reports/
/docker-compose.yml
/*.phar
/Icinga
Expand Down
14 changes: 12 additions & 2 deletions application/controllers/ShowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ public function treeAction()
{
$this->view->name = $name = $this->params->getRequired('name');

$c = new ViewConfig();
$config_dir_module = Icinga::app()
->getModuleManager()
->getModule('toplevelview')
->getConfigDir();

$c = new ViewConfig($config_dir_module);

// Check if the user has permissions/restrictions for this View
$restrictions = $c->getRestrictions('toplevelview/filter/views');
Expand All @@ -95,7 +100,12 @@ public function sourceAction()
{
$this->view->name = $name = $this->params->getRequired('name');

$c = new ViewConfig();
$config_dir_module = Icinga::app()
->getModuleManager()
->getModule('toplevelview')
->getConfigDir();

$c = new ViewConfig($config_dir_module);

// Check if the user has permissions/restrictions for this View
$restrictions = $c->getRestrictions('toplevelview/filter/views');
Expand Down
7 changes: 7 additions & 0 deletions test/php/library/Toplevelview/ViewConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,12 @@ public function testViewConfigWithNoError()
$view = $c->loadByName('example');

$this->assertStringContainsString('linux-servers', $view->getText());
$this->assertSame('5fc0ad55066b871d376eee60c84300d32ac7cb1d', $view->getTextChecksum());
$this->assertSame('yml', $view->getFormat());
$this->assertSame('example', $view->getName());

$clone = clone $view;
$this->assertSame(null, $clone->getName());
$this->assertFalse($clone->hasBeenLoaded());
}
}

0 comments on commit 55dec68

Please sign in to comment.