[icinga-checkins] icinga.org: icinga-web/master: Added regression test for bug refs #2857

git at icinga.org git at icinga.org
Fri Oct 19 12:19:57 CEST 2012


Module: icinga-web
Branch: master
Commit: 48d5a5b35532f9a9e97da15d0079d6abd4039e69
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=48d5a5b35532f9a9e97da15d0079d6abd4039e69

Author: Marius Hein <marius.hein at netways.de>
Date:   Mon Jul 16 14:15:30 2012 +0200

Added regression test for bug refs #2857

---

 tests/phpunit/suites.xml                           |   91 ++++++++++----------
 .../phpunit/tests/regression/bugs/Bug2857Test.php  |   72 +++++++++++++++
 2 files changed, 119 insertions(+), 44 deletions(-)

diff --git a/tests/phpunit/suites.xml b/tests/phpunit/suites.xml
index cfdab7c..42f42b9 100644
--- a/tests/phpunit/suites.xml
+++ b/tests/phpunit/suites.xml
@@ -1,53 +1,56 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <phpunit  bootstrap="TestInit.php">
-	<logging>
-		 <log type="junit" target="./../../.build/test-results.xml" logIncompleteSkipped="false"/>
-	</logging>
-	
-	<testsuites>
-		<testsuite name="Bootstrap" >
-			<file>tests/phpunit/tests/bootstrap/agaviBootstrapTest.php</file>
-		</testsuite>
-		<testsuite name="Installation">
-			<file>tests/phpunit/tests/installation/userRightsTest.php</file>
-			<file>tests/phpunit/tests/installation/configSettingsTest.php</file>	
-		</testsuite>
-		<testsuite name="Module">
-			<file>tests/phpunit/tests/module/ModuleLoadingTest.php</file>
-		</testsuite>-->
-		<testsuite name="AppKit">
+    <logging>
+         <log type="junit" target="./../../.build/test-results.xml" logIncompleteSkipped="false"/>
+    </logging>
+    
+    <testsuites>
+        <testsuite name="Bootstrap" >
+            <file>tests/phpunit/tests/bootstrap/agaviBootstrapTest.php</file>
+        </testsuite>
+        <testsuite name="Installation">
+            <file>tests/phpunit/tests/installation/userRightsTest.php</file>
+            <file>tests/phpunit/tests/installation/configSettingsTest.php</file>    
+        </testsuite>
+        <testsuite name="Module">
+            <file>tests/phpunit/tests/module/ModuleLoadingTest.php</file>
+        </testsuite>-->
+        <testsuite name="AppKit">
             <directory>tests/phpunit/tests/appkit/</directory>
         </testsuite>
         <testsuite name="Configuration">
-			<file>tests/phpunit/tests/configuration/ApiProviderRoutesTest.php</file>
-			<file>tests/phpunit/tests/configuration/ApiValidationParserTest.php</file>
-		</testsuite>
-		<testsuite name="Validators">
-			<file>tests/phpunit/tests/validators/AppKitJsonValidatorTest.php</file>
-	        </testsuite>
+            <file>tests/phpunit/tests/configuration/ApiProviderRoutesTest.php</file>
+            <file>tests/phpunit/tests/configuration/ApiValidationParserTest.php</file>
+        </testsuite>
+        <testsuite name="Validators">
+            <file>tests/phpunit/tests/validators/AppKitJsonValidatorTest.php</file>
+            </testsuite>
         <testsuite name="Database">
-			<file>tests/phpunit/tests/configDatabase/icingaDatabaseAccessibleTest.php</file>
-			<!-- <file>tests/phpunit/tests/configDatabase/icingaUserOperations.php</file> -->
-			<!-- <file>tests/phpunit/tests/configDatabase/icingaRoleOperations.php</file> -->
-			<file>tests/phpunit/tests/configDatabase/persistenceView.php</file>
-		</testsuite>
-
-		<testsuite name="Interface">
-			<file>tests/phpunit/tests/interface/availabilityTest.php</file>
-		</testsuite>
+            <file>tests/phpunit/tests/configDatabase/icingaDatabaseAccessibleTest.php</file>
+            <!-- <file>tests/phpunit/tests/configDatabase/icingaUserOperations.php</file> -->
+            <!-- <file>tests/phpunit/tests/configDatabase/icingaRoleOperations.php</file> -->
+            <file>tests/phpunit/tests/configDatabase/persistenceView.php</file>
+        </testsuite>
+        <testsuite name="Interface">
+            <file>tests/phpunit/tests/interface/availabilityTest.php</file>
+        </testsuite>
+        
+        <testsuite name="Regression">
+            <directory>tests/regression/bugs</directory>
+        </testsuite>
 
-		<testsuite name="API">
-		<!--
-			<file>tests/phpunit/tests/api/ConsoleInterfaceTest.php</file>
-			<directory>tests/phpunit/tests/api/hosts</directory>
-			<directory>tests/phpunit/tests/api/services</directory>	
-			<directory>tests/phpunit/tests/api/hostgroups</directory>	
-			<directory>tests/phpunit/tests/api/servicegroups</directory>
-			<directory>tests/phpunit/tests/api/misc</directory>
-		-->
-		</testsuite>
-		
-		<!--
+        <!-- 
+        <testsuite name="API">
+            <file>tests/phpunit/tests/api/ConsoleInterfaceTest.php</file>
+            <directory>tests/phpunit/tests/api/hosts</directory>
+            <directory>tests/phpunit/tests/api/services</directory> 
+            <directory>tests/phpunit/tests/api/hostgroups</directory>   
+            <directory>tests/phpunit/tests/api/servicegroups</directory>
+            <directory>tests/phpunit/tests/api/misc</directory>
+        </testsuite>
+        -->
+        
+        <!--
         <testsuite name="ApiProvider">
             <file>tests/phpunit/tests/api/apiprovider/FilterTest.php</file>
             <file>tests/phpunit/tests/api/apiprovider/DataStoreTest.php</file>
@@ -56,5 +59,5 @@
         </testsuite>
         -->
         
-	</testsuites>
+    </testsuites>
 </phpunit>
diff --git a/tests/phpunit/tests/regression/bugs/Bug2857Test.php b/tests/phpunit/tests/regression/bugs/Bug2857Test.php
new file mode 100644
index 0000000..f824022
--- /dev/null
+++ b/tests/phpunit/tests/regression/bugs/Bug2857Test.php
@@ -0,0 +1,72 @@
+<?php
+
+class Bug2857Test extends PHPUnit_Framework_TestCase {
+    
+    const HOSTGROUP = 'XXX_DOES_NOT_EXIST';
+    const TEMPLATE = 'icinga-open-problems-template';
+    const CONNECTION = 'icinga';
+    
+    protected $target_value = null;
+    protected $principal_target = null;
+    
+    public function setUp() {
+        IcingaWebTestTool::authenticateTestUser();
+        $ctx = IcingaWebTestTool::getContext();
+        $user = $ctx->getUser();
+        $record = $user->getNsmUser();
+        
+        $principal = $record->principal;
+        
+        $target = Doctrine::getTable('NsmTarget')
+            ->findOneBy("target_name",'IcingaHostgroup');
+        
+        $this->principal_target = new NsmPrincipalTarget();

+        $this->principal_target->NsmPrincipal = $principal;

+        $this->principal_target->NsmTarget = $target;
+        
+        $this->target_value = new NsmTargetValue();

+        $this->target_value->tv_key = 'hostgroup';

+        $this->target_value->tv_val = self::HOSTGROUP;
+        
+        $this->principal_target->NsmTargetValue[] = $this->target_value;
+        
+        $this->target_value->save();
+        
+        $this->principal_target->save();
+        
+        $this->assertGreaterThan(0, $this->target_value->tv_pt_id);
+        $this->assertGreaterThan(0, $this->principal_target->pt_id);
+    }
+    
+    public function tearDown() {
+        $this->assertInstanceOf("NsmTargetValue", $this->target_value);
+        $this->assertInstanceOf("NsmPrincipalTarget", $this->principal_target);
+        $this->target_value->delete();
+        $this->principal_target->delete();
+    }
+    
+    /**

+     * @group Bug

+     */

+    public function testBug() {

+        $ctx = IcingaWebTestTool::getContext();
+        
+        $file = AppKitFileUtil::getAlternateFilename(
+            AgaviConfig::get('modules.cronks.xml.path.grid'), 
+            self::TEMPLATE, 
+            '.xml'
+        );
+        
+        $template = new CronkGridTemplateXmlParser(
+            $file->getRealPath(),
+            $ctx
+        );
+        

+        $template->parseTemplate();
+        
+        $worker = CronkGridTemplateWorkerFactory
+            ::createWorker($template, $ctx, self::CONNECTION);
+        
+        $this->assertGreaterThanOrEqual(0, $worker->countResults());

+    }
+}
\ No newline at end of file





More information about the icinga-checkins mailing list