diff --git a/library/Icinga/Web/Hook/Configuration/ConfigurationTab.php b/library/Icinga/Web/Hook/Configuration/ConfigurationTab.php deleted file mode 100644 index 28538687b..000000000 --- a/library/Icinga/Web/Hook/Configuration/ConfigurationTab.php +++ /dev/null @@ -1,145 +0,0 @@ -setModuleName($name); - - if ($title === null) { - $this->setTitle($name); - } - } - - if ($url !== null) { - $this->setUrl($url); - } - - if ($title !== null) { - $this->setTitle($title); - } - } - - /** - * Setter for title - * @param string $title - */ - public function setTitle($title) - { - $this->title = $title; - } - - /** - * Getter for title - * @return string - */ - public function getTitle() - { - return $this->title; - } - - /** - * Setter for url - * @param string $url - */ - public function setUrl($url) - { - $this->url = $url; - } - - /** - * Getter for url - * @return string - */ - public function getUrl() - { - return $this->url; - } - - /** - * Setter for module name - * @param string $moduleName - */ - public function setModuleName($moduleName) - { - $this->moduleName = $moduleName; - } - - private function assertConfiguration() - { - if (!$this->moduleName) { - throw new ProgrammingError('moduleName is missing'); - } - - if (!$this->getUrl()) { - throw new ProgrammingError('url is missing'); - } - - if (!$this->getTitle()) { - throw new ProgrammingError('title is missing'); - } - } - - /** - * Returns a tab configuration to build configuration links - * @return array - */ - public function getTab() - { - $this->assertConfiguration(); - - return array( - 'title' => $this->getTitle(), - 'url' => $this->getUrl() - ); - } - - /** - * Return the tab key - * @return string - */ - public function getModuleName() - { - $this->assertConfiguration(); - return $this->moduleName; - } -} diff --git a/library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php b/library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php deleted file mode 100644 index c84073e1e..000000000 --- a/library/Icinga/Web/Hook/Configuration/ConfigurationTabBuilder.php +++ /dev/null @@ -1,107 +0,0 @@ -setTabs($tabs); - - $this->initializeSystemConfigurationTabs(); - } - - /** - * Setter for tabs - * @param \Icinga\Web\Widget\Tabs $tabs - */ - public function setTabs($tabs) - { - $this->tabs = $tabs; - } - - /** - * Getter for tabs - * @return \Icinga\Web\Widget\Tabs - */ - public function getTabs() - { - return $this->tabs; - } - - /** - * Build the tabs - * - */ - public function build() - { - /** @var ConfigurationTab $configTab */ - $configTab = null; - foreach (Hook::all(self::HOOK_NAMESPACE) as $configTab) { - if (!$configTab instanceof ConfigurationTabInterface) { - throw new ProgrammingError('tab not instance of ConfigTabInterface'); - } - - $this->getTabs()->add($configTab->getModuleName(), $configTab->getTab()); - } - } - - /** - * Initialize system configuration tabs - */ - public function initializeSystemConfigurationTabs() - { - $configurationTab = new ConfigurationTab( - 'configuration', - 'configuration/index', - 'Configuration' - ); - - // Display something about us - Hook::registerObject( - ConfigurationTabBuilder::HOOK_NAMESPACE, - $configurationTab->getModuleName(), - $configurationTab - ); - - $modulesOverviewTab = new ConfigurationTab( - 'modules', - 'modules/overview', - 'Modules' - ); - - Hook::registerObject( - ConfigurationTabBuilder::HOOK_NAMESPACE, - $modulesOverviewTab->getModuleName(), - $modulesOverviewTab - ); - } -} diff --git a/library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php b/library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php deleted file mode 100644 index 064bd8450..000000000 --- a/library/Icinga/Web/Hook/Configuration/ConfigurationTabInterface.php +++ /dev/null @@ -1,27 +0,0 @@ -build(); - $tabs = $builder->getTabs(); - - $this->assertInstanceOf('Icinga\\Web\\Widget\\Tab', $tabs->get('configuration')); - } - - public function testTabCreation1() - { - $widget = new Tabs(); - $builder = new ConfigurationTabBuilder($widget); - - $tab1 = new ConfigurationTab('test1', '/test1', 'TEST1'); - $tab2 = new ConfigurationTab('test2', '/test2', 'TEST2'); - $tab3 = new ConfigurationTab('test3', '/test3', 'TEST3'); - - Hook::registerObject(ConfigurationTabBuilder::HOOK_NAMESPACE, 'test1', $tab1); - Hook::registerObject(ConfigurationTabBuilder::HOOK_NAMESPACE, 'test2', $tab2); - Hook::registerObject(ConfigurationTabBuilder::HOOK_NAMESPACE, 'test3', $tab3); - - $builder->build(); - - $this->assertCount(5, $builder->getTabs()); - } - - /** - * @expectedException Icinga\Exception\ProgrammingError - * @expectedExceptionMessage tab not instance of ConfigTabInterface - */ - public function testTabCreation2() - { - $widget = new Tabs(); - $builder = new ConfigurationTabBuilder($widget); - - $tab = Mockery::mock('Tab'); - Hook::registerObject(ConfigurationTabBuilder::HOOK_NAMESPACE, 'misc', $tab); - $builder->build(); - - $this->assertCount(5, $builder->getTabs()); - } -} diff --git a/test/php/library/Icinga/Web/Hook/Configuration/ConfigurationTabTest.php b/test/php/library/Icinga/Web/Hook/Configuration/ConfigurationTabTest.php deleted file mode 100644 index 6f9fdaeb1..000000000 --- a/test/php/library/Icinga/Web/Hook/Configuration/ConfigurationTabTest.php +++ /dev/null @@ -1,79 +0,0 @@ -assertEquals('test1', $tab->getModuleName()); - - $testArray = array( - 'title' => 'TEST_TITLE', - 'url' => '/test/$555' - ); - - $this->assertEquals($testArray, $tab->getTab()); - } - - public function testCreate2() - { - $tab = new ConfigurationTab( - 'test2', - '/test/$666' - ); - - $this->assertEquals('test2', $tab->getModuleName()); - - $testArray = array( - 'title' => 'test2', - 'url' => '/test/$666' - ); - - $this->assertEquals($testArray, $tab->getTab()); - } - - /** - * @expectedException Icinga\Exception\ProgrammingError - * @expectedExceptionMessage moduleName is missing - */ - public function testException1() - { - $tab = new ConfigurationTab(); - $tab->getTab(); - } - - /** - * @expectedException Icinga\Exception\ProgrammingError - * @expectedExceptionMessage url is missing - */ - public function testException2() - { - $tab = new ConfigurationTab(); - $tab->setModuleName('DING1'); - $tab->getTab(); - } - - /** - * @expectedException Icinga\Exception\ProgrammingError - * @expectedExceptionMessage title is missing - */ - public function testException3() - { - $tab = new ConfigurationTab(); - $tab->setModuleName('DING1'); - $tab->setUrl('/ding/dong'); - $tab->getTab(); - } -}