[icinga-checkins] icinga.org: icingaweb2-module-director/master: ExtensibleSet: fix tests

git at icinga.org git at icinga.org
Mon Feb 29 20:39:05 CET 2016


Module: icingaweb2-module-director
Branch: master
Commit: 245e632f54dba777fc8e0da3f1454eba55cc44ac
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=245e632f54dba777fc8e0da3f1454eba55cc44ac

Author: Thomas Gelf <thomas at gelf.net>
Date:   Mon Feb 29 17:37:01 2016 +0100

ExtensibleSet: fix tests

---

 library/Director/IcingaConfig/ExtensibleSet.php     |    2 +-
 .../Director/IcingaConfig/ExtensibleSetTest.php     |   19 +++++++++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/library/Director/IcingaConfig/ExtensibleSet.php b/library/Director/IcingaConfig/ExtensibleSet.php
index 0347af9..d5a5e36 100644
--- a/library/Director/IcingaConfig/ExtensibleSet.php
+++ b/library/Director/IcingaConfig/ExtensibleSet.php
@@ -317,7 +317,7 @@ class ExtensibleSet
             $parts[] = c::renderKeyOperatorValue(
                 $key,
                 '-=',
-                c::renderArray($this->plusValues),
+                c::renderArray($this->minusValues),
                 $prefix
             );
         }
diff --git a/test/php/library/Director/IcingaConfig/ExtensibleSetTest.php b/test/php/library/Director/IcingaConfig/ExtensibleSetTest.php
index 23fbad7..63f343d 100644
--- a/test/php/library/Director/IcingaConfig/ExtensibleSetTest.php
+++ b/test/php/library/Director/IcingaConfig/ExtensibleSetTest.php
@@ -3,6 +3,7 @@
 namespace Tests\Icinga\Module\Director\IcingaConfig;
 
 use Icinga\Module\Director\IcingaConfig\ExtensibleSet;
+use Icinga\Module\Director\Objects\IcingaUser;
 use Icinga\Module\Director\Test\BaseTestCase;
 
 class ExtensibleSetTest extends BaseTestCase
@@ -28,6 +29,16 @@ class ExtensibleSetTest extends BaseTestCase
         );
     }
 
+    public function testConstructorAcceptsSingleValues()
+    {
+        $set = new ExtensibleSet('Bla');
+
+        $this->assertEquals(
+            array('Bla'),
+            $set->getResolvedValues()
+        );
+    }
+
     public function testSingleValuesCanBeBlacklisted()
     {
         $values = array('Val1', 'Val2', 'Val4');
@@ -96,12 +107,12 @@ class ExtensibleSetTest extends BaseTestCase
 
     public function testInheritedValuesCanBeBlacklisted()
     {
-        $pset = array('p1', 'p2', 'p3');
-
         $child = new ExtensibleSet();
         $child->blacklist('p2');
 
+        $pset = array('p1', 'p2', 'p3');
         $parent = new ExtensibleSet($pset);
+
         $child->inheritFrom($parent);
         $child->blacklist(array('not', 'yet', 'p1'));
 
@@ -136,12 +147,12 @@ class ExtensibleSetTest extends BaseTestCase
     public function testCombinedDefinitionRendersCorrectly()
     {
         $set = new ExtensibleSet(array('pre', 'def', 'ined'));
-        $set->blacklist('and', 'not', 'those');
+        $set->blacklist(array('and', 'not', 'those'));
         $set->extend('plus this');
 
         $out = '    key_name = [ "pre", "def", "ined" ]' . "\n"
              . '    key_name += [ "plus this" ]' . "\n"
-             . '    key_name -= [ "plus this" ]' . "\n";
+             . '    key_name -= [ "and", "not", "those" ]' . "\n";
 
         $this->assertEquals(
             $out,



More information about the icinga-checkins mailing list